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

  • Home
  • SEARCH
  • 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 1078391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:43:00+00:00 2026-05-16T21:43:00+00:00

I’m trying to mimic the admin interface for the Photologue app on the front

  • 0

I’m trying to mimic the admin interface for the Photologue app on the front end. To achieve this, I have thus far created a bit of code in the view:

def galleryuploader(request):
    GalleryFormSet = modelformset_factory(GalleryUpload)    
    if request.method == 'POST':
        formset = GalleryFormSet(request.POST, request.FILES)
        if formset.is_valid():
            formset.save()
            # do something. ... do what?
    else:
        formset = GalleryFormSet()
    return render_to_response("cms_helper/gallery_upload.html", {
        "formset": formset,
    })

and a template:

<form method="post" action="">
    {{ formset }} 
    <input type="submit" />
</form>

I’m using django’s “form from models” method for generating this front-end form.

The problem: when I try to upload a file (because I am uploading photos to a photo gallery), and hit submit, it returns with a form error telling me that a required field was missing (the file).

I think I am not checking the request for any files, but even if I were to, I’m not quite sure how to. Here’s some documentation about file uploads, but I haven’t been able to decipher it yet.

If you have any suggestions about how to make this upload form work, I’d be veryyy happy to hear them. 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-05-16T21:43:01+00:00Added an answer on May 16, 2026 at 9:43 pm

    Add the enctype="multipart/form-data" attribute to your form tag. Also you’ll need to actually do something with the uploaded files. Here’s the example from the django docs:

    from django.http import HttpResponseRedirect
    from django.shortcuts import render_to_response
    
    # Imaginary function to handle an uploaded file.
    from somewhere import handle_uploaded_file
    
    def upload_file(request):
        if request.method == 'POST':
            form = UploadFileForm(request.POST, request.FILES)
            if form.is_valid():
                # you'll need to loop through the uploaded files here.
                handle_uploaded_file(request.FILES['file'])
                return HttpResponseRedirect('/success/url/')
        else:
            form = UploadFileForm()
        return render_to_response('upload.html', {'form': form})
    
    def handle_uploaded_file(f):
        destination = open('some/file/name.txt', 'wb+')
        for chunk in f.chunks():
            destination.write(chunk)
        destination.close()
    

    (See the comment about halfway through)

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

Sidebar

Related Questions

No related questions found

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.