> 
> 
> > 
> > I am new to Django. Whenever I submit my Sign Up form form.is\_valid() in my view function returns false. I can't figure out where I am going wrong. I use SignUpForm class for additional fields. signup.html is my template. signup is my view function. Is my SignUpForm class in my forms.py is wrong? Any help would be great. I also filled all the details in my signup form but still form.is\_valid() returns false in my case.
> > 
> > 
> > 
> 
> 
> 

my view function

```
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'signup.html', {'message': 'Signed Up successfully'})
    return render(request, 'signup.html')

```

my forms.py

```
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User

class SignUpForm(UserCreationForm):
    first_name = forms.CharField(max_length=255)
    last_name = forms.CharField(max_length=255)
    password = forms.CharField(widget=forms.PasswordInput)
    confirm_password = forms.CharField(widget=forms.PasswordInput)
    phone_number = forms.CharField(max_length=100)

    class Meta:
        model = User
        fields = ['username', 'email', 'first_name', 'last_name', 'password', 'confirm_password', 'phone_number']

```

my base.html

```
<body style = "margin: 0;">
    <div class="row" style="padding-left: 2%;padding-top:1%;">
        <div class="col-md-9">
            <h2>Welcome to my site</h2>
        </div>
        <div class="col-md-2">
            <a href="{% url 'login' %}" class="btn btn-primary" style="margin-right: 6%;">Login</a><br><br><br>
        </div>
    </div>

    <div class="row" style="margin-left: 4%">
        <form  class="form-group" name="form1" id="form1" method="post" style="padding-top: 1%" action = "{% url 'signup' %}">
            {% csrf_token %}
            <h3>Sign up</h3><br>
            <div class="form-group row">
                <label id="user" class="col-4 col-form-label">Username</label>
                <div class="col-8">
                    <input class="form-control" type="text" name = "username" placeholder = "Username" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="email" class="col-4 col-form-label">Email id</label>
                <div class="col-8">
                    <input class="form-control" type="text" name = "email" placeholder = "Email id" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="first_name" class="col-4 col-form-label">First name</label>
                <div class="col-8">
                    <input class="form-control" type="text" name = "first_name" placeholder = "First name" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="last_name" class="col-4 col-form-label">Last name</label>
                <div class="col-8">
                    <input class="form-control" type="text" name = "last_name" placeholder = "Last name" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="password" class="col-4 col-form-label">Password</label>
                <div class="col-8">
                    <input class="form-control" type="password" name = "password" placeholder = "Password" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="confirm_password" class="col-4 col-form-label">Re-enter Password</label>
                <div class="col-8">
                    <input class="form-control" type="password" name = "confirm_password" placeholder = "Password" required="true" >
                </div>
            </div>
            <div class="form-group row">
                <label id="contact_number" class="col-4 col-form-label">Contact number</label>
                <div class="col-8">
                    <input class="form-control" type="text" name = "phone_number" placeholder = "Contact number" required="true" >
                </div>
            </div>

            <input type = "submit" value = "Sign up" class="btn btn-primary">
        </form>
        {% if message %}
            {{ message }}
        {% endif %}
    </div>
    <br>
</body>

```

my signup.html which extends base.html

```
{% extends 'base.html' %}

{% block content %}
  <h2>Sign up</h2>
  <form method="post" action="{% url 'signup' %}">
    {% csrf_token %}
    {{ form.as_p }}
    <button type="submit">Sign up</button>
  </form>
{% endblock %}

```