Opened 12 years ago
Closed 12 years ago
#19405 closed Bug (duplicate)
Long integers cause DatabaseError when submitting ModelForm
Reported by: | Daniil Ryzhkov | 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.
Change History (2)
comment:1 by , 12 years ago
Summary: | Long integers causing DatabaseError when submitting ModelForm → Long integers cause DatabaseError when submitting ModelForm |
---|
comment:2 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The problem is that the maximum value is database-dependent (See #16747). You can initialize IntegerField with
max_value
to prevent this error.