django-rest-witchcraft
django-rest-witchcraft copied to clipboard
I'm a little lost with the documentation
Hi all,
I'm struggling to understand the workflow of the documentation.
- Is the first model example the
models.py
models, or is that insideserializers.py
? - Do I import that model into the serializer?
- 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.
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.
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?