Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:31:50+00:00 2026-06-10T08:31:50+00:00

forms.py class UserProfileForm(forms.ModelForm): phone = forms.CharField(max_length = 15,widget = forms.TextInput(attrs = {‘placeholder’:’Enter mobile no.

  • 0

forms.py

class UserProfileForm(forms.ModelForm):
    phone = forms.CharField(max_length = 15,widget = forms.TextInput(attrs = {'placeholder':'Enter mobile no. ','class':''}))
    profession = forms.CharField(max_length= 50,widget = forms.Select(choices = PROFESSION_CHOICES,attrs = {'class':''}))
    #email = forms.EmailField(label='Email address',max_length = 75,widget = forms.TextInput(attrs={'placeholder':'Email address.','class':''}))
    sex = forms.CharField(max_length = 20,label="I am :",widget=forms.Select(choices=SEX_CHOICES,attrs = {'class':''}))
    first_name = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Please enter your real name.','class':''}))
    last_name = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Enter last name.','class':''}))
    location = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Enter your current location','class':''}))
    def clean_first_name(self):
        first_name = self.cleaned_data['first_name']
        if first_name == '':
            raise forms.ValidationError("This field is required.")
        return first_name

        def save(self,*args,**kw):
                    self.instance.first_name = self.cleaned_data.get("first_name")
                    self.instance.last_name = self.cleaned_data.get("last_name")
                    self.instance.sex = self.cleaned_data.get("sex")
                    self.instance.location = self.cleaned_data.get("location")
                    self.instance.profession = self.cleaned_data.get("profession")
                    self.instance.phone = self.cleaned_data.get("phone")
                    self.instance.save()
                    return self.instance





    class Meta:
        model = User
        fields = ('username','first_name','last_name','phone','sex','profession','location')

views.py

def profile(request,nav="profile",template="profile.html",context = {},extra_context = None):
    if request.POST:
        if 'profileFormSubmit' in request.POST:
            pform = UserProfileForm(request.POST,instance = request.user)
            if pform.is_valid():
                try:
                    user = pform.save()
                    return redirect(profile,nav="profile")
                    except RuntimeError as e:
                    return HttpResponse(e)

error

The User could not be changed because the data didn't validate.

line

    user = super(UserProfileForm,self).save(*args,**kw) 

doubt

what changes am i supposed to make to get rid of this error
how am i supposed to change the , i have tried removing all the clean_field form methods , but still getting the same error , please help , thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:31:52+00:00Added an answer on June 10, 2026 at 8:31 am

    The form wasn’t validating because I was using ‘username’ in my meta class of the UserProfileForm, which wasn’t supposed to be there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class EditAdminForm(forms.ModelForm): password = username.CharField(widget=forms.TextInput()) password = forms.CharField(widget=forms.PasswordInput()) password_confirm = forms.CharField(widget=forms.PasswordInput(), initial=???) You can
views.py if pform.is_valid(): user = pform.save() forms.py class UserProfileForm(forms.ModelForm): sex = forms.CharField(max_length = 20,label=I
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
How to add value to this form.content before rendering class myform(forms.Form): title = forms.CharField(max_length
I'm trying to create a form. Here is my form class: class RegisterForm(forms.Form): login=forms.CharField(min_length=5,max_length=15)
This is my form: from django import forms class UploadFileForm(forms.Form): titl = forms.CharField(max_length=50) ffile
I am using ModelForm on Django 1.3. models.py: class UserProfile(models.Model): ... gender = models.CharField(max_length=1,
my form is class MapForm(forms.ModelForm): class Meta: model = Map fields = ('mapName', 'kmlStr')
I'm using a modelform for User like so: class UserForm(forms.ModelForm): class Meta: model =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.