BESSER-PEARL / BESSER

A Python-based low-modeling low-code platform for smart software
https://besser.readthedocs.io/en/latest/
MIT License
46 stars 11 forks source link

alpha version of django models generator #34

Closed FChikh closed 9 months ago

FChikh commented 10 months ago

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

ivan-alfonso commented 10 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.

ivan-alfonso commented 9 months ago
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)