Reverse relation

2009-06-03 Thread Jaco Niko
The model's code is below. First thing I need is to retrieve all the places that are labelled e.g. "tea". So I just create a view a type: places = Place.objects.all() places = Place.objects.filter(primary_tags__name__contains="tea") But then additionally I need all the places that are open now,

Disabling reverse relation

2009-06-04 Thread Mattias Brändström
Hello! I'm trying to figure out if it is possible to disable the creation of a reverse relation field when defining relations between models. Something like this example: class Route(models.Model): start = models.ForeignKey (Location, related_name='starting_points&#x

Multitable inheritance - reverse relation

2010-05-27 Thread bohemian
Hello! I have model A in which there is field ForeignKey(B). I also have model C which inherits from model A. None of these models is abstract. Having B object, can I find all C objects pointing to it? When I use something like this: Bobject.C_set.all() there appears an error: 'AttributeError: B o

bypassing reverse relation (related_name)

2007-10-17 Thread Joe Holloway
I'm finding that I have quite a few many-to-one relations that don't really need the reverse relation to be expressed in the object model. For example, class Route(models.Model): start = models.ForeignKey (Location) destination = models.ForeignKey (Location) The default re

ForeignKey Reverse Relation Fail

2022-07-27 Thread Malik Rumi
I have a model with a recursive foreign key to 'self'. This is intended to model a parent child relation among instances. The forward relation, on a field called 'childof', works as expected. The reverse relation, using the related_name 'parent', comes up as a Rel

Re: Multitable inheritance - reverse relation

2010-05-27 Thread Scott Gould
Try: myB = B.objects.get(pk=1) myCs = C.objects.filter(a__b=myB) Regards Scott > I have model A in which there is field ForeignKey(B). I also have > model C which inherits from model A. None of these models is abstract. > Having B object, can I find all C objects pointing to it? When I use > som

Re: Multitable inheritance - reverse relation

2010-05-27 Thread bohemian
I haven't think about it this way. It works (using "a_ptr__b"). Thank you for help Scott! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send em

Re: bypassing reverse relation (related_name)

2007-10-17 Thread RajeshD
> > Is there a way to express that I don't need the reverse relation? No. Even if you don't need them, Django will want to dynamically endow your Location objects with them. And, as you know, it can't do it if two reverse relatio

Re: ForeignKey Reverse Relation Fail

2022-07-27 Thread Ammar Mohammed
27;childof', works as expected. > The reverse relation, using the related_name 'parent', comes up as a > RelatedManager, > again as expected. However, parent.count(), parent.all(), etc., always > give me the "Manager is > not accessible on instances" error. Ma

Re: ForeignKey Reverse Relation Fail

2022-07-27 Thread Malik Rumi
n >> the model, would that work? >> Presumably the related name on the childof field would still fail like it >> does now, >> but I would instead have the explicit parent field to work with. I still >> would not have the >> automatic reverse relation

Re: ForeignKey Reverse Relation Fail

2022-07-31 Thread Ryan Nowakowski
ldof', works as expected. The reverse relation, using the related_name 'parent', comes up as a RelatedManager, again as expected. However, parent.count(), parent.all(), etc., always give me the "Manager is not accessible on instances" error. Many of these parent instances

Re: ForeignKey Reverse Relation Fail

2022-07-31 Thread Ammar Mohammed
n 27 Jul 2022 12:18, "Malik Rumi" wrote: >> >>> I have a model with a recursive foreign key to 'self'. This is intended >>> to model a parent child >>> relation among instances. The forward relation, on a field called >>> 'childo

Re: Reverse relation lookups with multidb

2015-10-24 Thread probleem support
we also tried without _set etc. -- 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 d

Re: Reverse relation lookups with multidb

2015-10-24 Thread Tim Graham
I don't think this has anything to do with multi-db. I'm not sure what that query is trying to accomplish. Can you simply use: ProfielenUserprofile.objects.values('profielnaam') You can't use values() across a reverse ForeignKey ("foo_set") as this might return multiple values. On Saturday,

Re: Reverse relation lookups with multidb

2015-10-24 Thread probleem support
> > nieuweklanten = ProfielenUserprofile.objects.all()[:1] >> for nieuwe in nieuweklanten: >> print(nieuwe.user.profielenprofielen.profielnaam) >> >> >> this for example works fine >> > but doing the same thing but then like this with works fine on i do a similar test on the default db but i

