This example should help you: http://docs.djangoproject.com/en/dev/topics/class-based-views/#dynamic-filtering
``self.args`` and ``self.kwargs`` contain the groups matched in the URL, so I guess you want to use ``self.args[0]`` as your Menu name. One thing I don't understand is, why you sometimes write "Food" and sometimes "MenuItem". Is that the same model ? On 4 December 2010 16:34, Recep KIRMIZI <rkirm...@gmail.com> wrote: > Hi i m trying to use class based views on my project. > I've read the documentation but i couldnt determine it well. > what i'm trying to do is just use simple list of items of selected menu. > i have 2 classes on my model. Menu and MenuItem. Menu corresponds of > food menu types of a cafe; like "wine menu" "beef menu" ... and MenuItem > is sub item of menus. like in "Wıne menu": "red wine" or "white wine" or > some other kind of wine. but i couldnt get the list of items in the > menu.here is my models views urls and template. > > ---------------------------------------------------- > models: > ---------------------------------------------------- > #!/usr/bin/env python > #-*- coding: utf-8 -*- > > from django.db import models > from photologue.models import Photo > > class Menu(models.Model): > """Model that contains the menu information\ > such as wine menu, meat menu, vegetables menu""" > > name = models.CharField(max_length=100, blank=True) > slug = models.SlugField(max_length=100) > description = models.CharField(max_length=200, blank=True) > > def __unicode__(self): > return u'%s' %self.name > > class Food(models.Model): > """Model that contains the foods such as white wine,\ > red wine, grilled meat, cooked meat.""" > > name = models.CharField(max_length=100) > menu = models.ForeignKey(Menu) > price = models.FloatField() > photo = models.ForeignKey(Photo) > > def __unicode__(self) > return u'%s' %self.name > > ---------------------------------------------------- > urls: > ---------------------------------------------------- > > (r'^menu/(\w+)/$', FoodsListView.as_view()), > > ---------------------------------------------------- > views: > ---------------------------------------------------- > #!/usr/bin/env python > #-*- coding: utf-8 -*- > > from menus.models import MenuItem, Menu > from django.shortcuts import render_to_response, get_object_or_404 > from django.views.generic import ListView > > class FoodsListView(ListView): > context_object_name = "foods" > template_name = "menu.html" > model = Food > > def get_queryset(self): > self.menu = Food.objects.filter(menu__iexact=????????????) > return MenuItem.objects.filter(menu=self.menu) > > > ---------------------------------------------------- > template: > ---------------------------------------------------- > % extends "base.html" %} > {% block title %}Menu name{% endblock title %} > {% block extra_head %} > <link rel="stylesheet" href="{{STATIC_URL}}css/menu.css" /> > {% endblock extra_head %} > {% block content %} > {% for food in foods %} > {{food}} > {% endfor %} > {% endblock %} > ---------------------------------------------------- > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Łukasz Rekucki -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.