what is the use of the article foreignkey in the UserProfile model?

On Tue, Aug 23, 2011 at 2:34 PM, raj <nano.ri...@gmail.com> wrote:

> nvm, I think i'm starting to figure it out. Need to read up on many-to-
> many fields.
>
> On Aug 23, 2:21 am, raj <nano.ri...@gmail.com> wrote:
> > This may be difficult to explain. I'm a little new to django and the
> > whole idea of models.
> >
> > Let's say I'm making an article app, where each article has a creator,
> > but other users can edit the article at will. I'm having a little
> > difficult on how to create the models for this.
> >
> > Firstly, I extend the user profile with the following:
> >
> > class UserProfile(models.Model):
> >     #Required field:
> >     user = models.OneToOneField(User)
> >
> >     #Other Fields:
> >     headline = models.CharField()
> >     industry = models.CharField()
> >     article= models.ForeignKey(articleModel.article)
> >
> > Here is the first place I'm getting confused, do I put the foreignkey
> > field in the user model? My reasoning for it being placed here is
> > because each article can have many editors.
> >
> > Now here is my article model:
> >
> > class article(models.Model):
> >     #primary key is already true
> >     creator = models.ForeignKey(userModel.UserProfile)
> >     title = models.CharField()
> >     text = models.TextField()
> >
> > Over here, I put the ForeignKey field so it would relate back to the
> > creator, because every article has a single creator. (As a side note,
> > I do want to make it so an article can have multiple creators, but I
> > don't know what to do in this scenario). I'm finding it a bit odd that
> > the UserProfile model is referencing the article model, and the
> > article is referencing it back. Can someone please help me unjumble my
> > brain?
> >
> > Thank you. :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to