Discussion:
Customized Views for CRUD actions
Alexander Lamas
2018-09-06 02:02:21 UTC
Permalink
Hi all,

Does Django Rest Framework have a customized views for CRUD actions
built-in the framework?

If so, could please send some references or samples on how to do it?

If not, how can I add my own customized views and still using Django Rest
Framework to get the data for me?

Thank you very much!

Regards,
Alex
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-06 10:31:45 UTC
Permalink
that's what the generics and mixins
<http://www.django-rest-framework.org/api-guide/generic-views/> are for
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alexander Lamas
2018-09-07 01:18:10 UTC
Permalink
Hi Jason,

Thank you very much for your reponse.

I'm new with Python and Django, and I don't know much about Django Rest
Framework capabilities and features.
I tried to understand the mixins, I could not find anything that would be
suitable for me.


What I'm trying to achieve is to have a model list, user friendly, not
showing { } "curly brackets". Just data information like the following
sample


Create new

========================================================================
Employee Department Salary
========================================================================
Peter Pan Animation $10.000
Edit | Details | Delete
Bruce Wayne Investment $80.000
Edit | Details | Delete



And the actions at the column on the right, for the CRUD operations/actions.

Is it possible to achieve that just using Django Rest Framework and it's
view or generics or mixins?

Thank you very much.

Regards,
Alex
Post by Alexander Lamas
Hi all,
Does Django Rest Framework have a customized views for CRUD actions
built-in the framework?
If so, could please send some references or samples on how to do it?
If not, how can I add my own customized views and still using Django Rest
Framework to get the data for me?
Thank you very much!
Regards,
Alex
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-07 12:33:28 UTC
Permalink
I think you're mixing pieces, concepts and ideas up due to your
unfamilarity.

django can do exactly what you want to do. but it does it in different
ways, and DRF adds another way to do it. Problem is, you need to separate
out the view layer, the transport format and the presentation layer. View
layer is the code responsible for handling the request and returning the
response. This can be in JSON, HTML, XML, etc. Its up to your
presentation layer to present the response in the form you deem sufficient.

from what it sounds like in your example, you're confusing the transport
format with the presentation layer in DRF. You need to have something in
HTML/JS to *render* the response into something the browser can use. The
JSON data is not meant to be primarily human readable, but to be consumed
by a client and transformed as the dev wants.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alexander Lamas
2018-09-12 00:26:39 UTC
Permalink
Hi Jason,

Thanks for reply and sorry for my late answer.

Yes, I understand what you said.

At the moment I'm trying to create a front end independent of the RESTful
web api, using pure HTML/5, CSS, JavaScript/jQuery and Bootstrap.

My problem is because of the lack of experience with Python and Django,
even more Django Framework, I don't know how things will hang together.

Questions that I have.

1. Should I have a folder for the views of each model?
Example: Employee (model) would have a folder Employee view and inside of
this folder I would have Index (list), Edit, Create, Details, Delete views?

2. How would be the structure of this views?

3. What sort of view should I use? ModelViewSet, ListAPIView,
ListAPICreteView, which one would be better for what I want to achieve?

4. Should I use only one model for all CRUD operations? Or should I create
a view model for each view?

5. One serializer is enough for all CRUD operations?

Would you have any samples to demonstrate how things link together? Any
sample on github by any chance?

Thank you very much for your time mate! Greatly appreciated!

Regards,
Alex
Post by Jason
I think you're mixing pieces, concepts and ideas up due to your
unfamilarity.
django can do exactly what you want to do. but it does it in different
ways, and DRF adds another way to do it. Problem is, you need to separate
out the view layer, the transport format and the presentation layer. View
layer is the code responsible for handling the request and returning the
response. This can be in JSON, HTML, XML, etc. Its up to your
presentation layer to present the response in the form you deem sufficient.
from what it sounds like in your example, you're confusing the transport
format with the presentation layer in DRF. You need to have something in
HTML/JS to *render* the response into something the browser can use. The
JSON data is not meant to be primarily human readable, but to be consumed
by a client and transformed as the dev wants.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...