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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:14:49+00:00 2026-05-15T15:14:49+00:00

I have a page which displays a form that a logged-in user can use

  • 0

I have a page which displays a form that a logged-in user can use to edit their profile.

The first time the user loads the corresponding view, with a GET request, the form should display the values of the users existing profile record.

Because I’d like to have granular control over the markup used for the form fields, I’d like to retrieve the field values only, and manually write the necessary input element markup inserting the retrieved field values as the input elements’ ‘value’ attribute (rather than have django render the entire input elements).

So far I’ve been trying to use directives like {{ form.myfield.data }} in my template to access the field data, but this is returning “None”, instead of the profile details as i expected.

If the user has just posted a valid form though, the form fields do contain the expected profile details.

I hope someone can help me understand what i’m doing wrong here:

Here’s my view:

@login_required
def edit(request):
    # get logged-in user's profile
    obj=Profile.objects.get(user=request.user)
    if request.method == 'POST': # If the form has been submitted...
        form = ProfileForm(request.POST, request.FILES, instance=obj)   
        if form.is_valid(): # All validation rules pass
            form.save()
            request.flash['success'] = "Your profile has been updated." # Puts a string to the flash scope
        else:
            request.flash['error'] = 'Please correct the problems below and try again' # Puts a string to the flash scope
    else:
        # if no form was submitted
        # derive the form data from the logged-in users existing profile
        form = ProfileForm(instance=obj)    
    return render_to_response('app_profile/edit.html',
    {
    'form': form,
    'user': request.user,
    'ancestor_urls': ['app_profile.views.edit',],
    },context_instance=RequestContext(request)
)

And here’s an excerpt from the corresponding template. This input element deals with a field called ‘display_name’.

<input type="text"
class="textInput large {% if form.display_name.errors %}error{% endif %}"
maxlength="50"
size="35"
value="{{ form.display_name.data }}"
id="id_display_name"
name="display_name">
  • 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-05-15T15:14:50+00:00Added an answer on May 15, 2026 at 3:14 pm

    The way to do what you want to do is to write custom form widgets, instead of doing that in the template.

    You can either create an entirely custom widget, or you can just add/change the attributes on the form level when you init the ModelForm

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

Sidebar

Related Questions

I have an html page which contains a div that displays the html from
I have an ASP.Net page, which displays a list of options to the user.
I have a web page that displays dynamic data which changes every 2 seconds.
I have a View with a form which displays data from objects that are
I have a page that lets the viewer edit objects. The page displays a
I have a page which dynamically brings in a form via ajax and displays
I have a page which displays my database information. Through each loop, there is
I have an ASP page which displays a text box when it loads. It
I have web page in PHP which displays all records in a table. I
Lets say you have a fragment of the page which displays the most recent

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.