Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm a little lost with the documentation #60

Open
FootyNetwork opened this issue Dec 17, 2019 · 2 comments
Open

I'm a little lost with the documentation #60

FootyNetwork opened this issue Dec 17, 2019 · 2 comments
Labels

Comments

@FootyNetwork
Copy link

FootyNetwork commented Dec 17, 2019

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.

@shosca
Copy link
Owner

shosca commented Dec 17, 2019

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.

@FootyNetwork
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants