Hi there, I don't know if I put the right title, so here is what I'm stuck 
with:
I have this model:

> class Foo(models.Model):
>     name = models.CharField(...) 


this one:

> class Bar(models.Model):
>      name = models.CharField(....)


And their connection:

> class FooBar(models.Model):
>     foo = models.ForeingKey(Foo, related_name='bars')
>     bar = models.ForeingKey(Bar, related_name='foos')

    some_other_value = ..... 


And wanted to know how can I(if possible) do something that has the same 
result as this code:

> f = Foo.objects.get(name='some foo')
> b = Bar.objects.get(name='nice bars')
> my_nice_bars = f.bars.filter(bar = b)


but without having to do the *"b = Bar.objects.get(name='nice bars')" *like 
this:

> f = Foo.objects.get(name='some foo')
> my_nice_bars = f.bars.get_by_name('nice bars')


Or even do a more complex query then "get_by_name".
Can I add this new query to the Foo.bars stuff?

I tried the *QueryManager* from 
django-model-utils<https://bitbucket.org/carljm/django-model-utils/overview>, 
and added a new query to *Bar*, but this couldn't be used in* Foo.bars*
*
*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uH4ZLL9B0dUJ.
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