Open In App

Django - Dealing with Unapplied Migration Warnings

Last Updated : 16 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Django is a powerful web framework that provides a clean, reusable architecture to build robust applications quickly. It embraces the DRY (Don't Repeat Yourself) principle, allowing developers to write minimal, efficient code.

Create and setup a Django project:

Prerequisite: Django - Creating project

After setting up a new Django project, your directory structure may look something like this:

At first, it might seem confusing to see two folders with the same name. Here’s the clarification:

  • The outer folder is just the project container you can rename it to anything.
  • The inner folder contains the actual project settings and should not be renamed, as Django depends on that name internally.

For example, renaming the outer folder to geeksforgeeks will give you:

Unapplied Migrations Warning

After completing your setup, run the server using command:

python manage.py runserver

You may encounter a red warning message like:

You have 15 unapplied migrations. Your project may not work properly until you apply the migrations...

These warnings indicate that there are pending database schema changes that haven’t been applied yet. While your project might run, these should not be ignored.

How to Fix:

Stop the development server using CTRL+C and run:

python manage.py migrate

Now on your command prompt, you will see something like this:

This command applies all pending migrations and sets up your database schema correctly.

Now, restart the server:

python manage.py runserver

Doing this will remove the warnings.

Moving towards Django Apps

As our project grows, it’s a best practice to shift functionality into separate Django apps. These apps help modularize features and keep your code maintainable and scalable.

If you’ve added a function-based view like this in views.py:

Python
# geeks_site/views.py
from django.http import HttpResponse

def hello_geeks(request):
    return HttpResponse("Hello, Geeks!")

Add this route in urls.py:

Python
from geeks_site.views import hello_geeks

urlpatterns = [
    path('geek/', hello_geeks),
]

Next Article
Article Tags :
Practice Tags :

Similar Reads