How to change the default registration in django - html

I have used django's default registration. I want to edit this forms because it's appearance does not look very good to me. I want to convert the instructions into tool tip or something better looking how can I do it?I am new to django
)
html
<div class="header-wrapper">
<div class="header" style="background-image: url('/static/img/tele-bg.jpg');">
<div class="title-container text-center">
<h2>Register</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
</div>

For this you can use django bootstrap forms or you can make your own custom tempalate for registering the user.
If you want django bootstrap form which are pretty good you can try like this:
First install pip install django-bootstrap4
Then add the bootstrap4 into your INSTALLED_APPS:
INSTALLED_APPS = [
...........
'bootstrap4',]
Then you can render the forms in your template with this tag:
{% load bootstrap4 %}
<div class="header-wrapper">
<div class="header" style="background-image: url('/static/img/tele-bg.jpg');">
<div class="title-container text-center">
<h2>Register</h2>
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
</div>
EDIT: This is just a demo you can change this design as you want:
<div class="header-wrapper">
<div class="header" style="background-image: url('/static/img/tele-bg.jpg');">
<div class="title-container text-center">
<h2>Register</h2>
<form method="post">
{% csrf_token %}
Username:<br>
<input type="text" name="username" placeholder="Username"><br>
Password:<br>
<input type="password" name="password1" placeholder="Password"><br>
Password Confirmation:<br>
<input type="password" name="password2" placeholder="Confirm Password"><br><br>
<input type="submit" value="Submit">
</form>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
</div>

Related

How to center horizontally and put an element down inside a column

HTML file:
<div class="container h-100">
<div class="row h-100">
<div class="col">
<h1>{{ auction.name }}</h1>
</div>
<div class="col">
<form method="POST" action="{% url 'bid' auction.id %}">
{% csrf_token %}
<input name="bid" type="number" required><br>
<input type="submit" value="Make a bid!">
</form>
<a class="btn btn-warning" href="{% url 'close' %}">Close auction</a>
</div>
</div>
</div>
I would like to put the <a class="btn btn-warning" href="{% url 'close' %}">Close auction</a> in the bottom of the <div class="col"> and in the center horizontally, how can I do? Thank you!
This is most simply accomplished using a flexbox layout. The following is not tested but according to the bootstrap docs should give you what you want.
<div class="col d-flex flex-column justify-content-between align-items-center">
<form method="POST" action="{% url 'bid' auction.id %}">
{% csrf_token %}
<input name="bid" type="number" required><br>
<input type="submit" value="Make a bid!">
</form>
<a class="btn btn-warning" href="{% url 'close' %}">Close auction</a>
</div>
In order to make your button in the bottom of your form you should add a new row (new div with the class row), and in order to center it horizontally you should add one of these classes: pagination-centered or text-center as suggested by this answer. The final code may be similar to this :
<div class="container h-100">
<div class="row h-100">
<div class="col">
<h1>{{ auction.name }}</h1>
</div>
<div class="col">
<form method="POST" action="{% url 'bid' auction.id %}">
{% csrf_token %}
<input name="bid" type="number" required><br>
<input type="submit" value="Make a bid!">
</form>
<div class="row pagination-centered">
<a class="btn btn-warning" href="{% url 'close' %}">Close auction</a>
</div>
</div>
</div>
</div>
Try this. This may take some editing to get it exactly how you like it, but it should put the warning button below the other buttons and in the center. The key here is the bootstrap class "offset-(number of columns)"
<div class="container h-100">
<div class="row h-100">
<div class="col">
<h1>{{ auction.name }}</h1>
</div>
</div>
<div class="row">
<form method="POST" action="{% url 'bid' auction.id %}">
<div class="col-3">
{% csrf_token %}
</div>
<div class="col-3">
<input name="bid" type="number" required><br>
</div>
</div>
<div class="offset-5">
<input type="submit" value="Make a bid!">
</div>
</form>
</div>
<div class="row">
<div class="offset-5 col-1">
<a class="btn btn-warning" href="{% url 'close' %}">Close auction</a>
</div>
</div>
</div>

Html form not submitting data

This html form is not submitting data and i don't know why.I have tried to find the error and i do not seem to get around it,any help will be gladly appreciated
{% extends 'registration/base.html' %}
{% load widget_tweaks %}
{% block title %}Create account{% endblock %}
{% block body %}
<div class="container" style="padding-top:20px">
<div class="row">
<div class="col-md-4 card jumbotron ">
<h2><span class="badge badge-light">Create Account</span></h2><br>
<form action="{% url 'tzuzz:create_account' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label>Email </label>
<input class="form-control is-valid" type="text" name="email" placeholder="Email">
<label>Names</label>
<input class="form-control is-valid" type="text" name="names" placeholder="Enter first and last name">
<label>Sex</label>
<select class="form-control" name="sex">
<option>Male</option>
<option>Female</option>
</select>
<label>Date of birth</label>
<input class="form-control is-valid" name="date" type="date">
<label>Password</label>
<input class="form-control is-valid" type="password" name="password" placeholder="Password">
</div>
<button class="btn btn-secondary">Login</button>
</form>
<br><br>
{% if error %}
<p class="alert alert-danger alert-dismissible fade show" role="alert">
{{error}}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</p>
{% endif %}
</div>
</div>
{% endblock %}
Here is the answer i forgot to include type submit in my button
<button class="btn btn-secondary" type="submit">Login</button>

