I posted previously about how it seemed to me that, while the
permalink decorator is useful in decoupling the get_absolute_url()
methods of an application's models from the site/project, it more or
less forces you to create dummy custom views where you would normally
simply use generic views. Here's what I find myself doing repeatedly:
In models.py:
from django.db.models import permalink
import views
class Item(models.Model):
...
def get_absolute_url(self):
return (views.item_detail, (str(self.id),))
get_absolute_url = permalink(get_absolute_url)
----
In urls.py (included in project URLconf):
from django.conf.urls.defaults import *
from views import *
urlpatterns = patterns('',
(r'^item/(?P<object_id>\d+)/$', item_detail),
)
----
In views.py:
from django.views.generic.list_detail import object_detail,
object_list
import models
def item_detail(request, object_id=None):
return object_detail(request, queryset=models.Item.objects.all(),
object_id=object_id)
----
Am I missing something?
Thanks,
David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---