Is it possible to use REST API on Django template ?

閲覧: 922 回
最初の未読メッセージにスキップ

Aman Modi

未読、
2020/11/25 9:19:582020/11/25
To: Django users


Hello Django lovers.

I want to use REST API  on Django template but i have no idea how can i do that.
I want to use same API on android app and Django template.

Any suggestion .

Thanks and regard
Aman Modi

Omkar Parab

未読、
2020/11/25 9:37:472020/11/25
To: django...@googlegroups.com
Creating REST API in Django is similar to any app on Django. All you need to do is, install the djangorestframework library, and serialize your models. 

On Wed, Nov 25, 2020, 7:48 PM Aman Modi <amanmo...@gmail.com> wrote:


Hello Django lovers.

I want to use REST API  on the Django template but I have no idea how can I do that.
I want to use the same API on the android app and the Django template.

Any suggestion.

Thanks and regard
Aman Modi

--
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/99c6d921-9ea7-4f3b-9d69-03b06fbbd5d8n%40googlegroups.com.

Devender Kumar

未読、
2020/11/25 10:50:532020/11/25
To: django...@googlegroups.com
Use ajax with django rest framework 

Farai M

未読、
2020/11/25 11:21:562020/11/25
To: django...@googlegroups.com
Very possible you can create urls for API with the rest framework then create other  urls for your templates .Just install the django rest framework you are good to go.

Kris A. Stern

未読、
2020/11/25 11:48:292020/11/25
To: django...@googlegroups.com

Venu Gopal

未読、
2020/11/26 23:04:272020/11/26
To: django...@googlegroups.com
Yes, it is possible. Below is the documentation. we will use serialization to get a django rest API.

Aman Modi

未読、
2020/11/29 1:25:352020/11/29
To: Django users
I know how to create API but i just want to know how to use in Django template.

RANGA BHARATH JINKA

未読、
2020/11/29 2:06:442020/11/29
To: django...@googlegroups.com
Hi 
Use JavaScript or jQuery to call APIs in frontend of Django template.
You can use fetch API using vanilla JavaScript.
You can perform all CRUD operations.
All the best 👍

sree e

未読、
2020/11/29 12:30:332020/11/29
To: Django users

Hi 
And go through "api" app , where you will find adding the api in easy way.

Liu Zheng

未読、
2020/11/30 21:04:442020/11/30
To: django...@googlegroups.com
Hi,

Guys earlier have provided useful links for consuming APIs. Just want to emphasize some concepts between server-side and client-side codes.
A django template is rendered into a page on the server side. That means, the server does the work and prepares the html content before sending it to the browser. In theory, you can call APIs when rendering the templates on the server side, but it's almost never a good idea. APIs are designed to be consumed by clients. The django templates should contain the relevant  javascripts (using ajax). These javascripts are not executed when the server renders the templates. They are sent as they are to the client, and are executed automatically by the browser. If the javascript calls API, the browser will come back to your server (this time, to the rest api endpoints, instead of the template rendering endpoints) and consume your API.

Hope it helps.

Best
Zheng

Kris A. Stern

未読、
2020/11/30 21:09:412020/11/30
To: django...@googlegroups.com
Hey, 

Guess you are making some baseless assumptions about the so-called templates... Can the original poster of the question please clarify what you really meant before we get more and more confused? 

K.S. 

Suhaib Ali

未読、
2020/12/03 3:37:242020/12/03
To: django...@googlegroups.com
you can use jquery to fetch api calls 

全員に返信
投稿者に返信
転送
新着メール 0 件