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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:53:10+00:00 2026-05-21T23:53:10+00:00

I have used forms of Django in this manner and have got an error:

  • 0

I have used forms of Django in this manner and have got an error:
Error:invalid literal for int() with base 10: 'check‘

#this is forms.py    
from django import forms

    class PersonalInfo(forms.Form):
        Name = forms.CharField(max_length=20)
        Email_ID = forms.EmailField(required=False)
        Address = forms.CharField(max_length=50,required=False)
        Contact_Phone =  forms.CharField(max_length=20)
        Image = forms.FileField(required=False)

The PersonalInfo is used in register.html

#This is view.py, register calling register.html
    def register(request):
        form = PersonalInfo()
        return render_to_response('register.html', {'form':form}, context_instance=RequestContext(request))

In register.html this is the way I will use it :

            {% if form.errors %}
            <p style="color: red;">
                Please correct the error{{ form.errors|pluralize }} below.
            </p>
            {% endif %}

            <form action="/uregister/" method="post">
                <table>
                    {{ form.as_table }}
                </table>
                <input type="submit" value="Submit">
            </form>

This is views of uregister:

def uregister(request):
    if request.method == 'POST':
    form = PersonalInfo(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
                per_job = Personal(cd['Name'], cd['Email_ID'], cd['Address'], cd['Contact_Phone'], cd['Image'])
                per_job.save()
                return HttpResponseRedirect('/')
        else:
            form = PersonalInfo()
            return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request))

This is the Personal model in models.py:

class Personal(models.Model):
    name = models.CharField(max_length=20)
    email = models.EmailField(blank=True,null=True)
    address = models.CharField(max_length=50,blank=True,null=True)
    contact =  models.CharField(max_length=20)
    pic = models.FileField(upload_to='image/',blank=True,null=True)

The error I get is :

invalid literal for int() with base 10: 'check'

and

Exception Type: ValueError
Exception Value:    invalid literal for int() with base 10: 'check'
Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/models/fields/__init__.py in get_prep_value, line 479

Check is the name I had given as in dummy data.
Can anyone tell me where i am going wrong? Please.

Update:
Trace

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/nagaraj/ghar/gharnivas/views.py" in uregister
  49.                 per_job.save()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save
  460.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save_base
  522.                         manager.using(using).filter(pk=pk_val).exists())):
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py" in filter
  550.         return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py" in _filter_or_exclude
  568.             clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py" in add_q
  1172.                             can_reuse=used_aliases, force_having=force_having)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py" in add_filter
  1107.                 connector)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/where.py" in add
  67.             value = obj.prepare(lookup_type, value)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/where.py" in prepare
  316.             return self.field.get_prep_lookup(lookup_type, value)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/__init__.py" in get_prep_lookup
  292.             return self.get_prep_value(value)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/__init__.py" in get_prep_value
  479.         return int(value)

Exception Type: ValueError at /uregister/
Exception Value: invalid literal for int() with base 10: 'check
  • 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-21T23:53:11+00:00Added an answer on May 21, 2026 at 11:53 pm

    I think the problem is in line

    per_job = Personal(cd['Name'], cd['Email_ID'], cd['Address'], cd['Contact_Phone'], cd['Image'])
    

    I don’t know if it’s possible to create a model instance with only positional parameters, but it’s not mentioned in the docs. You should be using keyword parameters:

    per_job = Personal(name=cd['Name'], email=cd['Email_ID'], etc.
    

    The error you’re seeing probably results from trying to assing non-integer value to the default database field with object ID, so it might be caused by this.


    Regarding the other things:

    • Image is not stored probably because you’re not using form attribute enctype="multipart/form-data" which is required for correctly processing uploaded files.
    • The errors are not displayed most probably because they’re contained in the form after validation, and you’re replacing that with an empty instance in else: branch of your uregister view.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used Django forms. I have this function in views.py : def func(request): if
I used Django's generic createview for my model from myproject.app.forms import PersonForm class PersonMixin(object):
I have this custom JSlider, which will be used in many other forms/windows. But
Up until now I have used the django template system to perform this kind
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
How to make the forms non scrollable in sencha touch? I have not used
I have an application where the System.Windows.Forms.ColorDialog dialog box is used as a color
I have a problem in customizing labels in a Django form This is the
Coming from frameworks like Django and RoR I am used to show and handle
I'm currently working on a project where we previously used Django. However this proved

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.