Django Templates Not Loading After Removing migrations Folder

In the command line I had run the following lines of code:
find . -path “/migrations/.pyc” -delete
rm db.sqlite3

After this I executed the following lines of code without any issues:
python mange.py makemigrations
python manage.py migrate

The problem I now have is that the web pages on my django application no longer load. And the “Sign Up” button to register an account doesn’t work even though the same source code is there as well as the same files.

“POST /register/ HTTP/1.1” 200 6610

I would appreciate any advice is solving this matter.

The development server is running without any noticeable issues.

On the first command, did you see the migrations being generated?

For the second command, did you see the migrations being applied?

What does manage.py showmigrations show? Does it show all the identified migrations as having been applied?

Are you saying that no web pages load? Do you just get a blank page? Or do you get an error?

What does your console show (the console where you run webserver) when you try to get a page?

The following is what I see when I run python manage.py showmigrations:
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
blog
[X] 0001_initial
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
sessions
[X] 0001_initial
users
[X] 0001_initial
[X] 0002_profile_facialimage_profile_is_facialimageset
[X] 0003_alter_profile_facialimage
[X] 0004_remove_profile_facialimage
[X] 0005_remove_profile_is_facialimageset
[X] 0006_profile_facialimage_profile_is_facialimageset

For the commands python manage.py makemigrations and python manage.py migrate, I did see changes being applied.

I don’t see an error message, but I just see a blank web page.

My console shows the following when I attempt to load the registration page:
“GET /register/ HTTP/1.1” 200 6610
“POST /register/ HTTP/1.1” 200 6610

We’ll need to see the view that creates that page along with the template being rendered. (Including any base template that this template may extend.)

Inside django_project I have the directories called django_project, users, and blog.
“users” and “blog” are both applications within the project.

Inside django_project → django_project → urls.py I have the following:

from users import views as user_views

urlpatterns = [
    path('register/', user_views.register, name = 'register'),
]

Inside django_project → users → views.py I have the following:

def register(request):
    if request.method == 'POST':
         if form.is_valid():
        form.save()
        username = form.cleaned_data.get('username')
        message.success(request, f'Your account has been created!')
        return redirect('login')
    else:
        form = UserRegistrationForm()
        return render(request, 'users/register.html')

Inside django_project → django_project → users → templates → users → register.html I have the following:

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}

{% block content %}
    <head>
        <script src="https://code.jquery.com/jquery-3.4.1.min.js" 
                integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
                crossorigin="anonymous">
        </script>
    </head>

    <div class="content-section">
        <form method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4">Join Today</legend> 

                {{ form|crispy }}
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Sign Up</button>
            </div>
        </form>
        <div class="border-top pt-3">
            <small class="text-muted">
                Already Have An Account? <a class="ml-2" href="{% url 'login' %}">Sign In</a>                                                 
            </small>
        </div>
    </div>
{% endblock content %}

Inside django_project → django_project → blog → templates → blog → base.html I have the following:

<!--This is our base template that other templates will inherit from.-->

{% load static %} <!--We are opening up a code block. We are loading our CSS from our static directory.-->
<!DOCTYPE html>
<html>
<head>
    <!--Below we have added boostrap. Bootstrap is a free and open source front end development 
        framework for the creation of websites and web apps.-->
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <!--This indicates that we want a link that is a style sheet with a type that is CSS.-->
    <!--href will indicate where the CSS file is located.-->
    <link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">

    <!--In this section we can add a title to our webpage.-->
    {% if title %}
        <!--If we have a title.-->
        <title>Django Blog - {{ title }}</title>
    {% else %}
        <!--If we don't have a title.-->
        <title>Django Blog</title>
    {% endif %} <!--This indicates that we are ending our if-else statement.-->
