Problems with first program

51 views
Skip to first unread message

Edvani Pascoal

unread,
Feb 28, 2019, 6:14:33 PM2/28/19
to Django users
hey guys I'm beginner on django I never worked with this framework before and then I've problems to started polls app this is the error:
(my_env) root@ubuntu:~/django-test/djangoproject# python manage.py runserver 192.168.184.202:8000


Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fa7af08b9d8>
Traceback (most recent call last):
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
    app_config.import_models()
  File "/home/edvani/django-test/my_env/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_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 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/edvani/django-test/djangoproject/polls/models.py", line 5
    question_text = models.CharField(max_length=200)
                ^
IndentationError: expected an indented block


I need help how to solve this??

bob gailer

unread,
Feb 28, 2019, 7:07:02 PM2/28/19
to django...@googlegroups.com, edva...@gmail.com
On 2/28/2019 6:08 PM, Edvani Pascoal wrote:
> hey guys I'm beginner on django I never worked with this framework
> before and then I've problems to started polls app this is the error:
>
deleting most of the traceback since in this case it is not relevant.
>   File "/home/edvani/django-test/djangoproject/polls/models.py", line 5
>     question_text = models.CharField(max_length=200)
>                 ^
> IndentationError: expected an indented block
>
Here is the head of models.py, as copied from the tutorial

from django.db import models


class Question(models.Model):
    question_text = models.CharField(max_length=200)

Your copy of that file is different. Statement that end in : must be
followed by at least one indented line. These are known as "compound
statements" (if, elif, else, while, for, try, except, finally, with).

--
Bob Gailer


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Harryxon Ndegwa

unread,
Mar 1, 2019, 5:14:51 AM3/1/19
to django...@googlegroups.com
The problem is with the indentation,the question_text field is wrongly indented.ensure you have a python friendly IDE or text editor

--
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/580f4cd8-1d87-56a0-7548-c20e26e3e446%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Sam W

unread,
Mar 1, 2019, 11:56:29 AM3/1/19
to Django users
The error is very clear "IndentationError: expected an indented block" Use PyCharm IDE OR Visual Studio Code.
Also, never use Keyboard Spacebar for indentation , always use Tab for indentation. TO solve your problem take the question_text to the beginning of the line then hit the Tab once. 

gauravsriv...@gmail.com

unread,
Mar 1, 2019, 12:56:08 PM3/1/19
to Django users
Doing copy-paste always lead to indentation fault.Try to copy the code on any editor and then indent 2nd statement by 4 or 8 space indent .

Julio Cojom

unread,
Mar 1, 2019, 1:00:11 PM3/1/19
to Django users
If you use sublime text, try this, right down corner, it says "Tab size" -> Convert Indentation to Tabs.

Sin título.png

sachin thakur

unread,
Mar 5, 2019, 12:56:09 AM3/5/19
to django...@googlegroups.com
that is just a indentation error look just  back space 
look into the indentation of python you need to understand the coding flow in python and respective framework of python  

Thanks and Kind Regards
====================
Sachin Thakur
about.me/sachin.thakur 
PG Student
Dept. of Computer Applications,
Christ ( Deemed to Be university) Main Campus Bangalore, India
UG (DSCASC under Bangalore University ) Bangalore, India.




sachin thakur

unread,
Mar 5, 2019, 12:59:29 AM3/5/19
to django...@googlegroups.com
that is just a indentation error look just  back space 
look into the indentation of python you need to understand the coding flow in python and respective framework of python  

Thanks and Kind Regards
====================
Sachin Thakur
about.me/sachin.thakur 
PG Student
Dept. of Computer Applications,
Christ ( Deemed to Be university) Main Campus Bangalore, India
UG (DSCASC under Bangalore University ) Bangalore, India.




On Fri, Mar 1, 2019 at 5:36 AM bob gailer <bga...@gmail.com> wrote:

Ranganath Kulkarni

unread,
Mar 7, 2019, 8:39:24 AM3/7/19
to Django users
Always use editors like pycharm which will take care of indentation if not it will complain syntax errors if there are any in your program.
Reply all
Reply to author
Forward
0 new messages