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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:42:33+00:00 2026-06-17T01:42:33+00:00

I have a Django template which is displaying a file field like so: <div

  • 0

I have a Django template which is displaying a file field like so:

  <div class="fieldWrapper">
      {{ auth_users_ext.user_pic.error }}
      Image Upload: {{ auth_users_ext.user_pic }}
  </div>

I’ve used the necessary enctype=”multipart/form-data”. The field correctly displays a value being pulled from the database, so I have so far assumed that it is functioning as it’s supposed to. The problem I’m having is that wherever I place the field within the template file, the request.POST data is truncated at that point.

So, if I place the field last on the form, I get every field above it. If I place the field at the very top of the form, I get nothing at all.

I can read the POST payload in Chrome and verify that the POST data being passed to the view is complete:

------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="csrfmiddlewaretoken"

********
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="csrfmiddlewaretoken"

********
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="staff_id"

98.0
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="auth_user_id"

1069
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="user_groups"

1
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="user_groups"

11
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="user_groups"

13
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="current_pic"

/media/no_pic.jpg
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="user_pic"; filename="Picture0029.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="first_name"

Robert
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="last_name"

Vila
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="username"

bobvila
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="email"

BobVila@thisoldhouse.com
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="work_number"

1239111234
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="mobile_number"

1239111234
------WebKitFormBoundaryZTdhKmOKbDRAXLAm
Content-Disposition: form-data; name="mgr_id"

1
------WebKitFormBoundaryZTdhKmOKbDRAXLAm--

Regardless, when I specify request.FILES[‘user_pic’] in the view, I get nothing.

UPDATED

Here is the relevant code from the view:

def STAFF(request, uid=None, template='auth_user.html'):
    [ ... ]
    user = request.user
    is_admin = user.groups.filter(name='*** ADMIN_GROUP_NAME ***')

    if uid == None:
        instance = AuthUser()
        ext_instance = AuthUserExt()
    else:
        instance = AuthUser.objects.get(auth_user_id=uid)
        ext_instance = AuthUserExt.objects.get(auth_user_id=uid)

    if request.method == 'POST':
        # get image request.FILE object
        if request.FILES:
            avatar = request.FILES['user_pic']
            # build destination path for os file handling
            dest_path = settings.MEDIA_ROOT + request.POST['username'] + '/avatar/'
            # create user/avatar dir if not exist
            if not os.path.exists(dest_path):
                os.makedirs(dest_path)
            # open file handle at the intended destination and write our request.FILE
            if os.path.isfile(dest_path + avatar.name):
                os.remove(dest_path + avatar.name)
            destination = open(dest_path + avatar.name, 'wb+')
            destination.write(avatar.read())
            destination.close()
            # build uri path for database insert
            uri_path = settings.MEDIA_URL + request.POST['username'] + '/avatar/' + avatar.name
        else:
            [ ... ] # lands here, because Django produces no request.FILES
  • 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-17T01:42:34+00:00Added an answer on June 17, 2026 at 1:42 am

    This issue ended up being the result of some sort of problem with Google Chrome. It was apparently having a problem with something about that file field and was truncating the actual POST data being returned to the server, but was handling things internally sufficient to make me think that all was well when I inspected the debug information. Every other browser worked just fine.

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

Sidebar

Related Questions

I have a hidden field defined in my django template,value of which is passed
I have a search field at the top of my django template (with no
I have a string which needs to passed into a django template filter. But
I have a django template which is used from many views. The template has
I would like to use django template for e-mail sending. But I should have
I have a Django application which includes a custom model field (and accompanying form
I have a django template which I have to send as email body, the
I have been searching for a way to make a django template which can
I have this model which has Image field to be uploaded. It has a
I have a django template in which I wish to present a table of

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.