pizzas.api package¶
Submodules¶
pizzas.api.serializers module¶
-
class
pizzas.api.serializers.
AdminOrderSerializer
(*args, **kwargs)[source]¶ Bases:
rest_framework.serializers.ModelSerializer
-
class
Meta
[source]¶ Bases:
object
-
fields
= ('pk', 'payment', 'product', 'name', 'member', 'display_name')¶
-
model
¶ alias of
pizzas.models.Order
-
-
create
(validated_data: Any) → Any[source]¶ We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:
return ExampleModel.objects.create(**validated_data)
If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:
example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance
The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.
-
class
-
class
pizzas.api.serializers.
OrderSerializer
(*args, **kwargs)[source]¶ Bases:
rest_framework.serializers.ModelSerializer
pizzas.api.urls module¶
pizzas.api.viewsets module¶
-
class
pizzas.api.viewsets.
OrderViewset
(**kwargs)[source]¶ Bases:
rest_framework.viewsets.ModelViewSet
-
basename
= None¶
-
description
= None¶
-
detail
= None¶
-
get_object
()[source]¶ Returns the object the view is displaying.
You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.
-
get_queryset
()[source]¶ Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
-
get_serializer_class
()[source]¶ Return the class to use for the serializer. Defaults to using self.serializer_class.
You may want to override this if you need to provide different serializations depending on the incoming request.
(Eg. admins get full serialization, others get basic serialization)
-
name
= None¶
-
permission_classes
= (<class 'rest_framework.permissions.IsAuthenticated'>,)¶
-
queryset
¶
-
suffix
= None¶
-
-
class
pizzas.api.viewsets.
PizzaViewset
(**kwargs)[source]¶ Bases:
rest_framework.viewsets.GenericViewSet
,rest_framework.mixins.ListModelMixin
-
basename
= None¶
-
description
= None¶
-
detail
= None¶
-
name
= None¶
-
permission_classes
= (<class 'rest_framework.permissions.IsAuthenticated'>,)¶
-
queryset
¶
-
serializer_class
¶
-
suffix
= None¶
-