14π
Django needs to be able to import your application, usually this means including the full path relative to the root directory 'myproject.blog'
.
You could add <full_path_to_your_project>/myproject/myproject
to PYTHONPATH
so that you can import blog
, but I would not recommend it
20π
Directory structure is unusual. More usual and the one that matches your app being named blog would be
myproject/
βββ myproject
β βββ __init__.py
β βββ __pycache__
β β βββ __init__.cpython-36.pyc
β β βββ settings.cpython-36.pyc
β β βββ urls.cpython-36.pyc
β β βββ wsgi.cpython-36.pyc
βββ blog
β βββ __init__.py
β βββ admin.py
β βββ apps.py
β βββ migrations
β β βββ __init__.py
β βββ models.py
β βββ tests.py
β βββ views.py
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
βββ db.sqlite3
βββ manage.py
- Best way of linking to a page in Django
- Mixing HTML5 Canvas and Python
- How can my Model primary key start with a specific number?
- Django Model Choices: IntegerField vs CharField
0π
My problem is solved by adding the path of the app in the settings.py of myproject in this below format
INSTALLED_APPS = [
'blog.apps.BlogConfig', # <app_name>.apps.<class_name>
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', ]
0π
I had a similar issue .Turns out I had already registered my app in the settings.py before running βpython manage.py startapp #myapp.
- Python and sqlite3 β importing and exporting databases
- Multiple Django apps, shared authentication
-2π
I usually add the config path to installed apps to avoid this problem. So installed apps would look like this:
NSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog,apps.BlogConfig',