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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:23:31+00:00 2026-06-03T20:23:31+00:00

What I basically want to accomplish is that when a user edits his profile,

  • 0

What I basically want to accomplish is that when a user edits his profile, a blank field causes everything to be overwritten.

For example:

if a first name is added and the user wants t change it he wont have to refill the whole form, the only field he will have to change is the first name field.When the form gets submitted the other blank fields cause their model field to be empty.

here is what i tried:

def editUserprofile(request):
    rc = context_instance=RequestContext(request)
    u = request.user
    if request.method=='POST':
        form = UserProfileEdit(request.POST, request.FILES)
        if form.is_valid():
            u = UserProfile.objects.get(user=u)
            if 'avatar' in request.FILES :
                u.avatar = request.FILES['avatar']
            if 'first_name' in request.POST:
                u.first_name = form.cleaned_data['first_name']
            if 'last_name' in request.POST:
                u.last_name = form.cleaned_data['last_name']
            if 'email' in request.POST:
                u.email = form.cleaned_data['email']
            if 'country' in request.POST:    
                u.country = form.cleaned_data['country']
            if 'date_of_birth' in request.POST:
                u.date_of_birth = form.cleaned_data['date_of_birth']
            u.save()
            return HttpResponseRedirect(reverse('photocomp.apps.users.views.editUserprofile'))
    else:
        u = UserProfile.objects.get(user=u)
        form = UserProfileEdit()
    return render_to_response('users/editprofile.html',
                             {'form':form, 'u':u},
                             rc)

Can I someway make the empty field pass without editing my models content?

Hope it doesn’t confuse you so much!

If you want more detail just tell me 🙂 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-03T20:23:32+00:00Added an answer on June 3, 2026 at 8:23 pm

    Since this is edit form, you should consider pre-filling the fields with the current values. This is easy by submitting the constructor an instance argument (if you are using ModelForm). This would pre-fill the values with the correct values and the user can change whichever he/she wants.

    form = UserProfileEdit(instance=u)
    

    Django doc link.

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

Sidebar

Related Questions

Let me describe the thing that I want to accomplish: I basically want to
I basically want to do this: grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log ...with of course
I basically want to open a browser window from Word using VBA that does
for($i=0;$i<$num;$i++) { if($i==even) $hilite=hilite; dothing($i,$hilite); } This is basically what I want to accomplish.
I have a bit of a problem with user controls. Basically what I want
Alright, I am trying to accomplish this: When a user clicks a button that
Basically what I want to do is allow a user to type in a
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am working on a small text replacement application that basically lets the user
What I want basically to acomplish is to schedule on a task_group new work

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.