简体   繁体   中英

styling django forms using reactjs

I learnt about django-forms, and I wanna create a form which looks nice, styling with css and bootstrap and html. but I found that out that I can't do it clean (like creating separate css sheet for styling) and I have to do it through python code which is doesn't look good. is there any way to do this? if I try to handle the whole frontend, do I still need to set some styles through python in backend including django forms? I'm sorry if it is a dumb question but I'm new to reactjs(actually I didn't learn it yet) and I have just a little experience in django.

Why do you need to do this through Python code and who says that you can't create separate CSS style sheets?

Just use a template which is then loaded in Django. Within the template you can take each and every input field from your forms.py and show it separately by adding

{{ form.first_field }}

for example. If you want to learn more on this read the documentation here .

Separate CSS sheets, you can just include in the head of the HTML template.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM