Thanks Daniel!

I try to always RTFM, but this slipped by me.

On Thu, Nov 21, 2013 at 5:32 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Wednesday, 20 November 2013 22:49:28 UTC, Thomas Murphy wrote:
>>
>> Hi all,
>>
>> I'm working on a hour-reporting system.
>>
>> Each Project has many Users, and each User has many Projects(These are
>> established and working nicely).
>>
>> My design issue is this:
>> How can I assign each User an IntegerField "Hours" on each Project
>> they are assigned to? This Integer Field is personal to them, but must
>> be able to summed by the Project "Hours" count later(This last part is
>> trivial to design, just wanted to include)
>>
>> Here's relevant code:
>>
>> class Project(models.Model):
>>     client = models.CharField(max_length=500)
>>     name = models.CharField(max_length=500)
>>     campaign_start_date = models.DateField()
>>     hours = models.IntegerField(default=0)
>>     members = models.ManyToManyField(User)
>>     hours = models.IntegerField(default=0)
>>
>>     def __unicode__(self):
>>     return self.name
>>
>> class UserProfile(models.Model):
>>
>>     user = models.OneToOneField(User)
>>
>>     #Additional Attributes Defined Below
>>     project = models.ManyToManyField(Project)
>>     rate = models.IntegerField(default=0)
>>
>>     def __unicode__(self):
>>         return self.user.username
>>
>>     def project_names(self):
>>         return ', '.join([p.name for p in self.project.all()])
>
>
>
> This is well covered in the documentation under "Extra fields on
> many-to-many relationships":
> https://docs.djangoproject.com/en/1.6/topics/db/models/#intermediary-manytomany
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6e6d5b33-ce10-4dac-b2e1-a7f64c8ada7e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALgvumUvfyLmrhRxMCPw%3DrSitQN0jLo%3DTSpkR%3Dfr4B%3DvRnQ%2BEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to