[Patchew-devel] [PATCH 06/12] models: create Result model

Paolo Bonzini pbonzini at redhat.com
Tue May 22 14:57:43 UTC 2018


On 22/05/2018 10:11, Fam Zheng wrote:
> On Tue, 05/22 08:57, Paolo Bonzini wrote:
>> @@ -58,6 +140,7 @@ class Project(models.Model):
>>                                         top project which has
>>                                         parent_project=NULL""")
>>      maintainers = models.ManyToManyField(User, blank=True)
>> +    results = models.ManyToManyField(Result, blank=True)
>>  
>>      def __str__(self):
>>          return self.name
>> @@ -319,6 +402,7 @@ class Message(models.Model):
>>      num_patches = models.IntegerField(null=False, default=-1, blank=True)
>>  
>>      objects = MessageManager()
>> +    results = models.ManyToManyField(Result, blank=True)
> Why ManyToMany relationship? A Result entry belongs to exactly one Project or
> Message, just like Property, no?

Yes, however I wanted to avoid the same issue like we have with
properties, where we need two classes ProjectProperty or MessageProperty
for basically the same model.  And if I add a OneToManyField, I'll have
two database fields in the api_result table (for the project_id and the
message_id).

It's not great but I don't have a better idea, it's the best I could do
(start) on a plane without StackOverflow. :)  That's also why the series
is RFC.

Paolo




More information about the Patchew-devel mailing list