Forums

Unhandled Exception when launching admin panel

Hi i am new to python and django. I started an new project while following starting tutorial. Everything was perfect until i tried to launch admin panel.

I uncommented in settings.py line: 'django.contrib.admin',

run python manage.py syncdb. for now everything was good. But when i uncomment specyfied lines in urls.py, update project, and try to visit: http://projectname.pythonanywhere.com/admin/

i got simply "Unhandled Exception". Unfortunetly main page also returns this error.

What did i wrong? Please help me with this. Thanks. John

Have a look in your error log to see what exception is being thrown.

Hello, thanks for Your reply. I've checked error log. Last error i've got is:

"django.template.base.TemplateSyntaxError: Caught ImportError while rendering: No module named news"

Can I take a look at your files? That might make this easier to diagnose. There's no need to do anything to give me permission beyond just posting here and saying it's OK.

Sure it's ok. There is just test app.

OK, so looking at your WSGI file, you have /home/aiir on your Python load path, but the module news is in /home/aiir/POVRay.

You're importing your settings file as POVRay.settings, so the system path is correct for that. But if you want to be able to import your module, you'll need to do one of two things:

  • My recommended action -- import it as POVRay.news instead of just as news
  • A less-good solution that might lead to confusion down the line but means you only need to make one change: add /home/aiir/POVRay to the system path in the WSGI file as well as /home/aiir/.

After making one of those changes, reload the web app, and it should work.

Thats great. It works. Thank You for Your explanations and Your time. :)

Great! Out of interest, which of the two options did you choose?

I choose first one. But when i done it i got another error. One more change was required in file news/admin.py there is import:

from news.models import *

I had to change it to:

from POVRay.news.models import *

I assume that everytime I import my own modules i need use POVRay.module_name.

Thanks a lot, one more time.

John.

Great, I'm glad you chose that option :-)

Yes, you're right -- you need to put POVRay at the start of your imports too. Sorry I didn't make that clear.