Adrian Holovaty wrote: > The convention is to put the URL-creation logic in your models, in a > get_absolute_url() method. Here's a quick example: > > class Person(meta.Model): > gender = meta.CharField(maxlength=1) # 'm' or 'f' > full_name = meta.CharField(maxlength=50) > > def get_absolute_url(self): > return '/people/%s/%s/' % (self.gender, > self.full_name.lower().replace(' ', ''))
I find this *really* surprising. All discussions and examples I've seen so far are quite strict about the fact that models should be separate from presentation logic. See the various discussions about "how can my model get access to request.user?" here in this group. These arguments made (make) perfect sense to me. And now you're encoding URLs (which are, in my mind, definitely presentation-related) in the models? To me, this seems strange and unnatural. Why should a "Book" model care wether it has a view that lives under "/library" or under "/amazon/shoppingcart" or under "/thingtostopthetablefromwobbling" ? It's a book. It has properties. It knows how to tell me its title. But it shouldn't care wether it's being read or being used to prop up furniture. Or am I misunderstanding something here? Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---