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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:03+00:00 2026-06-14T14:51:03+00:00

I have a form with 11 fields and one image upload field. After filling

  • 0

I have a form with 11 fields and one image upload field. After filling in and hitting submit, I’m given a TypeError saying that an integer is required. this error doesn’t come up if i remove the imagefield. checking the image directory, the files are saved to the server before the error is thrown.

Forms.py:

class ListingForm(ModelForm):
    seller_email = forms.EmailField(max_length="", required=True, widget=forms.TextInput(attrs={'placeholder': "jsmith@stevens.edu"}))  
    title = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder':"The Cat in the Hat"}))
    edition = forms.IntegerField(required=True, widget=forms.TextInput(attrs={'placeholder':"5"}))
    author = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder':"Dr. Seuss"}))
    isbn = forms.CharField(label="ISBN", required=True, widget=forms.TextInput(attrs={'placeholder':"9780717260591"}))
    price = forms.FloatField(required=True, widget=forms.TextInput(attrs={'type':"number", 'placeholder':"50.00"}))
    classcode= forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder':"MA115"}))
    #description = forms.CharField(widget=forms.TextArea(attrs={'placeholder':"You should buy this because..."}))
    condition = forms.ChoiceField(required=True, widget=forms.Select(), choices=([(4,"New"), (3,"Good"), (2,"Fair"), (1,"Poor")]))
    seller_name = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder':"John Doe"}))
    seller_phone = forms.CharField(widget=forms.TextInput(attrs={'placeholder':"(555) 555-1234"}))

    picture = forms.ImageField(widget=forms.FileInput('accept':"image/*"))
    #picture = forms.ImageField()
    uuid = forms.CharField(widget=forms.HiddenInput(), initial=uuid.uuid4())
    timeposted = forms.CharField(widget=forms.HiddenInput(), initial=datetime.now())
    sale_status = forms.BooleanField(widget=forms.HiddenInput(), initial=True)



    class Meta:
        model = Listing
        fields = ('seller_email', 'title', 'edition', 'author', 'isbn', 'price', 'classcode', 'description', 'condition', 'seller_name', 'seller_phone', 'picture', 'uuid', 'timeposted', 'sale_status')
        #exclude = ("uuid", "timeposted", "sale_status", "picture", "school")

Views.py:

from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import Context, loader, RequestContext
from django.contrib.auth.models import User 
from cbt.accounts.models import School, UserProfile
from cbt.listings.models import Listing
from django.contrib import auth
from django.core.context_processors import csrf
from django.core.mail import send_mail
from django.core.files import File
from datetime import datetime
from cbt.settings import MEDIA_ROOT
from cbt.listings.forms import ListingForm

school_list = School.objects.all().order_by('name')

def add(request):

    form = ListingForm()
    if request.method == 'POST':
        form = ListingForm(request.POST, request.FILES)
        if form.is_valid() and form.is_multipart():
            form.save()
            return HttpResponseRedirect(reverse('cbt.views.home'))      

    return render_to_response('listings/add.html', {'school_list':school_list, 'form':form}, context_instance=RequestContext(request))

Here is the exact error code:

Environment:



Request Method: POST
Request URL: http://alligator.collegebooktrade.info/listings/add/

Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'cbt.accounts',
 'cbt.listings')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/cbt/cbt/listings/views.py" in add
  25.           form.save()
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in save
  364.                              fail_message, commit, construct=False)
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in save_instance
  86.         instance.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
  463.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
  551.                 result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in _insert
  203.         return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in insert_query
  1576.     return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  909.         for sql, params in self.as_sql():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in as_sql
  872.                 for obj in self.query.objs
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in pre_save
  249.             file.save(file.name, file, save=False)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in save
  86.         self.name = self.storage.save(name, content)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py" in save
  45.         name = self._save(name, content)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py" in _save
  212.             os.chmod(full_path, settings.FILE_UPLOAD_PERMISSIONS)

Exception Type: TypeError at /listings/add/
Exception Value: an integer is required

EDIT: As requested:

Model:
class Listing(models.Model):
title = models.CharField(max_length="100")
edition = models.CharField(max_length="5")
author = models.CharField(max_length="50")
isbn = models.CharField(max_length="13")
price = models.FloatField()
classcode = models.CharField(max_length="12")
description = models.CharField(max_length="400")
condition = models.CharField(max_length="10")
#school = models.OneToOneField(School)
school = models.CharField(max_length="36")

picture = models.ImageField(upload_to="listings")

#CONTACT INFO:
seller_name = models.CharField(max_length="30")
seller_phone = models.CharField(max_length="11")
seller_email = models.EmailField(max_length="75")

uuid = models.CharField(max_length="36")
timeposted = models.DateTimeField()
sale_status = models.BooleanField() #0 for sale, 1 for sold

Settings.py:

#just including pertinent settings...
FILE_UPLOAD_PERMISSIONS '0760'
FILE_UPLOAD_HANDLERS  ('django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler')
MIDDLEWARE_CLASSES  ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware')
FILE_UPLOAD_MAX_MEMORY_SIZE  '2621440'
  • 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-14T14:51:05+00:00Added an answer on June 14, 2026 at 2:51 pm

    In your settings.py script, you have this line:

    FILE_UPLOAD_PERMISSIONS '0760'
    

    It should not have quotes around it. You are trying to call os.chmod() with a string as the second argument when it expects an integer. Specifically, the octal permissions value. In python, numbers with a leading 0 are automatically considered to be octal values and are converted to integers. So, just use this line instead:

    FILE_UPLOAD_PERMISSIONS = 0760
    

    By the way, why aren’t you using equals signs in your settings.py?

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

Sidebar

Related Questions

I have a form and one of the fields is a check-all-that-applies type field
I have an InfoPath form with several fields on, the problem is that one
I have a form that includes text string fields and file upload fields (for
When I submit the form without filling in one of the required fields( or
I have form containing many input fields. But I need to take one field
Currently I have a model 'Locations' that has an image upload field added to
I have one form with several text fields and one button. When i enter
I had developed one website purely in HTML .I have my form with fields
I have a form with 3 fields (simplyfied example). The first one is a
I have a Symfony2 form with a variety of fields, including one optional text

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.