orm

Django Rest Framework- retrieving a related field on reverse foreign key efficiently

纵饮孤独 提交于 2020-07-05 10:26:30
问题 I have the following models that represent a working group of users. Each working group has a leader and members: class WorkingGroup(models.Model): group_name = models.CharField(max_length=255) leader = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) class WorkingGroupMember(models

Django Rest Framework- retrieving a related field on reverse foreign key efficiently

让人想犯罪 __ 提交于 2020-07-05 10:25:20
问题 I have the following models that represent a working group of users. Each working group has a leader and members: class WorkingGroup(models.Model): group_name = models.CharField(max_length=255) leader = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) class WorkingGroupMember(models

Database Model's meta data should be defined in models file or migration file?

拈花ヽ惹草 提交于 2020-06-28 06:57:12
问题 Using sequelize init I generated a model with a migration. Inside model.js there is only the definition of the type of each attribute, e.g. const User = sequelize.define('User', { firstName: DataTypes.STRING, lastName: DataTypes.STRING, email: DataTypes.STRING, password: DataTypes.STRING }, {});