Regarding Django forms

79 views
Skip to first unread message

Nishant Sagar

unread,
Sep 23, 2022, 1:56:59 AM9/23/22
to django-d...@googlegroups.com, django...@googlegroups.com
Hey forks, 

I’m in little dilemma regarding Django forms. I'm working on a project as a backend guy who doesn't know much about CSS and JavaScript so a frontend guy delivered me a form template designed using CSS, however, Django documentation suggests that it's good practice to use Django forms.

So how feasible do you think it is for a frontend guy to learn Django widgets from scratch to implement the same thing he can easily do from CSS and JS. As a newbie backend guy, it's not easy for me either to learn frontend tech to implement the same thing in so little time.

So I tried implementing the form without using Django forms but I find it hard to deal with files as there is no documentation I can look up to.

So can we add these to the documentation or it is still advisable to use Django forms?


Thanks and regards,
Nishant 

siyamak abasnezhad

unread,
Sep 23, 2022, 9:50:13 AM9/23/22
to django-d...@googlegroups.com
You can use widget Tweeks or crispy 


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CANNtL-Kqud7V6sk_%3DYnagzATw8eJjO9pCeDx9Za80XywXBi2tQ%40mail.gmail.com.

Nishant Sagar

unread,
Sep 23, 2022, 10:06:58 AM9/23/22
to django-d...@googlegroups.com
That's the whole point. I've attached my form.html file, do you think it's a generous idea to design the whole form page using widgets if I already have the form template ready?

<div class="main">
<div class="container-form">
<div class="signup-content">
<div class="signup-img">
<img src="{% static 'img/form-img-2.jpg' %}" alt="">
</div>
<div class="signup-form">
<form action="form" method="POST" class="register-form" id="register-form">
{% csrf_token %}
<h2>Registration form</h2>
<div class="form-row">
<div class="form-group">
<label for="name">Name of Homeowner :</label>
<input type="text" name="name" id="name" placeholder="Name" required />
</div>
<div class="form-group">
<label for="age">Roof Age :</label>
<input type="number" name="roof_age" id="age" placeholder="Roof Age" required />
</div>
</div>
<div class="form-group">
<label for="email">Email ID :</label>
<input type="email" name="email" id="email" placeholder="Email" required />
</div>
<div class="form-group">
<label for="phone">Phone :</label>
<input type="number" name="phone" id="phone" placeholder="Phone" required />
</div>
<div class="form-group">
<label for="address">Full Home Address :</label>
<input type="text" name="address" id="address" placeholder="Address" required />
</div>
<div class="form-group">
<label for="bill">Average Monthly Electric Bill Costs :</label>
<input type="number" name="monthly_bill" id="bill" placeholder="$" required />
</div>
<div class="form-radio">
<label for="HOA" class="radio-label">Do you have HOA?</label>
<div class="form-radio-item">
<input type="radio" name="HOA" id="HOA_YES" >
<label for="HOA_YES">Yes</label>
<span class="check"></span>
</div>
<div class="form-radio-item">
<input type="radio" name="HOA" id="HOA_NO" >
<label for="HOA_NO">No</label>
<span class="check"></span>
</div>
</div>
<div class="form-radio">
<label for="battery" class="radio-label">Would you also need a battery? </label>
<div class="form-radio-item">
<input type="radio" name="battery" id="Battery_YES" >
<label for="Battery_YES">Yes</label>
<span class="check"></span>
</div>
<div class="form-radio-item">
<input type="radio" name="battery" id="Battery_NO">
<label for="Battery_NO">No</label>
<span class="check"></span>
</div>
</div>
<div class="form-radio">
<label for="foundation" class="radio-label">Is your home on concrete foundation?</label>
<div class="form-radio-item">
<input type="radio" name="foundation" id="foundation_YES" >
<label for="foundation_YES">Yes</label>
<span class="check"></span>
</div>
<div class="form-radio-item">
<input type="radio" name="foundation" id="foundation_NO">
<label for="foundation_NO">No</label>
<span class="check"></span>
</div>
</div>
<div class="form-group">
<label for="course">Roof Type :</label>
<div class="form-select">
<select name="roof_type" id="course">
<option value="">Select here</option>
<option value="Shingle">Comp Shingle</option>
<option value="Concrete">Concrete</option>
<option value="Metal">Metal</option>
<option value="Spanish">Spanish</option>
<option value="Clay">Clay</option>
</select>
<span class="select-icon"><i class="zmdi zmdi-chevron-down"></i></span>
</div>
</div>
<div class="form-group">
<label for="availability">Your Availability :</label>
<input type="datetime-local" name="availability" id="availability" placeholder="Select Time"
required />
</div>
<div class="form-group">
<label for="uplaod">Upload your bill :</label>
<input type="file" name="bill" id="uplaod" required />
</div>
<div class="form-submit">
<input type="reset" value="Reset All" class="submit" name="reset" id="reset" />
<input type="submit" value="Submit Form" class="submit" name="submit" id="submit" />
</div>
</form>
</div>
</div>
</div>

</div>

Nishant Sagar

unread,
Sep 23, 2022, 10:08:13 AM9/23/22
to django-d...@googlegroups.com
And one more thing, why is radio btn returning 'on' even if it is not selected?

Ken Whitesell

unread,
Sep 23, 2022, 10:12:57 AM9/23/22
to django-d...@googlegroups.com
Absolutely.

If you're using Django, then *use* Django. Take advantage of all the facilities it provides you.

Yes, it's a little more work on your part to convert this to a Form-based template. But what it provides you are all the facilities available within Django forms for data validation and conversions.

Nishant Sagar

unread,
Sep 23, 2022, 10:20:29 AM9/23/22
to django-d...@googlegroups.com
That's what I wanted to know

Thank you sir

Kiet Lam

unread,
Sep 23, 2022, 2:34:21 PM9/23/22
to django-d...@googlegroups.com
Why don't you also use the context and pass in an array to be rendered at the htm?

There are too many repeating and hard code elements that could have been done with a single foreach statement.

On Sat, Sep 24, 2022 at 2:27 AM Kiet Lam <kmla...@gmail.com> wrote:
Hi Nishant,
Yes. I would stick to using Django forms. It has a lot of inbuilt security protection that is easily implemented at the front end like CSRF.

Cheers,
Kiet

--

Kiet Lam

unread,
Sep 23, 2022, 2:34:21 PM9/23/22
to django-d...@googlegroups.com
Hi Nishant,
Yes. I would stick to using Django forms. It has a lot of inbuilt security protection that is easily implemented at the front end like CSRF.

Cheers,
Kiet

On Fri, Sep 23, 2022 at 3:56 PM Nishant Sagar <nishan...@gmail.com> wrote:
--

Adam Johnson

unread,
Sep 27, 2022, 5:44:43 PM9/27/22
to django-d...@googlegroups.com
Hi!

I think you've found the wrong mailing list for this post (django-developers). This mailing list is for discussing the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy.

Please also avoid posting to multiple mailing lists at once.

For support, please follow the "Getting Help" page: https://docs.djangoproject.com/en/stable/faq/help/ . This will help you find people who are willing to support you, and to ask your question in a way that makes it easy for them to answer.

Thanks for your understanding and all the best,

Adam

Reply all
Reply to author
Forward
0 new messages