Opened 12 months ago
Last modified 12 months ago
#35019 closed Bug
GeneratedField save error — at Version 3
Reported by: | Deb Kumar Das | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Release blocker | Keywords: | GeneratedField save error |
Cc: | Lily Foote, Jeremy Nauta | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When using GeneratedField column along with a ForeignKey column, getting error while saving.
The below model throws error while saving data from admin panel.
class Square(models.Model): side = models.IntegerField() area = models.GeneratedField( expression=F("side") * F("side"), output_field=models.BigIntegerField(), db_persist=True, ) user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
Throws the below error
Cannot force an update in save() with no primary key.
attached error screenshot
Change History (4)
by , 12 months ago
Attachment: | django_error.PNG added |
---|
comment:1 by , 12 months ago
Component: | Uncategorized → Database layer (models, ORM) |
---|
comment:2 by , 12 months ago
Description: | modified (diff) |
---|
comment:3 by , 12 months ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.