Re: reverse ForeignKey

2010-09-26 Thread ionut cristian cucu
2010/9/25 Daniel Roseman : > > > On Sep 25, 9:51 am, ionut cristian cucu wrote: >> I've tried to do something like that: >> class Pacienti_manager(models.Manager): >>   def get_visible(self): >>     return(super(Pacienti_manager, >> self).get_query_set().filter(pacient_id__exact=pacient_id) >> but

Re: reverse ForeignKey

2010-09-25 Thread Daniel Roseman
On Sep 25, 9:51 am, ionut cristian cucu wrote: > I've tried to do something like that: > class Pacienti_manager(models.Manager): >   def get_visible(self): >     return(super(Pacienti_manager, > self).get_query_set().filter(pacient_id__exact=pacient_id) > but still no go, I tried > def queryset(

Re: reverse ForeignKey

2010-09-25 Thread ionut cristian cucu
I've tried to do something like that: class Pacienti_manager(models.Manager): def get_visible(self): return(super(Pacienti_manager, self).get_query_set().filter(pacient_id__exact=pacient_id) but still no go, I tried def queryset(self, request): qs= super(Pacient, self).queryset(request) r

Re: reverse ForeignKey

2010-09-23 Thread Vali Lungu
Hi, You may be interested in this: http://stackoverflow.com/questions/2618893/how-to-filter-queryset-in-changelist-view-in-django-admin, looks like a similar (solved) problem. In short, it's about overriding the queryset() method of ModelAdmin. On Thu, Sep 23, 2010 at 11:33 AM, ionut cristian cuc

Re: reverse foreignkey "add" method using multiple INSERTs

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 02:17 -0800, Andrew Ingram wrote: > Hi All, > > I'm using something along the following lines to bulk add a bunch of > objects to a model's reverse foreignkey relationship: > > foo.bar_set.add(*bars) > > where bars is a list of Bar objects. > > I've noticed that Django is

Re: Reverse ForeignKey lookups

2006-12-19 Thread Rob Slotboom
Hi Cathy, Chris is right. User in entrystatus is a relation to User. This isnt't the same as a 'normal' field like Name or Title. Look at these: Entry.objects.filter(blog__id__exact=3) # Explicit form Entry.objects.filter(blog__id=3) # __exact is implied Entry.objects.filter(blog__pk=3) # __pk i

Re: Reverse ForeignKey lookups

2006-12-19 Thread Cathy Young
Chris Ryland wrote: > One more stab: > > On Dec 19, 11:16 am, "Cathy Young" <[EMAIL PROTECTED]> wrote: > > I'm having trouble with generating a QuerySet using a reverse > > ForeignKey lookup, and I'm not sure why I'm getting an error. > > > > Here is my model, with only the relevant attributes sho

Re: Reverse ForeignKey lookups

2006-12-19 Thread Chris Ryland
One more stab: On Dec 19, 11:16 am, "Cathy Young" <[EMAIL PROTECTED]> wrote: > I'm having trouble with generating a QuerySet using a reverse > ForeignKey lookup, and I'm not sure why I'm getting an error. > > Here is my model, with only the relevant attributes shown: > > def EntryStatus(models.Mo

Re: Reverse ForeignKey lookups

2006-12-19 Thread Chris Ryland
On Dec 19, 3:05 pm, "Chris Ryland" <[EMAIL PROTECTED]> wrote: >>> Entry.entrystatus_set.filter(entrystatus__user=3) > since the ForeignKey is on the EntryStatus model rather than the Entry > model. Nope, let me correct myself: according to the docs, what you want to do should work. I officially d

Re: Reverse ForeignKey lookups

2006-12-19 Thread Cathy Young
Chris Ryland wrote: > I'm a relative Django newbie, but I think you need to use something > like > > >> Entry.entrystatus_set.filter(entrystatus__user=3) > > since the ForeignKey is on the EntryStatus model rather than the Entry > model. Thanks Chris, but as far as I know you can't use entrystat

Re: Reverse ForeignKey lookups

2006-12-19 Thread Chris Ryland
On Dec 19, 2:08 pm, "Cathy Young" <[EMAIL PROTECTED]> wrote: > class Entry(models.Model): > guid = models.CharField(maxlength=250,primary_key=True) > permalink = models.URLField() > title = models.CharField(maxlength=300,default="Untitled entry") > author = models.CharField(maxlen

Re: Reverse ForeignKey lookups

2006-12-19 Thread Cathy Young
Chris Ryland wrote: > On Dec 19, 11:16 am, "Cathy Young" <[EMAIL PROTECTED]> wrote: > > > Here is my model, with only the relevant attributes shown: > > > > def EntryStatus(models.Model): > > ... > > user = models.ForeignKey(User) > > entry = models.ForeignKey(Entry) > > > > where Entr

Re: Reverse ForeignKey lookups

2006-12-19 Thread Chris Ryland
On Dec 19, 11:16 am, "Cathy Young" <[EMAIL PROTECTED]> wrote: > Here is my model, with only the relevant attributes shown: > > def EntryStatus(models.Model): > ... > user = models.ForeignKey(User) > entry = models.ForeignKey(Entry) > > where Entry is another of my models and User is D