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
On Mon, Jul 2, 2018 at 10:40 PM, Tamilvanan Anbalagan <tamilanbalagan@gmail.com> wrote:
--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_lineutility.execute()File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\ management\__ini t__.py", line 365, in executeself.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_commandklass = 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_classmodule = import_module('%s.management.commands.%s' % (app_name, name)) File "c:\users\nb97441\envs\py1\lib\importlib\__init__.py", line 126, in impor t_modulereturn _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_importFile "<frozen importlib._bootstrap>", line 971, in _find_and_loadFile "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 665, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "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 MigrationLoaderFile "c:\users\nb97441\envs\py1\lib\site-packages\django\db\ migrations\loader. py", line 8, in <module>from django.db.migrations.recorder import MigrationRecorderFile "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 MigrationRecorderclass 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_configself.check_apps_ready()File "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\ registry.py", li ne 127, in check_apps_readyraise 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 modelsfrom django.contrib.auth.models import Userclass Post(models.Model):post = models.CharField(max_length=255 )user = models.ForeignKey(User, on_delete=models.PROTECT)
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-users@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 .
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-users@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/CAEqej2N%2Bxjn4%2BGrj8GtwTwUTbA-V2Vr33mZxNP9U2Htbp%3DmJqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment