Thanks, that's just the solution I was looking for! Just out of curiosity, is it also possible to do this for many-to-many relationships?
On Oct 20, 2:09 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Oct 20, 6:07 pm, "Andy Lei" <[EMAIL PROTECTED]> wrote: > > > > > Sorry if this is a repost, i don't think my last message got through: > > I have two models: > > class Reporter(models.Model): > > pass > > > class Article(models.Model): > > reporter = models.ForeignKey(Reporter) > > > Let's say I have the pk of a reporter object. Can I assign the reporter > > attribute of the Article object with just the pk? It seems like a wasted > > database query to do this: > > > r = Reporter.objects.get(pk=pk) > > Article.reporter = r > > Article.save() > > > Is there a way I can do something like this: > > > Article.reporter.pk = r > > Article.save() > > > Thanks a lot, > > > Andy > > Yes you can just do article.reporter_id = pk > -- > DR. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---