Search code examples
pythondjangodjango-migrations

Why does django continues naming my app as the previous name?


thanks for reading.

When I run "py manage.py makemigrations" I get the following message: "ModuleNotFoundError: No module named 'transformaTe'"

This is the apps.py code:

from django.apps import AppConfig


class TransformateConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'transformate'

The name is updated there and in my INSTALLED_APPS:

INSTALLED_APPS = [
'transformate',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

Where else should I look to change the name of the app?

This is the simplified structure of the app:

\my-app
  \transformate
    admin.py
    apps.py
    models.py
    urls.py
    views.py
   \my-app
     asgi.py
     settigs.py
     urls.py
     wsgi.py

All this happened when I rename the app because I had a problem creating a table called transformaTe_myuser so I though all could be caused by the capitalized letter use.

Is there a better way of renaming an existing app in Django? I followed this steps, except for the migration part (Because I deleted the db and the migrations folder): https://odwyer.software/blog/how-to-rename-an-existing-django-application

Thanks for your help.


Solution

  • Well, it turns out that when you run makemigrations you have to check the project urls.py file, that was the only thing that was crashing my migrations.

    ORIGINAL my-app/urls. py FILE:

     from django.contrib import admin
    from django.urls import include, path
    
    urlpatterns = [
        path('', include('transformaTe.urls')),
        path('admin/', admin.site.urls),
    ]
    

    NEEDED FILE:

    from django.contrib import admin
    from django.urls import include, path
    
    urlpatterns = [
        path('', include('transformate.urls')), # Here was the bug
        path('admin/', admin.site.urls),
    ]