Forums

Django 1.6 "Unhandled Exception" with admin.py

Hello PythonAnywherers !

I just create a Django 1.6 app and start follow the tutorial at https://docs.djangoproject.com/en/1.6/intro/tutorial01/ But I have a problem when creating the admin.py in one of my app (following the tutorial 'polls'). When I use :

` from django.contrib import admin

from polls.models import Poll

admin.site.register(Poll) `

This is for inject my database table in the interface of the django admin. All is working if i delete the content of admin.py but i need it to modify the content of the table...

Hope you can help me,

What do you see in your error log?

My log is here https://www.pythonanywhere.com/user/Mikescops/files/var/log/mikescops.pythonanywhere.com.error.log , each time it's a big issue but I can't understand it.

You have an indentation error on line 4 of your admin.py file:

2014-02-24 14:09:14,419 :  File "/home/Mikescops/gamequest/gamequest/polls/admin.py", line 4
2014-02-24 14:09:14,419 :    admin.site.register(Poll)
2014-02-24 14:09:14,419 :    ^
2014-02-24 14:09:14,419 :IndentationError: unexpected indent

Well I'll modify this when i'll come back home. But the indent was a try.

Have you access to my account if I can't solve the problem ?

I could, but then you wouldn't learn anything. Fix the indentation, reload the web app, hit the page and then have a look at the error log to see what the original problem was. If you like, you can drop the exception trace here and I can help you out.

So I delete the indent, clear the log, reload app and refresh page. Get again an error. The log is not very relevant, but i think it's a wrong path or something like that.

This lines seams to be important :`

2014-02-24 16:50:10,226 : File "/home/Mikescops/gamequest/gamequest/polls/admin.py", line 2, in <module> 2014-02-24 16:50:10,227 : from polls.models import Poll, Choice 2014-02-24 16:50:10,227 :ImportError: No module named 'polls'

But in fact there is a module polls...

OOOOHHHHH YES KISS KISS KISS KISS

It was because we use a different path like i say in my 4th post !

I had to use : from gamequest.polls.models import Poll, Choice

And not : from polls.models import Poll, Choice

So I'll hope this will help for making the 1.6 documentation :-) Thank you Glenn, hope my project i'll tell you by email will work fine !

Excellent! Glad to hear it.