Makemigration not working.. Please help me

29 views
Skip to first unread message

Tamilvanan Anbalagan

unread,
Jul 3, 2018, 1:40:16 AM7/3/18
to Django users

When i execute the makemigrations command i am getting below error pleae help me to resolve this




(py1) c:\TransportPortal\djangoproject>django-admin makemigrations portal
Traceback (most recent call last):
  File "c:\program files (x86)\python36-32\Lib\runpy.py", line 193, in _run_modu
le_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python36-32\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nb97441\Envs\py1\Scripts\django-admin.exe\__main__.py", line 9,
 in <module>
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
t__.py", line 371, in execute_from_command_line
    utility.execute()
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
t__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
t__.py", line 216, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
t__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "c:\users\nb97441\envs\py1\lib\importlib\__init__.py", line 126, in impor
t_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\comma
nds\makemigrations.py", line 10, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\autodet
ector.py", line 11, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\questio
ner.py", line 9, in <module>
    from .loader import MigrationLoader
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\loader.
py", line 8, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\recorde
r.py", line 9, in <module>
    class MigrationRecorder:
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\recorde
r.py", line 22, in MigrationRecorder
    class Migration(models.Model):
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\models\base.py", l
ine 100, in __new__
    app_config = apps.get_containing_app_config(module)
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py", li
ne 244, in get_containing_app_config
    self.check_apps_ready()
  File "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py", li
ne 127, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.


(py1) c:\TransportPortal\djangoproject>python manage.py check
System check identified no issues (0 silenced).

(py1) c:\TransportPortal\djangoproject>


from django.db import models
from django.contrib.auth.models import User


class Post(models.Model):
post = models.CharField(max_length=255)
user = models.ForeignKey(User, on_delete=models.PROTECT)

Mark Phillips

unread,
Jul 3, 2018, 2:01:27 AM7/3/18
to django users
To start with, in your Post class, you need to indent the post= and user= lines. Like this:

class Post(models.Model):
    post = models.CharField(....
    user = models. ForeignKey(......

Python depends on indentation - https://www.python-course.eu/python3_blocks.php. You can Google "Python indentation rules" for more explanation. 

There may be other things wrong with your code, but start by fixing this one thing and try again!

Mark

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/617b0048-6e23-4d82-b879-6e3b187ca039%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Keshav Garg

unread,
Jul 3, 2018, 11:07:36 AM7/3/18
to Django users
Make sure that your app_name is there in setting.py under INSTALLED_APPS and register your model under admin.py
Also there is indentation error in your model POST. Please correct it before running makemigrations command.
I hope this will Work :-)
Reply all
Reply to author
Forward
0 new messages