2👍
✅
It is related to Django model inheritance: create sub-instance of existing instance (downcast)? which suggests how to add object with existing base class object.
You may want to look at my question: Derived model filefield not available
In nutshell what you have to do is
restaurant = Restaurant(place_ptr_id=place.id)
restaurant.__dict__.update(place.__dict__)
restaurant.save()
0👍
You can add null=True
and blank=True
.
models:
class Place(models.Model):
customer = models.ForeignKey(Customer, null=True, blank=True)
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
- [Answered ]-How to DRY up my models
- [Answered ]-Select all records from the parent table assuming something is present in the child
- [Answered ]-ModelForm has no model class specified
- [Answered ]-Django forms.py initialized wrongly?
Source:stackexchange.com