Search code examples
djangovirtualenvpython-venvdjango-apps

virtualenv raises importerror because of changing app name in django


I've used [this link] to rename my django app. So I've edited some files and table's name and so on. But as it has been mentioned in that link, There is problem with virtualenv. So how can I fix it? I've change name "notes" to "blog".

enter image description here

The apps.py file:

from django.apps import AppConfig
                                
class NotesConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'blog'

In the settings.py file:

INSTALLED_APPS = [
    'blog.apps.BlogConfig',
    // the rest installed apps
]

Solution

  • Lets say the name of this application is: blog and its following the normal folder structure django comes with. so, the settings.py should be

    INSTALLED_APPS = [
        'blog',
    ]
    

    and the apps.py should be

    from django.apps import AppConfig
                                    
    class BlogConfig(AppConfig):
        default_auto_field = 'django.db.models.BigAutoField'
        name = 'blog'