Sunday, June 13, 2010

Problem with Django admin

i am using  Django Version: 1.2.1
I follow this Tutorial  http://docs.djangoproject.com/en/1.2/intro/tutorial01/
and
Edit the polls/models.py  file so it looks like this:

class Poll(models.Model):
    # ...
    def __unicode__(self):
        return self.question

class Choice(models.Model):
    # ...
    def __unicode__(self):
        return self.choice

After doing that  i run this command :

python manage.py shell

this error is come
Validating models...
Unhandled exception in thread started by <function inner_run at
0x9c574fc>
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 245, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
validation.py", line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
loading.py", line 146, in get_app_errors
    self._populate()
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
loading.py", line 61, in _populate
    self.load_app(app_name, True)
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
importlib.py", line 35, in import_module
    __import__(name)
  File "/home/jagdeep/mysite/../mysite/polls/models.py", line 19
    def __unicode__(self):
                         ^
IndentationError: unindent does not match any outer indentation level

I submit my problem on :-
django-users+noreply@googlegroups.com 
.
then the Django user  reply back and problem solved
I Check my indentation of that particular line, and all of the lines
above. In Python, indentation matters, and it all needs to line up
accordingly.

Now my django admin is work.

No comments:

Post a Comment