On Tue, Mar 28, 2006 at 12:19:39PM -0600, Jacob Kaplan-Moss wrote:
> "correct" and just as simple, and each time I've failed.  As far as  
> I'm concerned, if someone can come up with a way to do this that's  
> stupidly simple then I'm all for a change, but at the same time  
> get_absolute_url() is a wart I'm willing to live with.


Just thinking aloud...  

In the model you want to know "what is this object's identifier that
we would use in a url".   That might be just an object ID, a slug,
or maybe yyyy/mm/dd/id or who knows what.  This would be formated
such that it could be used as-is as PART of a URL.  Let's call this method
"get_id_for_url()"  (or whatever you end up calling it)  That seems to be
the appropriate type of data to come from a Model.. i.e. not the entire
absolute URL, but just a portion of the URL that would be used to
identify this Model's object.

Then, in the particular view (not clear, it might be and/or in the
template) you would want to combine some base URL string with the
previous get_id_for_url string to make it into a real url.  To do that
might need just a variable "base_url" (or it could be yet another view
specific method) that changes by the view. 

So in a template you'd have to do
    {{ base_url }}{{ this-object.get_id_for_url }}

In your urls.py and/or view you'd setup a dict to pass the appropriate
value to the template e.g.
   info_dict = {
       'app_label': 'myapp',
       'module_name': 'mymods',
       'base_url': 'mymods',
   }

That would allow me to use the generic views if I sent the 'base_url' correctly,
or you could even have it default to the 'module_name'.  Or I could code
it into my view's code however I wish.

?????

-- 
Glenn

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to