I want pass model name as parameter to views.py
But it does not woork very well
Please guide me how to do this Thank you
when I go to http://127.0.0.1:8000/filter/image/party/
There is error said :
'unicode' object has no attribute 'objects'
but the terminal can print mm='Party'
Here is my code:
models.py:
class Party(models.Model):
....
class Fun(models.Model):
....
urls.py:
urlpatterns = patterns('',
url(r'^image/(?P<model>\w+)/$', views.object_list_1 ),
views.py:
def object_list_1(request, model):
mm = model.capitalize()
obj_list = mm.objects.all()
template_name = 'filterimgs/%s_list.html' % mm.lower()
return render_to_response(template_name, {'object_list': obj_list,
context_instance=RequestContext(request))