Implement user authentication system with custom user model, views, and templates
- Created custom User model extending Django's AbstractUser. - Added user registration, login, and profile views with corresponding templates. - Implemented user authentication functionality and integrated Bootstrap for styling. - Updated project settings to use the new accounts app and user model. - Added tests for user model and admin functionality.
This commit is contained in:
parent
432d2b7707
commit
faddc4c9b0
22 changed files with 556 additions and 24 deletions
96
templates/accounts/signup.html
Normal file
96
templates/accounts/signup.html
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Sign Up{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-success text-white">
|
||||
<h4 class="mb-0"><i class="fas fa-user-plus"></i> Sign Up</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger">
|
||||
<ul class="mb-0">
|
||||
{% for field, errors in form.errors.items %}
|
||||
{% for error in errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="{{ form.username.id_for_label }}" class="form-label">Username</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
||||
<input type="text" class="form-control" name="username"
|
||||
id="{{ form.username.id_for_label }}" value="{{ form.username.value|default:'' }}"
|
||||
required>
|
||||
</div>
|
||||
{% if form.username.help_text %}
|
||||
<div class="form-text">{{ form.username.help_text }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="{{ form.password1.id_for_label }}" class="form-label">Password</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-lock"></i></span>
|
||||
<input type="password" class="form-control" name="password1"
|
||||
id="{{ form.password1.id_for_label }}" required>
|
||||
</div>
|
||||
{% if form.password1.help_text %}
|
||||
<div class="form-text">{{ form.password1.help_text }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="{{ form.password2.id_for_label }}" class="form-label">Confirm Password</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-lock"></i></span>
|
||||
<input type="password" class="form-control" name="password2"
|
||||
id="{{ form.password2.id_for_label }}" required>
|
||||
</div>
|
||||
{% if form.password2.help_text %}
|
||||
<div class="form-text">{{ form.password2.help_text }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-success btn-lg">
|
||||
<i class="fas fa-user-plus"></i> Sign Up
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer text-center">
|
||||
<p class="mb-0">Already have an account? <a href="{% url 'accounts:login' %}"
|
||||
class="text-decoration-none">Login here</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.form-control {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
.input-group-text {
|
||||
background-color: #f8f9fa;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.form-text {
|
||||
font-size: 0.875em;
|
||||
color: #6c757d;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue