Opened 13 months ago
Last modified 13 months ago
#35019 closed Bug
GeneratedField save error — at Initial Version
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
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): id = models.BigAutoField(primary_key=True) 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.
Note:
See TracTickets
for help on using tickets.