Closed FChikh closed 9 months ago
The "in-class definition" approach can be removed, since the classes are not ordered and this generates problems between relationships.
The "out-class definition" is a valid solution, but it is necessary to modify the template because the code generator should not modify the input model.
The on_delete
parameter in the OneToOneField
relationships of the model is missing and required.
In Django it is not necessary to redefine inherited attributes in child class (in fact an error occurs). For example, the following models will not be well defined:
class LifecycleStage(models.Model):
name = models.CharField(max_length=255)
date = models.DateTimeField()
class Design(LifecycleStage):
name = models.CharField(max_length=255)
date = models.DateTimeField()
other = models.CharField(max_length=255)
The correct way is:
class LifecycleStage(models.Model):
name = models.CharField(max_length=255)
date = models.DateTimeField()
class Design(LifecycleStage):
other = models.CharField(max_length=255)
I provided two template versions to choose between; they present 2 different approaches: in-class definition of relations & out-class; In-class definition has problems with ordering classes in order not to make links to not yet defined classes; Out-class definition has problem with readability of code, as we add constraints to class out of main definition