2011/8/23 Yaşar Arabacı <[email protected]>:
> Hi,
> If a use url template tag on a generic view, does urls.py supply required
> arguments? For example:
> urlpatterns = patterns('django.views.generic.date_based',
> (r'^arsiv/(?P<year>\d{4})/$','archive_year',{
> 'template_name' : 'blog/yillar.html',
> 'date_field' : 'pub_date',
> 'queryset' : Post.objects.filter(yayinlandi=True),
> 'extra_context' : common_data,
> 'make_object_list' : True,
> 'template_object_name' : 'makale'
> }),
> )
> Can I access this url with {% url
> django.views.generic.date_based.archive_index asdfasdf.year %}
No, that information is associated with the URL, not the view that
serves the URL. If you gave the URL a name in urls.py, then you could
use that name to refer to the view + attached extra info.
> And also, I am using rss framework like this:
> from feeds import LatestPosts, TagFeed
> urlpatterns += patterns('',
> (r'^rss/$', LatestPosts()),
> (r'^tag/(?P<tag>[^/]+)/rss/$', TagFeed()),
> )
> Can I access this via url template tag?
If you give them names. To give them names, either define a 4-tuple of
(regular expression, view function, optional dictionary, optional
name), or use the url() shortcut and pass name as a keyword argument.
See:
https://docs.djangoproject.com/en/1.3/topics/http/urls/#patterns
Cheers
Tom
--
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.