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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:05:15+00:00 2026-06-12T21:05:15+00:00

I have been trying to figure out what is going wrong when I try

  • 0

I have been trying to figure out what is going wrong when I try to submit a form.
I get this response on the web page when I hit submit on the form:

Image:
    This field is required.

It seems to think I have not included an image in the form!

settings.py

...
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/path/to/myproject/database/sqlite.db'),
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}
...
MEDIA_ROOT = '/path/to/myproject/media/'
MEDIA_URL = '/media/'
...
INSTALLED_APPS = (
    ...
    'myapp',
)

models.py

from PIL import Image
from django import forms
from django.db import models
from django.forms import ModelForm

UPLOADER_CHOICES = (
    ('C', 'Common User'),
    ('N', 'Nutrition Kitchen'),
)

class Meal(models.Model):

    title       = models.CharField(max_length=100)
    slug        = models.SlugField(unique=True)
    image       = models.ImageField(upload_to='images/')
    serves      = models.IntegerField()
    ingredients = models.CharField(max_length=1000)
    instructions= models.CharField(max_length=1000)
    time_period = models.IntegerField()# in minutes
    uploader    = models.CharField(max_length=1, choices=UPLOADER_CHOICES)

def __unicode__(self):
    return self.title

forms.py

from django import forms
from meal.models import Meal

class MealForm(forms.Form):

    title       = forms.CharField(max_length=100)
    image       = forms.ImageField()
    ingredients = forms.CharField(max_length=1000)
    instructions= forms.CharField(max_length=1000)
    time_period = forms.IntegerField(required=False)
    serves      = forms.IntegerField(required=False)

views.py

from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from meal.models import Meal
from meal.forms import MealForm

def upload(request):
    if request.method == 'POST':
        form = MealForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return render_to_response('upload.html', {'form': form})
    else:
        form = MealForm()
    return render_to_response('upload.html', {'form': form}, context_instance=RequestContext(request)
    )

upload.html

{% extends "base.html" %}
{% block content %}
{% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
{% endif %}
<div data-role="content" style="padding: 15px">
    <form action="" method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            {{ form.errors }}
            {{ form.non_field_errors }}
            {{ form.as_table }}
        <input type="submit" value="Submit" id="Save">
    </form>
</div>
{% endblock %}

Does anyone have any ideas about what I could be doing wrong? I feel like I’ve tried everything.

  • 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-12T21:05:16+00:00Added an answer on June 12, 2026 at 9:05 pm

    Okay, so it turned out that it was an issue with jQuery Mobile, which I didn’t mention earlier. All I needed to do was change

    <form action="" method="post" enctype="multipart/form-data">
    

    to

    <form action="" method="post" enctype="multipart/form-data" data-ajax="false">
    

    because jQuery was trying to handle the POST for me. Apparently when you POST to the same URL in Django and want to handle it manually, you must include the

    data-ajax="false"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been banging my head trying to figure out what is going wrong.
I have been going nuts trying to figure this out. I am trying to
I have been going mad trying to figure out why my scripts weren't working,
I have been trying to figure out why I am getting this problem and
I'm working on a web-accessible API and have been trying to figure out the
I have been trying to figure this out for quite a while, but what
I have been struggling trying to figure out this mindbody API for a while
I've been going crazy trying to figure out why this is happening. The problem
I have been trying to figure this out for the past week and everything
Ok, I have been staring at this for hours trying to figure out what's

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.