Why error occurs during the migration?

In django 3.0.3 set up a simple model. Want to do the migration:
python3 manage.py makemigrations articles
but I get an error:
django.core.exceptions.Improperly configured: 'articles.apps.AppConfig' must supply a name attribute. (what attribute name in question, I can not understand)
I understand that the error is somewhere with the name of your application, but what do not understand.
Here is the configuration file settings.py
import os
import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

PROJECT_ROOT = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(PROJECT_ROOT, 'apps'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!xa^x)#*nd0^n52al)cg5q_ikcb@vy_&7_%&byq^2e#@midnzt'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'articles.apps.AppConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

In this file IDE dissatisfied with the said record:
'articles.apps.AppConfig',

And the contents of the file apps.ru

from django.apps import AppConfig

class MyAppConfig(AppConfig):
 name = 'articles'

And this file was highlighted: 'articles'

Tell me, what could be the problem?
April 7th 20 at 11:05
1 answer
April 7th 20 at 11:07
Change settings.py:
INSTALLED_APPS = [
 'the website.apps.articles', # or 'website.apps.articles.apps.MyAppConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]


And apps.py:
from django.apps import AppConfig

class MyAppConfig(AppConfig):
 name = 'articles' # or 'the website.apps.articles'


https://docs.djangoproject.com/en/3.0/ref/applications/
No, not working.
The documentation I have read. - Mabelle.Dickins commented on April 7th 20 at 11:10
And the contents of the file apps.ru

apps.ru - a typo in the text of the question or he really has such a name? - alda_Von64 commented on April 7th 20 at 11:13
@alda_Von64, Yes, it does. - Mabelle.Dickins commented on April 7th 20 at 11:16
@Mabelle.Dickins, change the title to apps.py and try again. - alda_Von64 commented on April 7th 20 at 11:19
@alda_Von64, sorry. Phone watched. Of course it is Python file and expanding it - py - Mabelle.Dickins commented on April 7th 20 at 11:22
@Mabelle.Dickins, attach the contents of your application articles - alda_Von64 commented on April 7th 20 at 11:25
There is something wrong associated with moving the applications folder in apps. But what I can not understand! PyCharm highlights the line
'articles.apps.AppConfig',
and in another place stressed
'articles'
But what he is not, is not specified. Says "Unresolved reference 'articles'" - Mabelle.Dickins commented on April 7th 20 at 11:28
@Mabelle.Dickins, maybe your application folder has incorrect name, check it with what you have in apps.py - alda_Von64 commented on April 7th 20 at 11:31
@Mabelle.Dickins, should be like this:
the directory project/
articles/
__init__.py/
apps.py/
admin.py/
models.py/
 ...etc.
- alda_Von64 commented on April 7th 20 at 11:34
@alda_Von64, looked like all true....
How do you like the archive folder to transfer to see? - Mabelle.Dickins commented on April 7th 20 at 11:37
@Mabelle.Dickins, can google or yandex disk to fill. - alda_Von64 commented on April 7th 20 at 11:40
Here's the structure:
5e4202dbd8453003868731.jpeg - Mabelle.Dickins commented on April 7th 20 at 11:43
https://drive.google.com/open?id=1LwAn2X1u5jz4mx8z... - Mabelle.Dickins commented on April 7th 20 at 11:46
@Mabelle.Dickins, you have the application folder is inside the folder of the project in INSTALLED_APPS, you must specify the path beginning with her:
INSTALLED_APPS = [
 'the website.apps.articles', # or 'website.apps.articles.apps.MyAppConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]


Or you can change the project structure to this:
website/
articles/
__init__.py
admin.py
apps.py
models.py
tests.py
views.py/
website/
__init__.py
asgi.py
settings.py
urls.py
wsgi.py
venv/
templates/
db.sqlite3
 manage.py


Then you will have to work the code you provided in the question. - alda_Von64 commented on April 7th 20 at 11:49
Well. Try or so or so.
It is strange that did not like the IDE in the file apps.py then, with the word articles? - Mabelle.Dickins commented on April 7th 20 at 11:52
@Mabelle.Dickins, I don't use PyCharm so I can't answer. But perhaps because of incorrect entries in INSTALLED_APPS he swore... - alda_Von64 commented on April 7th 20 at 11:55
The problem could be solved only by the return of the applications folder to the place where it is placed django. Settings settings.py did not help, apparently something has changed in the new versions.
After a rollback folder and the settings it worked. - Mabelle.Dickins commented on April 7th 20 at 11:58
@Mabelle.Dickins, checked on version 3.0.3, your version, with the space application in the project folder, it works. Maybe you have somewhere a mistake.

If you want to leave the apps folder inside the project folder, you will need to change the settings file to this:
INSTALLED_APPS = [
 'the website.apps.articles', # or 'website.apps.articles.apps.MyAppConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

And file apps.py inside articles on this:
from django.apps import AppConfig

class MyAppConfig(AppConfig):
 name = 'articles' # or 'the website.apps.articles'


The second option stated in the review, it is necessary to use simultaneously, i.e., if you have settings.py the app added via 'the website.apps.articles.apps.MyAppConfig', and in apps.py you need to specify the option that is #, name = 'website.apps.articles'.

Here is the link on GitHub working on it all the options: https://github.com/alda_Von64/DjangoHabr
Can clone it, delete the migrations folder inside the app Articles and check. - alda_Von64 commented on April 7th 20 at 12:01

Find more questions by tags Django