-
Notifications
You must be signed in to change notification settings - Fork 77
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
Leverage Django REST Framework #11
Comments
This is true, and it's something I have considered. DRF just reached version 3.0 and the serializers have been worked over quite a bit, The SD serializers are quite different from DRFs serializers as well. That's not to say that one could not extend the DRF serializers, but there would be functions in the serializer that would never be used or possible have a breaking effect. This is not the first time this is mentioned however, so I see that it's something that would possibly be desired by the dev community, so I'm not knocking the idea, There is a lot more than just the serializers that have to be rewritten for this to work. |
Closed? |
The serializers are too different at the moment. I might open a new issue to implement the DRF serializer but this wasn't really an issue, more of a question so I'm closing this for now |
The DRF serializers does a lot that SD doesn't need or do. The way it handles foreign key relationships are way different etc. There is no depth option in SD etc. etc. LikeI said, I'm not knocking the idea of implementing them, but it becomes a dependency. Most people would probably be okay with being tied to a version of EDIT: If someone wants to create a pull request for this I will of course review it. |
You should loop in @tomchristie but I think now that DRF is on v3, the API for Serializers should be relatively stable. |
It would be nice if DRF serializers could be used. I think a solution where the existing serializers and DRF serializers can both work would be ideal. If I rewrote the way serializers are handled this could be a possibility (even go as far as making serializers swappable). Whatever solution I (or someone else) come up with, should not create a direct dependency on DRF 3.x I am considering this though. |
More than happy to help out with any questions if helpful. I wouldn't be too concerned about tying yourself to API stability with REST framework - the 3.0 upgrade was something of an exception - for medium point releases (ie 3.x - which is what we'll be having for the foreseeable future) we have a strong deprecation policy that's essentially in line with what Django does. http://www.django-rest-framework.org/topics/release-notes/#deprecation-policy Also I can't see the serializers changing substantially at this point. |
This might be doable with an adapter between the serializers and some work done to the current SD serializer to fit all this in. I will ponder this over the weekend. |
+1! |
Quick update on this: I've been poking at this for a bit now and the serializers are very different indeed, and this is going to be quite an arduous task. At this point I'm more inclined to rewrite both the serializers and route handlers which is not going to be a small task. The DRF serializers are (of course) not aware of the data maps. What this actually means: The data map contains information on how objects should be mapped.
If you have a serializer for This doesn't only affect the route handler but the self publishing models as well. In short: I'm happy to do this, but the work it involves is not tiny so it's going to take quite some time to do this (fitting this around haivng a baby and my day job). |
This is now available in the 0.4.3 branch (it's experimental at the moment) |
Was waiting for this update!!!!.Really excited to test it out |
+1! |
If anyone has tried the 0.4.3 branch I would love some feedback |
I'm trying to do the first tutorial using DRF. And after something a little more complex. I've got serializers.py
And models.py
And I got
I don't know how to resolve this issue. |
@sylflo Please create a new issue. Solution:Use a string of the model name in the metaclass of the serializer instead of importing the actual model. |
Would it be possible to define multiple serializers for one model class?
|
You can create several serializers for one model but you can not have multiple serializers on a selfpublish model. However I am currently unsure of the future of the self publishing model. People don't seem to be able to use it properly and get upset when it's either creating too many queries or not enough information so at the time of writing this I would say don't use the self publish model and let the routers handle the publishing Also, this doesn't really have anything to do with the DRF serializers so let's not continue this conversation here. |
@jonashagstedt Thanks for the quick answer. I'll try the tutorial and will be back to you asap. |
@jonashagstedt do you have any updates on this? I am myself a strong DRF user and just stumbled across your project (it looks awesome btw) but would like to avoid having to write another set of serializers. |
@jsenecal You could try the 0.4.3 branch. |
Given this description:
why not use Django REST Framework (DRF)'s serializers rather than re-inventing the wheel? Code here and description here and here. Perhaps use the renderers? They seem to solve the exact goal that you outlined.
I know you mentioned that you did not use them here: https://news.ycombinator.com/item?id=8676967:
but you don't address the reason why.
The text was updated successfully, but these errors were encountered: