Wednesday, July 20, 2022

Re: DRF question

There's no reason at all that DRF can't be used to do this. Just don't use a viewset, as it's not the right fit for this type of thing.
Read through the code for how your current system works, then re-implement the relevant parts as DRF ApiView's.

On Thu, Jul 21, 2022 at 8:43 AM Ram <ram.mullapudi@gmail.com> wrote:
Thank you all for quick suggestions. 

We are stuck with implementing the first API, which is login endpoint. That means since we already developed user registration functionality before without DRF, there seems no way to create a login endpoint so that an existing registered user can login using REST API and access his/her respective data . All we are finding on the web is to create an Abstract user using DRF which requires to change the existing user registration implementation. So I'm wondering whether there is any way to remedify this or are we missing something?

Best regards,
~Ram



On Tue, Jul 19, 2022 at 6:30 PM Hella thor <hellathorchmod777@gmail.com> wrote:
Hi Ram
您可以在原来项目的基础上创建新的APP来单独给移动应用程序来使用,并在整体项目完成以后研究是不是需要DRF来兼容。

Lalit Suthar <sutharlalit.97@gmail.com> 于2022年7月19日周二 19:04写道:
I would also suggest keeping Django views as it is and writing new views for your APIs 
maybe you can create another file named apiviews.py and then write new APIs with help of your present views

On Tue, 19 Jul 2022 at 06:38, Nikhil Chawla <nikhilchawla39@gmail.com> wrote:
Don't clutter the django views with DRF requests. Keep them separate, available at, say `api` endpoints.

On Tue, 19 Jul 2022, 06:17 Michael Thomas, <michael.thomas.sw20@gmail.com> wrote:
Hey Ram,

I'm afraid no one can answer your questions without knowing your code, how it works, or anything else...

Broadly speaking, here's how we approached a similar scenario:

1) Created one or more Serializer for each model that required interaction via API. Some models required more than one, as they were either too large for list() operations, or required a simpler representation when nested into another Serializer, etc..
2) Created custom permissions to check if users were allowed to perform the action(s) they were trying to make
3) Created ViewSets using the permissions and serializers mentioned above, as well as any additional actions that didn't fit within the normal REST verbs
4) Created a router and registered the viewsets with it
5) Added the router's urls into the projects url configuration

I hope that's useful :)

Kind Regards,
Michael Thomas  

On Tue, Jul 19, 2022 at 7:21 AM Ram <ram.mullapudi@gmail.com> wrote:
Hi,

We completed coding all the features without DRF for our web site and now we are planning to develop a mobile app for the same website by keeping the web site as it is and develop a mobile app using Flutter. 

Based on our understanding, we have do the following in the current code for adding REST APIs

  1. We have to create serializers.py for each model in each App that we have
  2. We need to add a few lines of code in views.py
  3. We think we don't have to modify the UI template by using json response from DRF ( Is this really necessary because we are not changing anything in the website UI)
Please correct me if I'm wrong about the above 3 points or do we need to do any additional things?

Best regards,
~Ram

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BOi5F2wgTLXQFreQp9cXNGBOnTqoAQ6vA5CqZuBNeya%2BWKLXg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEdx1fo_Zk7H7nFMgUSYkfTC_p_cV8Qa8W17C_GHnDDwdk2eBw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEO4UakHjqtO3S-DZ-9A_-C7ZMoEBiNxtGm1eGL-R1cp9Ofutw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGp2JVHC8SFuiJ7g7pnb4xEZz70O1-auE%3DUr0NGGG4AamJNUzw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAE1PWx3JROqX%2BDpENmX0R%2BA07nxG5oJMiFkeU42hT3TdMiGHw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BOi5F2OgvzwD-C6xwW%2BWqCjmczUq-5Trh%2B_X3w_2xOsc7ErFA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEdx1friDunL_FEabFjVg0J72JzL5fnBXgA2giHEbJuSawVm0A%40mail.gmail.com.

No comments:

Post a Comment