Django forms in ReactJs

0 votes
Is there any way I can use Django forms inside a ReactJS script, like include {{ form }} in the JSX file?

I have a view which displays a form and it is rendered using React. When I load this page from one page the data in these fields should be empty, but when I hit this view from another page I want the date to be prefilled in this form. I know how to do this using Django forms and form views, but I am clueless where to bring in React.
Apr 30 in Python by ana1504.k
• 5,990 points
10 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
The {{ form }} statement is relative to Django template. Django templates responsible for rendering HTML and so do React, so you don't have to mix the two together.

What you probably want to do is to use the django form validation mechanism server side, et let React render the form client side. In your django view, simply return a json object that you can use in your React code to initialize your form component.
answered Apr 30 by SDeb
• 9,540 points

Related Questions In Python

0 votes
1 answer

How should I write tests for Forms in Django with Python?

from django.tests import TestCase class MyTests(TestCase): ...READ MORE

answered Nov 20, 2018 in Python by Nymeria
• 3,500 points
16 views
0 votes
1 answer

How to switch pages using Ajax in Django?

You should use django-pjax which is built exactly for ...READ MORE

answered Oct 9, 2018 in Python by ariaholic
• 7,320 points
67 views
0 votes
1 answer

How to get all related Django model objects in Python?

This actually gives you the property names ...READ MORE

answered Nov 14, 2018 in Python by Nymeria
• 3,500 points

edited Dec 18, 2018 by Nymeria 254 views
0 votes
1 answer

How to run django unit-tests on production database in Python?

In case someone googles here searching for ...READ MORE

answered Nov 28, 2018 in Python by Nymeria
• 3,500 points
25 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
0 votes
1 answer

How to generate urls in django?

If you need to use something similar ...READ MORE

answered Apr 12 in Python by SDeb
• 9,540 points
8 views
0 votes
1 answer

Django session doesn't work in Firefox

You can try this: request.session.modified = True I hope ...READ MORE

answered May 6 in Python by SDeb
• 9,540 points
7 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.