Q:

Django: Model parameter in the URL template tag

I want to use the url template tag for my generic view.
I have been searching a lot about this and I didn't find what I want, but it seems a simple issue.
I will use the example that the Django book, Making a View Generic, has used:
# urls.py

from django.conf.urls.defaults import *
from mysite import models, views

urlpatterns = patterns('',
    (r'^events/$', views.object_list, {'model': models.Event}),
    (r'^blog/entries/$', views.object_list, {'model': models.BlogEntry}),
)

# views.py

from django.shortcuts import render

def object_list(request, model):
    obj_list = model.objects.all()
    template_name = 'mysite/%s_list.html' % model.__name__.lower()
    return render(request, template_name, {'object_list': obj_list})

So, I have one view for two URLs, my question is: How can I use the django URL template tag for this two URLs?
I want to do something like this in the html template:
href={% url "mysite.views.object_list" model="Event" %}
href={% url "mysite.views.object_list" model="BlogEntry" %}

Thanks!

A:

You need to define name for the url:
(r'^events/$', views.object_list, {'model': models.Event}, name='my_name'),

and use it instead of the view path:
href={% url "my_name" model="Event" %}

