I am trying to modify a user's username in his profile. I'm not using Django's User model and had created a custom user model (`MyRegistration`) by inheriting `AbstractBaseUser`. I have also assigned my custom user model to `AUTH_USER_MODEL` in the `settings.py`. But when I try to modify the user's profile details, it throws a `ValueError` stating that The view `akola.views.akolaprofile` didn't return an `HttpResponse` object. It returned `None` instead. What could possibly be wrong?

Also, I want to understand why `is_valid()` function has been ditching me every time ever since I created my own user model. It just doesn't work in any form. Below are my codes:

`models.py`:

```
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.utils import timezone
from .manager import FirstManager

#Making custom User model

class MyRegistration(AbstractBaseUser, PermissionsMixin):
    location_list=[
        ('Solapur', 'Solapur'),
        ('Latur', 'Latur'),
        ('Dhule', 'Dhule'),
        ('Akola', 'Akola'),
        ('Nashik', 'Nashik')
        ]
    username=models.CharField(max_length=10, unique=True)
    email=models.EmailField(unique=True)
    first_name=models.CharField(max_length=150)
    last_name=models.CharField(max_length=150)
    location=models.CharField(max_length=10, choices=location_list, default='Latur')
    designation=models.CharField(max_length=70)
    is_active=models.BooleanField(default=False)
    is_staff=models.BooleanField(default=False)
    start_date=models.DateTimeField(default=timezone.now)
    last_login=models.DateTimeField(null=True)

    USERNAME_FIELD='username'
    REQUIRED_FIELDS=['email', 'first_name', 'last_name', 'location', 'designation']
    objects=FirstManager()
    def __str__(self):
        return self.username

```

`forms.py`:

```
class ProfileForm(UserChangeForm):
    password=None
    class Meta:
        model=MyRegistration
        fields = ['username', 'first_name', 'last_name', 'email', 'location', 'designation', 'start_date', 'last_login']
        labels={'email': 'Email Address'}

```

**views.py**:
Line no. 7 here, print(fm.is\_valid()) returns True in the terminal, still the code returns None.

```
def akolaprofile(request):
    if request.user.is_authenticated:
        if request.method=='POST':
            print(request.POST)
            fm=ProfileForm(request.POST, instance=request.user)
            if fm.is_valid():
                print(fm.is_valid())
                fm.save()
            else:
                return HttpResponse('Not Valid!')
        else:
            nm=request.user.first_name
            fm=ProfileForm(instance=request.user)
            return render(request, 'akola/akolaprofile.html', {'form':fm, 'Name':nm})
    else:
        return HttpResponseRedirect('/login/')

```

`urls.py`:

```
from akola import views as ve

    path('akolaprofile/', ve.akolaprofile, name='akolaprofile'),
    ]

```

Template:

```
{% block content %}
    <div class="container" style="width: 65%; margin-top: 6%;">
        <div class="container" style="background-color: #4e7a7e; height: auto; width: auto; margin-top: 8%;">
            <div class="row">
                <div class="col-lg-12"></div>
            </div>
            <div class="row">
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    <form action="" method="post" novalidate> {% csrf_token %}
                        {{form.username.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.username}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.first_name.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.first_name}}
                </div>
            </div>
            <div class="row">
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.last_name.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.last_name}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.email.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.email}}
                </div>
            </div>
            <div class="row">
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.designation.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.designation}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.start_date.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.start_date}}
                </div>
            </div>
            <div class="row">
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.location.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.location}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px; padding-left: 20px;">
                    {{form.last_login.label_tag}}
                </div>
                <div class="col-lg-3" style="padding-top: 25px; padding-bottom: 20px;">
                    {{form.last_login}}
                </div>
            </div>

            <div class="row text-center">
                <div class="col-lg-12">
                    <input class="submitbtn" type="submit" value="Save">
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12"></div>
            </div>
        </div>
    </div>
{% endblock content %}

```