Opened 8 years ago
Closed 8 years ago
#28950 closed Bug (fixed)
ArrayField.has_changed() returns True for unchanged fields
| Reported by: | tejinderss | Owned by: | vinay karanam |
|---|---|---|---|
| Component: | contrib.postgres | Version: | 1.11 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have models Foo and Bar for example:
from django.contrib.postgres.fields import ArrayField
class Foo(models.Model):
field = models.CharField(max_length=200)
class Bar(models.Model):
foo = models.OneToOneField(Foo)
required_field = models.CharField(blank=False)
array_field = ArrayField(models.CharField(max_length=50, blank=true), blank=True, null=True)
and in the admin.py i have:
class BarInline(admin.StackedInline):
model = Bar
@admin.register(Foo)
class FooAdmin(admin.ModelAdmin):
inlines = [BarInline]
Now the issue is on the save form in admin, if i try to create foo instance without providing any bar data in barinline form, i get error that bar's required field is required and if i make all fields optional, it creates the bar instance anyway without any data. I have played with min_num and max_num but in vain.
Attachments (1)
Change History (8)
by , 8 years ago
| Attachment: | Capture.PNG added |
|---|
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 8 years ago
comment:4 by , 8 years ago
| Description: | modified (diff) |
|---|
This bug seems to be valid only when the postgres arrayfield is used in the inline model
comment:5 by , 8 years ago
| Component: | Uncategorized → contrib.postgres |
|---|---|
| Summary: | Model with OnetoOneFeild inline in admin cannot be created → ArrayField.has_changed() returns True for unchanged fields |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
The problem is ArrayField.has_changed() returning True even though the field wasn't modified.
comment:6 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
I've raised a PR implementing necessary changes.
I can't reproduce the issue given the minimal models and admin that you provided.