#5652: Startforward use of startproject command results in broken "Show on Site"
link in admin
----------------------------------------------+-----------------------------
Reporter:  Leo Hourvitz <[EMAIL PROTECTED]>  |       Owner:  nobody         
  Status:  new                                |   Component:  django-admin.py
 Version:  SVN                                |    Keywords:  SITE_ID        
   Stage:  Unreviewed                         |   Has_patch:  0              
----------------------------------------------+-----------------------------
 If you use startproject in the straightforward way (such as following the
 Django tutorial), and if you as suggested implement get_absolute_url()
 methods in your models, you will indeed get "Show on Site" links in your
 admin interface.  Unfortunately, they'll be broken because they will
 redirect to example.com.

 This is because the sites app is required, and thus activated; and it
 installs a default piece of SQL code that lists example.com as the URL for
 the project.

 Obviously, one possible fix is to document an additional step everyone has
 to do (go into their db interface and edit the sites table) to set up any
 straightforward app, however there are two downsides to that:  the first
 one is it makes the tutorial more complex.  However, the stronger reason
 is that it introduces an absolute URL when a relative URL would generally
 be a better choice anyway (for instance, my Django apps have different
 hosts when running under test versus in deployment; that's why a relative
 URL is the better solution in most cases).

 Fortunately, there's a simpler fix that seems to work just fine.  Right
 now the settings.py file installed by startproject sets SITE_ID to 1.  Per
 some earlier changelists, having this value set is required; but it's not
 required to set it to a valid site_id.  If this setting is changed to any
 value that doesn't exist, the code in management handles the situation
 perfectly, and reverts to using the relative URL provided by the model's
 get_absolute_url method (almost certainly what everyone wants until/unless
 they're actually taking advantage of the sites application).  Thus, the
 suggested fix is, in django/conf/settings.py, change the current
 uncommented line:

 SITE_ID = 1

 to something like:

 # Right now, this is set to an invalid ID to show you're not using the
 sites app.
 SITE_ID = -1


 Obviously not the most important bug in the world, but it's good to get
 all the little stumbling blocks out of the way of new users whenever we
 can!

 Leo

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5652>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to