</head>
<body>
    <header class="site-header">
        <!--Below we have added a navigation bar with bootstrap CSS classes.-->
        <nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
          <div class="container">
            <!--If someone clicks on "Django Blog", it goes to 'blog-home'.-->
            <a class="navbar-brand mr-4" href="{% url 'blog-home' %}">Django Blog</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarToggle">
              <div class="navbar-nav mr-auto">
                <!--If someone clicks on "Home", it goes to 'blog-home'.-->
                <a class="nav-item nav-link" href="{% url 'blog-home' %}">Home</a>
                <!--If someone clicks on "About", it goes to 'blog-about'.-->
                <a class="nav-item nav-link" href="{% url 'blog-about' %}">About</a>
              </div>
              <!-- Navbar Right Side -->
              <div class="navbar-nav">
                <!--If the user is already authenticated, it means that they are logged in. 
                    Display the link to the logout route.-->
                {% if user.is_authenticated %}
                  <a class="nav-item nav-link" href="{% url 'post-create' %}">New Post</a>
                  <a class="nav-item nav-link" href="{% url 'profile' %}">Profile</a>
                  <a class="nav-item nav-link" href="{% url 'logout' %}">Logout</a>
                <!--If the user is not authenticated, then they are logged out, so we will
                    display the link to the 'login' route and the 'register' route.-->
                {% else %}
                  <!--The following is a link that goes nowhere: href="#"-->
                  <!--We are saying here that we want 'login' to be the url for the "Login" route.-->
                  <a class="nav-item nav-link" href="{% url 'login' %}">Login</a>
                  <a class="nav-item nav-link" href="{% url 'register' %}">Register</a>
                {% endif %}
              </div>
            </div>
          </div>
        </nav>
      </header>
      <main role="main" class="container">
        <div class="row">
          <div class="col-md-8">
            {% if messages %}
              {% for message in messages %}
                <div class="alert alert-{{ message.tags }}">
                  {{ message }}
                </div>
              {% endfor %}
            {% endif %} <!--This is to end the if statement.-->
            {% block content %}{% endblock %}
          </div>
          <div class="col-md-4">
            <div class="content-section">
              <h3>Our Sidebar</h3>
              <p class='text-muted'>You can put any information here you'd like.
                <ul class="list-group">
                  <li class="list-group-item list-group-item-light">Latest Posts</li>
                  <li class="list-group-item list-group-item-light">Announcements</li>
                  <li class="list-group-item list-group-item-light">Calendars</li>
                  <li class="list-group-item list-group-item-light">etc</li>
                </ul>
              </p>
            </div>
          </div>
        </div>
      </main>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <!-- Adding this allows us to use bootstrap specific CSS classes.-->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <!--We will have our home and about templates inherit this base template and get this information.-->
</body>
</html>

And you’re saying with this that you’re not seeing anything - that you’re getting a completely blank (white) page, with no errors being reported in the console at all. That you’re not seeing any of the buttons, links, nothing?

I apologise as I poorly stated the issue. I am not seeing a blank page. The problem is that the “Sign Up” button on the web page fails to allow me to register as it should. Any idea on why this is?

The image I am attaching is what I see when I attempt to click on the “Register” button that is located on the top right of the web page.

No worries - that why I ask questions.

Anyway, this is a lot easier to explain.

When the page is retrieved as a GET, it executes this code:

You’re creating the form, but you’re not passing it to the template in the context.

See the example in the view section of Working with forms, along with the render docs for more information.

Yes! Thank you very much Mr. Whitesell! The register page is now working!

Unfortunately, I cannot say the same as the admin page. When I try to go to http://127.0.0.1:8000/admin/ and login with the username “deniz” and the correct password, I get the following result in the image I am attaching below:

The response from the web page when I attempt to access as admin’s page is the following:
“You are authenticated as deniz, but are not authorized to access this page. Would you like to login to a different account?”

What could be the cause of this problem?

However, when I attempt to create a superuser in the terminal, I am told that a super user with that same username “deniz” is already taken.

Yes, you have a user in your system named “deniz”. However, it’s not a super-user. That’s why you’re getting the responses you’re seeing.

You can either create a different user name for your super user, or you can use the Django shell to change “deniz” to be a super user.

Thank you very much sir! Admin page is working!