Create tables for models in your database

28 views
Skip to first unread message

tal...@gmail.com

unread,
Sep 22, 2018, 8:21:10 AM9/22/18
to Django users
Hi

getting an error while run this code...

python manage.py makemigrations blog
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dheerajkumar/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/dheerajkumar/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/home/dheerajkumar/.local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/dheerajkumar/.local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/home/dheerajkumar/.local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/dheerajkumar/djangogirls/myvenv/myproject/blog/models.py", line 6
    author = models.Foreignkey('auth.User', on_delete=models.CASCADE)
         ^
IndentationError: expected an indented block


please help, I'm new in Django

Kasper Laudrup

unread,
Sep 22, 2018, 8:33:12 AM9/22/18
to django...@googlegroups.com
Hi,

On 22/09/2018 14.21, tal...@gmail.com wrote:
>
> getting an error while run this code...
>
> "/home/dheerajkumar/djangogirls/myvenv/myproject/blog/models.py",
> line 6
>     author = models.Foreignkey('auth.User', on_delete=models.CASCADE)
>          ^
> IndentationError: expected an indented block
>

As the error message clearly states, you have an error on line 6 in your
models.py file where a line doesn't match the expected indentation.

Python uses indentation for scoping. This is very fundamental in python.

I would suggest you use an editor that understands python. Then you
would most like have the error highlighted on that exact line and the
editor would help you by suggesting different indentations, so you'd be
able to fix the error before even running the code.

Which editor to choose is mostly a matter of taste, but I do highly
recommend something that understands python. That will help you a lot
and save you a lot of time.

Kind regards,

Kasper Laudrup

Dheeraj Kumar

unread,
Sep 22, 2018, 9:08:13 AM9/22/18
to django...@googlegroups.com
Thanks. I'm going to install pycharm now.

--
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...@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/27f41b64-da4b-e1ef-7ef8-31fe6db0df3b%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages