Django NoReverseMatch not a valid view function -
django 1.11
i keep getting noreversematch error reverse 'menu_menuitem' not found. 'menu_menuitem' not valid view function or battern name
views.py
from .models import category, menuitem def show_category(request, category_slug): c = get_object_or_404(category, slug=category_slug) menuitems = c.menuitem_set.all()\ template_name='category.html' context = { 'c':c, 'menuitems':menuitems, } return render(request, template_name, context) def show_menuitem(request, menuitem_slug): = get_object_or_404(menuitem, slug=menuitem_slug) categories = i.categories.filter(is_active=true) template_name="menuitem.html" context = { 'i':i, } return render(request, template_name, context)
models.py
class category(models.model): name = models.charfield(max_length=50) slug = models.slugfield(max_length=50, unique=true, help_text='unique value category page url, created name.', blank=true, null=true) @models.permalink def get_absolute_url(self): return ('menu_category', (), { 'category_slug': self.slug }) class menuitem(models.model): name = models.charfield(max_length=250, blank=false, unique=true) slug = models.slugfield(max_length=250, unique=true, help_text='unique value menuitem page url, created name.', blank=true, null=true) categories = models.manytomanyfield(category) @models.permalink def get_absolute_url(self): return ('menu_menuitem', (), { 'menuitem_slug': self.slug })
for category
model
@models.permalink def get_absolute_url(self): return ('show_category', (), { 'category_slug': self.slug })
for menuitem
model
@models.permalink def get_absolute_url(self): return ('show_menuitem', (), { 'menuitem_slug': self.slug })
Comments
Post a Comment