Skip to content
Advertisement

Tag: django-urls

type object ‘PizzaMenu’ has no attribute ‘_default_manager’

I have following error while i try to reach PizzaDetailView on template: AttributeError at /pizza/6/ type object ‘PizzaMenu’ has no attribute ‘_default_manager’. Where is the problem? models.py views.py urls.py Answer Don’t name your view PizzaMenu, it will override the reference to the PizzaMenu for the other views. Usually class-based views have a …View suffix, so:

How to add an url field to a serializer with Django Rest Framework

I am following the tutorial on Django Rest Framework – Tutorial 3 Class based views. How to add an url field (pointing to the current snippet) to a serializer? serializers.py urls.py Actual output Desired output Answer You have to use HyperlinkedModelSerializer serializer and HyperlinkedIdentityField field From Django Rest Framework documentation The HyperlinkedModelSerializer class is similar to the ModelSerializer class except

Advertisement