[Answered ]-How to conditionally save a form using django multi table inheritance

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()
👤Rohan

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)

Leave a comment