Is it possible to update_or_create on a mptt model?

48 views
Skip to first unread message

Z

unread,
Feb 26, 2019, 2:33:28 AM2/26/19
to django-mptt-dev
Is it possible to update_or_create on a mptt model? I tried using the normal django methods but it didn't seem to work, is there a way around this?

I tried:
```RentableSpace.objects.update_or_create(name="Building1", 
    ...: address=address_ins, space_type="Complex", ref_code="SG_SK")```

Which resulted in this error:
```IntegrityError: duplicate key value violates unique constraint "properties_rentablespace_name_space_type_address__c521cc02_uniq"
DETAIL:  Key (name, space_type, address_id)=(Building1, Complex, 6bzfdSuuyADVNr2X) already exists.```
Reply all
Reply to author
Forward
0 new messages