views:

652

answers:

2

I've been working with a Django app for a while, and the Django admin interface works great, except that the "View on site" link doesn't work. Whenever I try to use it, I get an OperationalError with the message: no such table: django_site. I've done some research into this problem, and it seems that I have to set up the Django sites framework for this link to work, but I'm exactly sure how to do that. The documentation talks about database tables, etc., but it doesn't tell how to actually set up a site. So my question is really two-fold:

  1. How do I get the sites framework set up? Do I have to create the table myself (and enter the data myself), or is there something I have to enable so ./manage.py syncdc will automagically "detect" that I want the table set up?
  2. Will setting up the sites framework effect me when I'm developing locally (i.e., just running on localhost and not off my actual domain name)? Will I have to add something to settings.py like SITE_ID = 2 if DEBUG else 1, or will manage.py just detect that I'm working on the debug site and not do anything with the sites framework?
+2  A: 

Putting

'django.contrib.sites',

into your INSTALLED_APPS and a following

$ ./manage.py syncdb

may suffice.

When installed, edit the Site instance (e.g. through /admin interface) to reflect your local hostname (e.g. localhost:8000).

The MYYN
That did the trick, although I added two site entries, one for the production site (the "real" domain name), and another for localhost; then, in settings.py, I put SITE_ID = 1 if not DEBUG else 2, where 1 = production, 2 = localhost in the the sites table. That way, the admin site works both locally and on the production server.
mipadi
thanks for the hint, i haven't thought of that yet.
The MYYN
+1  A: 

Define a get_absolute_url on your model. The admin uses that method to figure out how to construct the objects url. See the docs.

Arthur Debert
That alone doesn't do the job (I'd already done that, since I have an RSS feed).
mipadi