How to consume DJango Rest Api with DJango?

37 views
Skip to first unread message

Stalin Vladimir Gomez Gutierrez

unread,
Sep 30, 2020, 7:40:42 PM9/30/20
to Django users
I am trying to consume a django api with django itself. Should I use class generic
views or normal views. Do you know what is the best approach?

Right now, to list items I am using TemplateView 

class RegionListView(TemplateView):
    template_name = 'region/list.html'

    def get(self,request):
        r = requests.get('http://127.0.0.1:8081/regions')
        regions = r.json()
        region_list = {'regions':regions}
        return render(request, self.template_name, region_list)

I need help to implement create and update views to use my api methods. Do you guys have any idea? 

Arpana Mehta

unread,
Oct 4, 2020, 4:17:20 PM10/4/20
to django...@googlegroups.com
You can googlle about `mixin` classes in Django 

CreateUpdateRetrieve mixins class along with your template or API view. 

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03abb212-8408-4fd7-8c5f-b78e9402bf38n%40googlegroups.com.

Dvs Khamele

unread,
Oct 11, 2020, 1:27:17 PM10/11/20
to django...@googlegroups.com, stanle...@gmail.com
Hi do you hire contract based python/django freelancer?
We can help you in this and related techincal tasks at fair prices. Reply or send email to div...@pythonmate.com
Best Regards, 
Divyesh Khamele,
Pythonmate


--
Reply all
Reply to author
Forward
0 new messages