WebFaction
Community site: login faq

I'm new to Django so I was running through the tutorial for creating the Poll app and things went great in part 1. But when I got to part two where you enable the Poll app in the administration interface I started to get Internal Server Errors. I eventually figured out that in ~/webapps/<app_name>/myproject/polls/admin.py I needed to have:

from myproject.polls.model import Poll

But in the tutorial it was just:

from polls.model import Poll

I also had to specify in myproject/settings.py 'myproject.polls' as an entry in INSTALLED_APPS. Not sure if this is a problem but in the tutorial they only included 'polls' as an installed app.

I thought that the apps should be decoupled from the projects so specifying the project name in the import statement would be bad. Is there something that I'm missing here? Should I be including a path somewhere in the apache config?

Please pardon my noobishness and thanks in advance for any feedback you give.

asked 04 Mar '11, 17:45

SwitchBlade
525
accept rate: 0%


Hi,

This is because of the way your PYTHONPATH is setup. If you look in the apache2/conf/httpd.conf for your application you'll see that the python-path= is set to include: /home/username/webapps/djangoappname and the server's Python installation. So you have to specify myproject.polls so that Python can import the full path. If you modify that variable to go further, to say, /home/username/webapps/djangoappname:/home/username/webapps/djangoappname/myproject and restart your apache then you won't have to use the myproject.polls in INSTALLED_APPS because the PYTHONPATH will know where polls is.

Hope that helps!

permanent link

answered 04 Mar '11, 18:18

klynton
1.6k1210
accept rate: 41%

can't upvote, but this helped.

(19 Jun '11, 15:15) thedoors

Thanks to both of you for helping me out.

Regarding setting python-path, my testing shows that the project path should be added to WSGIPythonPath rather than python-path.

permanent link

answered 16 Mar '11, 12:57

mindchasers
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909

question asked: 04 Mar '11, 17:45

question was seen: 5,400 times

last updated: 19 Jun '11, 15:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM