django-rest-witchcraft icon indicating copy to clipboard operation
django-rest-witchcraft copied to clipboard

I'm a little lost with the documentation

Open FootyNetwork opened this issue 5 years ago • 2 comments

Hi all,

I'm struggling to understand the workflow of the documentation.

  1. Is the first model example the models.py models, or is that inside serializers.py?
  2. Do I import that model into the serializer?
  3. Do I import rest_framework serializers or the witchcraft serializers in serializers.py?

I am struggling to just get to a point where I can setup a simple model and reflect that in django-rest-framework in sqlalchemy format.

Would someone mind please providing a general overview of the steps needed to use this module?

Thank you for your time.

FootyNetwork avatar Dec 17 '19 10:12 FootyNetwork

Is the first model example the models.py models, or is that inside serializers.py?

In the quick start, the first section is declaring models in pure sqlalchemy. In a typical django app these would be in models.py

Do I import that model into the serializer?

See UserSerializer.Meta.model in the quick start. This serializer inherits from rest_witchcraft.serializers.ModelSerializer

Do I import rest_framework serializers or the witchcraft serializers in serializers.py?

Yes, since the models are sqlalchemy models, you need to use a serializer that knows what to do with a sqlalchemy model

Would someone mind please providing a general overview of the steps needed to use this module?

This will depend on the api that you'll build but assuming you already have the sqlalchemy models setup roughly you'll need to build the serializer, then the viewset, then a router to register your viewset and generate url patterns and then include the url patterns in your project.

shosca avatar Dec 17 '19 13:12 shosca

Thank you @shosca, I am now able to get this going with a little help from your answer and #48

One last question if you wouldn't mind answering: How do I handle serializing nested fields that are a relational to another database table?

FootyNetwork avatar Dec 18 '19 14:12 FootyNetwork