Bootstrap: Issue with columns not adding up to 12 and being put on new rows

Right, so I'm pretty sure I'm following the rules to structure columns and rows in bootstrap. You have your container then your rows and columns for a specific row. What im wondring is why it creates a new row for each post that i make and stacks them instead of putting them on the same row till it hits 12.
Here is my code:
<div class="container">
<section class="row new-post">
<div class="col-md-6">
<header><h3>What do you have to say</h3></header>
<form action="{{ route('postcreate') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="cover_image">Image (only .jpg)</label>
<input type="file" name="cover_image" class="form-control" id="cover_image">
</div>
<div class="form-group">
<textarea class="form-control" name="body" rows="5" placeholder="your post"></textarea>
</div>
<button type="submit" class="btn btn-primary">Create post</button>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
</div>
</section>
<section class="row posts">
<div class="col-md-2">
#foreach($posts as $post)
#if(Auth::user() == $post->user)
<article class="post">
<!-- <img style="width:300; height:250px;" src="{{ asset('storage/cover_images/' . $post->cover_image) }}"> -->
<p>{{ $post->body }}</p>
<div class="info">Posted by {{ $post->user->first_name }} {{ $post->user->last_name }} on {{ $post->created_at }}</div>
<a href="#" >Like</a>|
Edit|
Delete
</article>
<br/>
#endif
#endforeach
</div>
</section>
</div>
I believe your form-group class is interfering with the thing that you are trying to achieve. Try removing it and check if that does it for you (the formatting would obviously change upon removing that class, but you'll know the source of the issue), otherwise try writing a custom class for form-group.
I hope this helps.

Register button not working in registration_form.html django

I've been following the How to Django 1.9 tutorials and I came across a problem. My registration_form.html has been working properly ever since installment but after adding bootstrap to the template, the registration button has no action. This is the registration_form.html without the bootstrap
{% extends "rango/base.html" %}
{% block body_block %}
<h1>Register Here</h1>
<form method="post" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
{% endblock %}
This is the registration_template with the bootstrap
{% extends 'rango/base.html' %}
{% block body_block %}
<link href="http://v4-alpha.getbootstrap.com/examples/signin/signin.css" rel="stylesheet">
<div class="jumbotron">
<h1 class="display-5">Register</h1>
</div>
<form role="form" method='post' action='.'>
{% csrf_token %}
<div class="form-group">
<p class="required"><label class="required" for="id_username">Username:</label>
<input class="form-control" id="id_username" maxlength="30" name="username" type="text" />
<span class="helptext">
Required. 30 charachters or fewer. Letters, digits and #/./+/-/_ only.
</span>
</p>
<p class="required"><label class="required" for="id_email">Email:</label>
<input class="form-control" id="id_email" name="email" type="email"/>
</p>
<p class="required"><label class="required" for="id_password1">Password:</label>
<input class="form-control" id="id_password1" name="password1" type="password"/>
</p>
<p class="required"><label class="required" for="id_password2">Password Confirmation:</label>
<input class="form-control" id="id_password2" name="password2" type="password" />
</p>
</div>
<button type="submit" class="btn btn-primary" value='Submit'>Submit</button>
</form>
<p>
Already a member?
Log In Here!
</p>
{% endblock %}
Add url in your template form under action attribute as showed below:
<form role="form" method='post' action='{% url 'example' %}'>
This may fix your issues!!!.Make sure that your form has no errors.Try to add your views.py,urls.py and models.py, so we can figure it out easily.
Must be an input type not a button type use <input type="submit" class="btn btn-primary" value='Submit'>Submit</button> instead
<button type="submit" class="btn btn-primary" value='Submit'>Submit</button>

Send button is not working

I have this template:
<form role="form">
<div class="form-group">
{% bootstrap_field form.username %}
</div>
<div class="form-group">
{% bootstrap_field form.password %}
</div>
<input type="submit" value="Enviar" class="btn btn-info btn-block">
</div>
</form>
The submit button is not working what I doing bad? i've read other answers and still not working, thanks for your help!!!.
With a regular HTML form, you would need to specify a couple of attributes in <form>
You need to provide a target page where the form will be processed:
action="http://script_url_here"
You should also specify the method by which the data will be sent (either GET or POST):
method="POST"
One other thing: you had an extra </div> at the end of your form. After making those changes, your form would now look like this:
<form role="form" action="http://script_url_here" method="POST">
<div class="form-group">
{% bootstrap_field form.username %}
</div>
<div class="form-group">
{% bootstrap_field form.password %}
</div>
<input type="submit" value="Enviar" class="btn btn-info btn-block">
<!-- You had an extra </div> here -->
</form>
There are other attributes that could and ought to be specified, but they are optional.