'i can't create user in django

I am trying to create a login and signup feature on my website but for some reason, I can't create a user. and it's not showing any error. I have done these before in another code but I don't know why it is not working in this one. And also when I refresh the website, it asks if it should resubmit the form.

These are the codes below

index.html

 <div class="main-register">
                            <div class="close-reg"><i class="fal fa-times"></i></div>
                            <ul class="tabs-menu fl-wrap no-list-style">
                                <li class="current"><a href="#tab-1"><i class="fal fa-sign-in-alt"></i> Login</a></li>
                                <li><a href="#tab-2"><i class="fal fa-user-plus"></i> Register</a></li>
                            </ul>
                            <!--tabs -->                       
                            <div class="tabs-container">
                                <div class="tab">
                                    <!--tab -->
                                    <div id="tab-1" class="tab-content first-tab">
                                        <div class="custom-form">
                                            <form method="post" action="" name="registerform">
                                                {% csrf_token %}
                                                {% for message in messages %}
                                          <h4 style="color: red;">{{message}}</h4>
                                          {% endfor %}
                                                <label>Email Address  * <span class="dec-icon"><i class="fal fa-user"></i></span></label>
                                                <input name="email" type="email"  placeholder="Your Mail"  onClick="this.select()" value="">
                                                <div class="pass-input-wrap fl-wrap">
                                                    <label >Password  * <span class="dec-icon"><i class="fal fa-key"></i></span></label>
                                                    <input name="password" placeholder="Your Password" type="password"  autocomplete="off" onClick="this.select()" value="" >
                                                    <span class="eye"><i class="fal fa-eye"></i> </span>
                                                </div>
                                                <div class="lost_password">
                                                    <a href="#">Lost Your Password?</a>
                                                </div>
                                                <div class="filter-tags">
                                                    <input id="check-a3" type="checkbox" name="check">
                                                    <label for="check-a3">Remember me</label>
                                                </div>
                                                <div class="clearfix"></div>
                                                <button type="submit"  class="log_btn color-bg"> LogIn </button>
                                            </form>
                                        </div>
                                    </div>
                                    <!--tab end -->
                                    <!--tab -->
                                    <div class="tab">
                                        <div id="tab-2" class="tab-content">
                                            <div class="custom-form">
                                                <form method="POST"   id="registerform" class="main-register-form" name="registerform">
                                                    {% csrf_token %}
                                                {% for message in messages %}
                                          <h4 style="color: red;">{{message}}</h4>
                                          {% endfor %}
                                                    <label >Full Name  * <span class="dec-icon"><i class="fal fa-user"></i></span></label>
                                                    <input name="full_name" type="text" placeholder="Your Name"    onClick="this.select()" value="">
                                                    <label>Email Address  * <span class="dec-icon"><i class="fal fa-envelope"></i></span></label>
                                                    <input name="email" type="text"  placeholder="Your Mail"   onClick="this.select()" value="">
                                                    <div class="pass-input-wrap fl-wrap">
                                                        <label >Password  * <span class="dec-icon"><i class="fal fa-key"></i></span></label>
                                                        <input name="password" type="password" placeholder="Your Password"  autocomplete="off"  onClick="this.select()" value="" >
                                                        <span class="eye"><i class="fal fa-eye"></i> </span>
                                                    </div>
                                                    <div class="filter-tags ft-list">
                                                        <input id="check-a2" type="checkbox" name="check">
                                                        <label for="check-a2">I agree to the <a href="#">Privacy Policy</a> and <a href="#">Terms and Conditions</a></label>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                    <button type="submit"     class="log_btn color-bg"> Register </button>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    <!--tab end -->
                                </div>

views.py

def index(request):
    return render(request, 'index.html')

def signup(request):
    if request.method == 'POST':
        full_name = request.POST['full_name']
        email = request.POST['email']
        password = request.POST['password']

        if User.objects.filter(email=email).exists():
            messages.info(request, 'Email is taken')
            return redirect('index.html')
        else:
            user = User.objects.create_user(full_name=full_name, email=email, password=password)
            user.save() 

            user_model = User.objects.get(full_name=full_name)
            new_profile = user_profile.objects.create(user=user_model, id_user=user_model.id)
            new_profile.save()
            return redirect('index.html')
    else:
        return render(request, 'index.html')

urls.py

from django.urls import path
from . import views


urlpatterns = [
    path('', views.index, name='index'),
]

models.py

from django.db import models
from django.contrib.auth import get_user_model

User =get_user_model()

# Create your models here.
class user_profile(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    id_user = models.IntegerField()
    location = models.CharField(max_length=120, blank=True)


    def __str__(self):
        return self.user.full_name


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source