how to design custom forms in django with bootstrap

217 views
Skip to first unread message

Ikram Ulhaq

unread,
Jun 20, 2016, 7:56:29 AM6/20/16
to Django users
Hi everyone!
i am new in django and want to design custom form in bootstarp that can use to send data to database.i made form successfully but values not inserted in database.please help

Babatunde Akinyanmi

unread,
Jun 20, 2016, 8:55:07 AM6/20/16
to Django users

Hello Ikram,
It's going to be difficult to help you without more information about the problem. If you give information about what you have tried and what's failing, you will get more helpful answers.

On Jun 20, 2016 12:56 PM, "Ikram Ulhaq" <ulhaq...@gmail.com> wrote:
Hi everyone!
i am new in django and want to design custom form in bootstarp that can use to send data to database.i made form successfully but values not inserted in database.please help

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1f966387-c6c9-4498-8776-8fa8c809f4d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ikram Ulhaq

unread,
Jun 20, 2016, 5:02:34 PM6/20/16
to Django users

sir i want to design a custom form in django that will store data in database...i done this with built in django forms but i can't be able to design with bootstarp or css. data not inserted if i create my own custom form like 

<div class="row">
<div class="col-md-4">
<div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
  </div>
</div>

<div class="col-md-4 col-md-offset-1">
<div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
  </div>
</div>
</div>

<button class="btn btn-info">some button</button>


<div class="col-md-4">
<div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <select class="form-control">
<option>aa</option>
</select>
  </div>
</div>

Ikram Ulhaq

unread,
Jun 20, 2016, 5:02:46 PM6/20/16
to Django users

Babatunde Akinyanmi

unread,
Jun 21, 2016, 4:49:14 AM6/21/16
to Django users

Hello Ikram,
You still didn't give enough details. For example, does it submit and successfully or does it not?

Anyway, I can see some problems in your markup.

1. I do not see any form tag (<form>.... <\form>)  in your markup.
2. More importantly, your form input elements do not have a name attribute.

Your browser *might* help you out with (1) but the server will not receive the data in your form input elements if they do not have any name attribute assigned to them.

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jani Tiainen

unread,
Jun 21, 2016, 5:38:16 AM6/21/16
to django...@googlegroups.com
Hi,

If you're unsure what markup should look a like, you can create initial HTML as you have done it with form.as_p (or whatever you used to make working form). Then open then source of page and copy to and start applying bootstrap CSS/html tags/attributes.

You should then get working form.
--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.
--
Jani Tiainen

13515...@qq.com

unread,
Jun 21, 2016, 8:46:42 PM6/21/16
to django-users

u need read how to use css file by django :https://docs.djangoproject.com/en/1.9/intro/tutorial06/ 
before this u need download bootstrap in ur location disk,and add <link rel="stylesheet" href="/static/css/bootstrap.min.css">
in the <head> of ur html.

ww
Reply all
Reply to author
Forward
0 new messages