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 8443503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:09:23+00:00 2026-06-10T09:09:23+00:00

views.py if pform.is_valid(): user = pform.save() forms.py class UserProfileForm(forms.ModelForm): sex = forms.CharField(max_length = 20,label=I

  • 0

views.py

if pform.is_valid():
    user = pform.save()

forms.py

class UserProfileForm(forms.ModelForm):
    sex = forms.CharField(max_length = 20,label="I am :",widget=forms.Select(choices=SEX_CHOICES,attrs = {'class':''}),required = False)
    first_name = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Please enter your real name.','class':''}),required = False)
    last_name = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Enter last name.','class':''}),required = False)
    location = forms.CharField(max_length = 50,widget = forms.TextInput(attrs={'placeholder':'Enter your current location','class':''}),required = False)
    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 clean_phone(self):
        phone = self.cleaned_data['phone']
        if phone == '':
            raise forms.ValidationError("This field is required.")
        return phone

    def clean_last_name(self):
        last_name = self.cleaned_data['last_name']
        if last_name == '':
            raise forms.ValidationError("This field is required.")
        return last_name

    def clean_profession(self):
        profession = self.cleaned_data['profession']
        if profession == "":
            raise forms.ValidationError("Select a valid option.")
        return profession

    def clean_sex(self):
        sex = self.cleaned_data['sex']
        if sex == "":
            raise forms.ValidationError("Select a valid option.")
        return sex

    def __init__(self,*args,**kw):
        super(UserProfileForm,self).__init__(*args,**kw)
        self.phone = self.instance.get_profile().phone
        self.profession = self.instance.get_profile().profession
        self.sex = self.instance.get_profile().sex
        self.location = self.instance.get_profile().location        

    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.get_profile().sex = self.cleaned_data.get("sex")
        self.instance.get_profile().location = self.cleaned_data.get("location")
        self.instance.get_profile().profession = self.cleaned_data.get("profession")
        self.instance.get_profile().phone = self.cleaned_data.get("phone")
        self.instance.save()
        return self.instance

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

doubt

everything is working fine but y am i not able to save the information to the user profile , when i use the self.instance.get_profile().phone = self.cleaned_data.get('#some_field') , because when i am retrieving the data its not showing up in m form , 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-10T09:09:25+00:00Added an answer on June 10, 2026 at 9:09 am

    If I understood you well, then you get data from the form and can’t save it to the users profile. To fix this, you need do save user profile too:

    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")
        profile = self.instance.get_profile()
        profile.sex = self.cleaned_data.get("sex")
        profile.location = self.cleaned_data.get("location")
        profile.profession = self.cleaned_data.get("profession")
        profile.phone = self.cleaned_data.get("phone")
        profile.save()
        self.instance.save()
        return self.instance
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

forms.py class UserProfileForm(forms.ModelForm): phone = forms.CharField(max_length = 15,widget = forms.TextInput(attrs = {'placeholder':'Enter mobile no.
views.py: user = User.objects.create_user(username=username, email=email) user.password=password1 #user.set_password(password1) user.save() models.py: def create_user_profile(sender, instance, created, **kwargs):
I have two table views, when user clicks one cell of the first, second
In views.py I have the following view which gets called when a new user
I have two views. The User view has some text and a button. I
I am editing views/elements/form_user.ctp and require a custom label for my input, I cannot
views/devise/sessions/new.html.haml %h2 = t('devise.sessions.link') devise can't find the translation <span class=translation_missing title=translation missing: ru.devise.sessions.link>Link</span>
views.py def login_user(request): if request.POST: sform = LoginForm(request.POST) rform = UserForm() if sform.is_valid(): username
My views extend a base view class I've made: public class BaseView : ViewPage
In views, I can use if ($view['security']->isGranted('ROLE_ADMIN')) : To check if the user has

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.