# beginner problem with models.py sql command is not applied?

**URL:** <https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693>\
**Category:** Getting Started\
**Created:** [March 19, 2022, 1:51pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693 "2022-03-19T13:51:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 19, 2022, 1:51pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/1 "2022-03-19T13:51:51Z")

</div>

Hey Guys,

iam pretty new to Django. Atm iam doing a tutorial on youtube to learn basic understandings.

In this tutorial i building my own project:

/mysite  
db.sqlite3  
manage.py  
./mysite/  
**init**.py  
asgi.py  
settings.py  
urls.py  
wsgi.py  
./polls/  
**init**.py  
admin.py  
apps.py  
models.py  
tests.py  
urls.py  
views.py

i added this to ./polls/models.py

```auto
from django.db import models

# Create your models here.

class User(models.Model):
	name=models.CharField(max_length=128)
	email=models.CharField(max_length=128)

```

Shell:

```auto
python manage.py makemigrations 
No changes detected 
python3 manage.py migrate 
Operations to perform:                                                            
Apply all migrations: admin, auth, contenttypes, sessions                       
Running migrations:                                                               
No migrations to apply.

```

if iam checking db.sqlite3 there should be a tabel called usermodel\_user but is not in there. pls help.

Like i said iam complete beginner. Pls dont get angry for a stupid noob question 🙂

Why is the sql not applied?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 19, 2022, 2:30pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/2 "2022-03-19T14:30:38Z")

</div>

Personally, I recommend working through either the [Official Django Tutorial](https://docs.djangoproject.com/en/4.0/intro/tutorial01/) or the [Django Girls Tutorial](https://tutorial.djangogirls.org/en/). It’s hard to help you with a tutorial that I’m not familiar with, and can’t determine if it’s accurate or appropriate.

Beyond that, unless you’re planning to completely replace the functionality of the built-in `User` model, I wouldn’t name a model, `User`. I’d pick a different name. If you need to add functionality to `User`, see [Customizing authentication in Django | Django documentation | Django](https://docs.djangoproject.com/en/4.0/topics/auth/customizing/#extending-the-existing-user-model). However, as a beginning user, I wouldn’t recommend that as a starting point either.

Regarding your migrations, see [django-admin and manage.py | Django documentation | Django](https://docs.djangoproject.com/en/4.0/ref/django-admin/#makemigrations)

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 12:46pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/3 "2022-03-20T12:46:21Z")

</div>

Hey, i’ve already did the Official Django Tutorial. My polls app is working. So I’am now playing around sql.

I did nothing special just added this simple lines to my polls ap in models.py

```auto
from django.db import models

# Create your models here.

class User(models.Model):
	name=models.CharField(max_length=128)
	email=models.CharField(max_length=128)

```

the question if i run:

python3 manage.py makemigrations  
python3 manage.py migrate

nothing happens and the table will not appear in my sql file. I’am feeling complete stuck atm .

Maybe you can look at this simple lines why it is not creating a table in my database?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 20, 2022, 12:47pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/4 "2022-03-20T12:47:24Z")

</div>

The solution is documented here:

> [@KenWhitesell](#):
>
> Regarding your migrations, see [django-admin and manage.py | Django documentation | Django](https://docs.djangoproject.com/en/4.0/ref/django-admin/#makemigrations)

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 1:27pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/5 "2022-03-20T13:27:06Z")

</div>

Hey,

thx for your answer but i have Problembs with the syntax. What is applabel in  
`django-admin makemigrations [app_label [app_label ...]]`?

I tried

django-admin makemigrations mysite  
django-admin makemigrations polls

both gave me error output. Thx for your help.

```auto
django-admin makemigrations polls
Traceback (most recent call last):                                               
  File "/home/naseweis/.local/bin/django-admin", line 8, in <module>             
    sys.exit(execute_from_command_line())                                        
  File "/usr/local/lib/python3.9/site-packages/django/core/management/ __init__.py
", line 419, in execute_from_command_line                                        
    utility.execute()                                                            
  File "/usr/local/lib/python3.9/site-packages/django/core/management/ __init__.py
", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", l
ine 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", l
ine 393, in execute
    self.check()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", l
ine 419, in check
    all_issues = checks.run_checks(
  File "/usr/local/lib/python3.9/site-packages/django/core/checks/registry.py", l
ine 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/usr/local/lib/python3.9/site-packages/django/core/checks/model_checks.py
", line 18, in check_all_models
    models = apps.get_models()
  File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 179
, in get_models
    self.check_models_ready()
  File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 141
, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 20, 2022, 1:30pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/6 "2022-03-20T13:30:10Z")

</div>

Since you are running this in the context of an “active project”, you would use the `manage.py` command, not `django-admin`. (That’s documented at the top of that page.) You can use `django-admin`, but you would need to manually set the evironment. (`manage.py` does that for you.)

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 1:53pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/7 "2022-03-20T13:53:27Z")

</div>

ok i tried:

python3 manage.py makemigrations polls

No installed app with label ‘polls’.

my polls application running on the internet [http://naseweis.pythonanywhere.com/polls/](http://naseweis.pythonanywhere.com/polls/)

When Iam running:  
python3 manage.py makemigrations  
python3 manage.py migrate

it running through but it will not create the table in the sql file

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 20, 2022, 1:55pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/8 "2022-03-20T13:55:23Z")

</div>

What does your `installed_apps` setting look like in your `settings.py` file?

What are the contents of your `polls/apps.py` file?

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 2:01pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/9 "2022-03-20T14:01:13Z")

</div>

installed\_apps looks like this

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

```

Content of polls/app.py:

```auto
from django.apps import AppConfig

class PollsConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'polls'

```

Thanks a lot for your help

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 20, 2022, 2:03pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/10 "2022-03-20T14:03:12Z")

</div>

You need to include your polls app into the INSTALLED\_APPS.

See [Applications | Django documentation | Django](https://docs.djangoproject.com/en/4.0/ref/applications/#configuring-applications)

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 2:38pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/11 "2022-03-20T14:38:13Z")

</div>

I added that to my settings.py, but now i have errors on python3 manage.py check

```auto
ImportError: Module 'polls.apps' does not contain a 'PollsAppConfig' class. Choic
es are: 'PollsConfig'.

```

my /polls/apps.py look like this:

```auto
from django.apps import AppConfig

class PollsConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'polls'

```

this is the whole error code from manage.py check:

```auto
python3 manage.py check
Traceback (most recent call last):
  File "/home/naseweis/django_projects/mysite/manage.py", line 22, in <module>
    main()
  File "/home/naseweis/django_projects/mysite/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/ __init__.py
", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/ __init__.py
", line 395, in execute
    django.setup()
  File "/usr/local/lib/python3.9/site-packages/django/ __init__.py", line 24, in s
etup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 91,
 in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 221, 
in create
    raise ImportError(msg)
ImportError: Module 'polls.apps' does not contain a 'PollsAppConfig' class. Choic
es are: 'PollsConfig'.

```

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 2:39pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/12 "2022-03-20T14:39:19Z")

</div>

i managed to fix this

---

<div class="post-metadata">

**Author:** ![naseweis-io](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/naseweis-io/32/7552_2.png) [@naseweis-io](https://forum.djangoproject.com/u/naseweis-io)\
**Post date:** [March 20, 2022, 2:44pm UTC](https://forum.djangoproject.com/t/beginner-problem-with-models-py-sql-command-is-not-applied/12693/14 "2022-03-20T14:44:15Z")

</div>

Thx for your help now my polls application migrate correctly and i can continue with my tutorial

Much Much THX 😀 😀 😀