Re: Reverse relation lookups with multidb

2015-10-24 Thread probleem support
same for nieuweklanten = ProfielenUserprofile.objects.values('user__profielenprofielen__profielnaam')[:1] for nieuwe in nieuweklanten: print(nieuwe['user__profielenprofielen__profielnaam']) -- You received this message because you are subscribed to the Google Groups "Django users" group

Re: Reverse relation lookups with multidb

2015-10-24 Thread probleem support
this worked fine in django 1.6.1 but fails in 1.8.5 -- 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 g

Re: Reverse relation lookups with multidb

2015-10-24 Thread Tim Graham
It would be helpful if you could create a minimal example project (without unnecessary fields and methods) with a test that passes on Django 1.6 but fails on Django 1.8. On Saturday, October 24, 2015 at 9:13:42 AM UTC-4, probleem support wrote: > > this worked fine in django 1.6.1 but fails in

Re: Reverse relation lookups with multidb

2015-10-24 Thread probleem support
working on that -- 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@goog

Re: Reverse relation lookups with multidb

2015-10-27 Thread probleem support
test project proving my point https://github.com/gerdkoetje/dualdbtest -- 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.

Re: Reverse relation lookups with multidb

2015-10-27 Thread Tim Graham
As noted on the ticket, it looks like you're missing an app in INSTALLED_APPS. On Tuesday, October 27, 2015 at 10:55:51 AM UTC-4, probleem support wrote: > > test project proving my point > https://github.com/gerdkoetje/dualdbtest > -- You received this message because you are subscribed to the

Re: Reverse relation lookups with multidb

2015-10-27 Thread probleem support
Tim in my real project that database is a remote database, that shouldn't be in installed apps shouldn't it. but to prove my point it did it with 2 local databases in the test project. in my real project i can't do reverse lookups on the remote database models. -- You received this message beca

Re: Reverse relation lookups with multidb

2015-10-27 Thread Tim Graham
In order to use models and their relations you have to include them in INSTALLED_APPS regardless of which database they are stored in. This is noted in the 1.7 release notes: https://docs.djangoproject.com/en/1.8/releases/1.7/#app-registry-consistency Maybe you don't want your local project to

Re: Reverse relation lookups with multidb

2015-10-27 Thread probleem support
Thanks a lot tim, this has resolved the issue. Lesson learned to jump from 1.6 to 1.8 go release by release. then i would probably seen it. Appreciated ur help do! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group a

How to delete a OneToOneField reverse relation?

2015-12-19 Thread Evan Heidtmann
My question is very similar to one by Seth Gordon in 2011. But it's been 4 years since then, so I'll try again. I have models A and B, and B has a O2O field pointing to A. When I do `a.b.delete()`, then I'm surprised to find that `a.b` is still a valid object. How can I modify `a` so that it retur

Re: How to delete a OneToOneField reverse relation?

2015-12-19 Thread James Schneider
I believe that delete() only deletes the reference to the object in the database, but does not affect the calling object in memory. I think the reason for this is so that you can perform a delete operation, and if successful, gather information about the deleted object to display a confirmation m

Can't edit reverse relation in a many2many field in admin site

2008-12-04 Thread Nelson
the 'include/exclude list box' that shows all the Records, so the user can choose the ones that the Track may belong to. What do I need to do to show this 'reverse' relation in the Track form page? --~--~-~--~~~---~--~~ You received this message

Annotate on a FK reverse relation gives FieldError: Cannot resolve keyword

2010-09-17 Thread martync
Hi, I am experiencing an issue on annotate function only on my production site only when executing the code on a normal navigation (the shell command on production has no problem). This is the pseudo code : # models class Competition(model): title = char published = bool date = date

Re: Can't edit reverse relation in a many2many field in admin site

2008-12-05 Thread anode
27;tracks',) in the ModelAdmin of the Record. > > However, the Track admin page DOES NOT show the 'reverse' of the many- > to-many relation. I mean, I want to display the 'include/exclude list > box' that shows all the Records, so the user can choose the ones tha

Re: Can't edit reverse relation in a many2many field in admin site

2008-12-06 Thread Nelson Altimari
Thank you so very much!! It worked exactly like I wanted. I had been through the django tickets, but since this ticket has no keywords, I wasn't able to find it... It's sad to see that this is being going on for nearly 3 years!!! In my case, I had my tables 'syncdb'ed already, so it was not an iss