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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:08:34+00:00 2026-05-13T10:08:34+00:00

I’m trying to edit an existing object through a form. Every thing is working

  • 0

I’m trying to edit an existing object through a form. Every thing is working fine except for the ImageField not being populated with the current value.

Here’s the model:

class Post(models.Model):
    author = models.ForeignKey(User, editable=False)
    slug = models.SlugField(max_length = 110, editable=False)
    title = models.CharField(verbose_name='Blog Title', max_length=40, blank=False)
    body = models.TextField(verbose_name='Body')
    thumbnail = models.ImageField(upload_to = 'posts/%Y/%m')

Here’s the view

@login_required
def edit_profile(request, form_class=UserProfileForm, success_url=None, template_name='profiles/edit_profile.html', extra_context=None):

try:
    profile_obj = request.user.get_profile()
except ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('profiles_create_profile'))

if success_url is None:
    success_url = reverse('profiles_profile_detail',
                          kwargs={ 'username': request.user.username })
if form_class is None:
    form_class = utils.get_profile_form()
if request.method == 'POST':
    form = form_class(data=request.POST, files=request.FILES, instance=profile_obj)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect(success_url)
else:
    form = form_class(instance=profile_obj)

if extra_context is None:
    extra_context = {}
context = RequestContext(request)
for key, value in extra_context.items():
    context[key] = callable(value) and value() or value

return render_to_response(template_name,
                          { 'form': form,
                            'profile': profile_obj, },
                          context_instance=context)

This object did have a thumbnail attached but when I went to edit, nothing showed up in the Thumbnail field

  • 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-13T10:08:34+00:00Added an answer on May 13, 2026 at 10:08 am

    I believe the answer lies in the fact that the file input field, when it displays a value, displays the local path to the file on the user’s computer that was selected. This value is not saved in Django anywhere so Django can’t and won’t display this value in the form when editing.

    What you need to do is print each field individually in the template instead of printing the form as a whole. Then, with your thumbnail field, show the currently selected thumbnail as an actual image on the page and use the file input field to allow the user to upload a new image.

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

Sidebar

Ask A Question

Stats

  • Questions 370k
  • Answers 370k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This functionality already exists; take a look at unset. http://php.net/manual/en/function.unset.php… May 14, 2026 at 6:36 pm
  • Editorial Team
    Editorial Team added an answer Unlike Oracle, PostgreSQL and even MySQL, SQL Server has no… May 14, 2026 at 6:36 pm
  • Editorial Team
    Editorial Team added an answer There's a whole universe of "what if" behind what causes… May 14, 2026 at 6:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.