Code

#19405 closed Bug (duplicate)

Long integers cause DatabaseError when submitting ModelForm

Reported by: Daniilr Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords: form, admin, DatabaseError, ModelForm
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Let's say there is a model:

class TestModel(models.Model):
    test_field = models.IntegerField()

And ModelForm (instread of this step you can just register model in admin):

class TestForm(forms.ModelForm):

    class Meta:
        model = TestModel

And view:

def test_view(request):
    ...
    if form.is_valid():
        ad.save()

When from is submitted Django returns "DatabaseError: current transaction is aborted, commands ignored until end of transaction block" if submitted integer is above 2147483647 (which is database maximum value for integer). This affects both contrib.admin generated form and ModelForm.
This was tested on Django 1.4 with Debian Squeeze and PostgreSQL 9.1 aboard.

Attachments (0)

Change History (2)

comment:1 Changed 20 months ago by Daniilr

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Long integers causing DatabaseError when submitting ModelForm to Long integers cause DatabaseError when submitting ModelForm

comment:2 Changed 20 months ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

The problem is that the maximum value is database-dependent (See #16747). You can initialize IntegerField with max_value to prevent this error.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.