Re: Django Model related_name

2022-09-08 Thread Toshar Saini
when you want to fetch multiple objects from reverse relation(foriengkey) On Tue, Sep 6, 2022 at 3:51 PM Justin Kpakpa wrote: > Hello, pls under what circumstances do you need to defined a related_name > of a model field? > > -- > You received this message because you are su

Re: Django Model related_name

2022-09-06 Thread DJANGO DEVELOPER
when you want to fetch multiple objects from that model ( having a foreign key relation) On Tue, Sep 6, 2022 at 3:21 PM Justin Kpakpa wrote: > Hello, pls under what circumstances do you need to defined a related_name > of a model field? > > -- > You received this message

Django Model related_name

2022-09-06 Thread Justin Kpakpa
Hello, pls under what circumstances do you need to defined a related_name of a model field? -- 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 dj

Is the document not consistent for related_name?

2021-06-23 Thread ihc...@gmail.com
`%(model_name)s` is recommended in the document default_related_name <https://docs.djangoproject.com/en/3.2/ref/models/options/#default-related-name> but `%(class)s ` is recommended in the document Be careful with related_name and related_query_name <https://docs.djangoproject.c

Re: Why are foreign keys rewritten when adding related_name?

2019-03-04 Thread Hanne Moa
some option changes. > > Are you experiencing this on 2.1 and 2.2 pre release? > > Simon > > Le vendredi 1 mars 2019 02:40:01 UTC-5, HM a écrit : >> >> I added "related_name" to an exiting ForeignKey and checked with >> "django-admin sqlmigrate" w

Re: Why are foreign keys rewritten when adding related_name?

2019-03-01 Thread Simon Charette
Hello HM, I know that some changes have been made to avoid unnecessary foreign key rebuilds on some option changes. Are you experiencing this on 2.1 and 2.2 pre release? Simon Le vendredi 1 mars 2019 02:40:01 UTC-5, HM a écrit : > > I added "related_name" to an exiting Foreig

Why are foreign keys rewritten when adding related_name?

2019-02-28 Thread Hanne Moa
I added "related_name" to an exiting ForeignKey and checked with "django-admin sqlmigrate" what would be done. It seems that the foreign key constraint is dropped, then the exact same constraint is added back. Why? Example: If we have the classes: class Wall(models.Mo

Filter data in related_name loop

2017-10-11 Thread tango ward
Hi guys, I've been scratching my head on this one. I want to know if it's possible to filter the data of models class with related_name in a foor loop? Basically, I want to show the members info associated to a Team. models.py class Team_Region(models.Model): name = models

related_name for two models which have same name but belong to different app

2016-11-28 Thread Xueguang Yang
Hi: I am a little confused about this section of django official docs: Be careful with related_name <https://docs.djangoproject.com/en/1.9/topics/db/models/#be-careful-with-related-name> when you are using related_name in an abstract base class (only), part of > the name shoul

Re: ManyToManyField('self') not using related_name

2016-07-19 Thread Farhan Khan
whose target is a 'self' reference, but it > does not create a related_name "reverse" field. > > Here is my model: > > class SecurityGroup(models.Model): > name = models.CharField(max_length=100) > description = models.TextField() > subgr

ManyToManyField('self') not using related_name

2016-07-19 Thread Farhan Khan
I am using a ManyToManyField whose target is a 'self' reference, but it does not create a related_name "reverse" field. Here is my model: class SecurityGroup(models.Model): name = models.CharField(max_length=100) description = models.TextField() subgroups = mo

Re: The related_name of ForeignKey cannot be Unicode name after Django 1.8

2015-06-22 Thread Cheng-Hung Hsueh
I have posted in https://code.djangoproject.com/ticket/25016#ticket . Tim Graham於 2015年6月23日星期二 UTC+8上午12時30分48秒寫道: > > It looks like the check added in ticket #22064 may be too strict (only > allowing alphanumeric characters in related_name). Would you like to open a > ticket? &

Re: The related_name of ForeignKey cannot be Unicode name after Django 1.8

2015-06-22 Thread Tim Graham
It looks like the check added in ticket #22064 may be too strict (only allowing alphanumeric characters in related_name). Would you like to open a ticket? On Monday, June 22, 2015 at 11:28:50 AM UTC-4, Cheng-Hung Hsueh wrote: > > This code can run before django 1.7 > But "relate

The related_name of ForeignKey cannot be Unicode name after Django 1.8

2015-06-22 Thread Cheng-Hung Hsueh
This code can run before django 1.7 But "related_name" got an error after django 1.8 使用者表.來源: (fields.E306) The name '使用者' is invalid related_name for field 使用者表.來源 class 來源表(models.Model): 名 = models.CharField(max_length=100) class 使用者表(models.Model): 來源 = mode

Re: Backwards relation not showing up via related_name in inherited models

2013-10-28 Thread Daniel Roseman
On Monday, 28 October 2013 15:11:24 UTC, Joshua Orvis wrote: > Thank you for responding, that's extremely helpful. I'm still failing to > query against it though. How would I implement a query for the > get_children() method in the example above? That is, for any given > instance of FlowBlue

Re: Backwards relation not showing up via related_name in inherited models

2013-10-28 Thread Joshua Orvis
models.ManyToManyField('self', blank=True, null=True, >> related_name='children') >> name = models.CharField( max_length=100 ) >> >> def __str__(self): >> return self.name >> >> class FlowBlueprint(StepBlueprint): >>

Re: Backwards relation not showing up via related_name in inherited models

2013-10-28 Thread Daniel Roseman
On Monday, 28 October 2013 07:29:39 UTC, Joshua Orvis wrote: > I'm using Django 1.6 RC1 and Python 3.3 with the following models: > > class StepBlueprint(models.Model): > parents = models.ManyToManyField('self', blank=True, null=True, > relat

Backwards relation not showing up via related_name in inherited models

2013-10-28 Thread Joshua Orvis
I'm using Django 1.6 RC1 and Python 3.3 with the following models: class StepBlueprint(models.Model): parents = models.ManyToManyField('self', blank=True, null=True, related_name='children') name = models.CharField( max_length=100 ) def __str__(self):

Re: My poll doesn't work when I start using related_name, help please.

2013-08-17 Thread Pepsodent Cola
t; >> ### PART B >> >> * Things work as intended when the rosword field just contain a simple >> "FK(Word)". >> * But when I use the other rosword field instead containing "FK(Word, >> related_name=&#

Re: My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Daniel Roseman
__ > > > > ### PART B > > * Things work as intended when the rosword field just contain a simple > "FK(Word)". > * But when I use the other rosword field instead containing "FK(Word, > related_name='altword

My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Pepsodent Cola
I use the other rosword field instead containing "FK(Word, related_name='altword_rosword')", then my altword_list template file doesn't receive a primary key ID from my Index template file anymore. What am I doing wrong when usi

Re: Model with several ManyToManyFields - related_name problem

2011-03-18 Thread George Lund
Hiya, thanks for the reply. So in this case the extra fields are actually denormalized subsets of the original field, and the reverse relation can use the main field. (At least, at the moment, that's my plan, but that could change. Which I guess goes to show how rare this case probably actual

Re: Model with several ManyToManyFields - related_name problem

2011-03-17 Thread werefr0g
Hello, I believe you need related_name, for disambiguation at least. Maybe by setting a db_table you can bypass the related_name but I'm not convinced. Actually, I'm "parasiting" your post to ask when "[we]'d prefer Django didn't create a backwards relation

Model with several ManyToManyFields - related_name problem

2011-03-17 Thread George Lund
I have a model with more than one (3 in fact) ManyToManyFields which point to the same other model. As long as I specify distinct related_names for each, all is well. But the documentation [1] suggests that if I don't need the backwards relation, then specifying '+' as the rela

Re: pass related_name-s into Model.objects.create()?

2010-05-18 Thread Phlip
> > But what about 'ForeignKey's? May we pass their 'remote_name's in with > > the kwargs? > > Foreign Keys - yes. Reverse Foreign Keys - no. Point: All kwargs takes is the fields on this object. > In the case of a foreign key, just pass in the object instance that > you want your object to be re

Re: pass related_name-s into Model.objects.create()?

2010-05-18 Thread Russell Keith-Magee
On Tue, May 18, 2010 at 12:45 PM, Phlip wrote: > Djangoists: > > The documentation for Model.objects.create(**kwargs) does not define > kwargs. It just sez "kwargs". > > I think all of our experiences would bear out "kwargs" may at least be > the model's fields. Correct. > But what about 'Foreig

pass related_name-s into Model.objects.create()?

2010-05-17 Thread Phlip
Djangoists: The documentation for Model.objects.create(**kwargs) does not define kwargs. It just sez "kwargs". I think all of our experiences would bear out "kwargs" may at least be the model's fields. But what about 'ForeignKey's? May we pass their 'remote_name's in with the kwargs? If not, wh

pass related_name-s into Model.objects.create()?

2010-05-17 Thread Phlip
='Cromskey', blogs=[ b1, b2, Blog.objects.create(title='yack yack yack') ] ) In my hypothetical kwargs, the related_name accepts an array of the target models. Do the kwargs support this convenience? Or must I simply plug the items in the

Abstract class related_name deppendent from application

2010-02-16 Thread gentlestone
Hi everyone, I have an abstract base class which has foreign key. Derived classes should have a related_name="%(class)s..." But, what if I have two or more derived classes with the same name in different applications? What is the solution of this issue? Patch this piece of code in

Problem with ManyToMany Relationship and related_name

2010-01-14 Thread HWM-Rocker
Hi, I am relatively new with Django but I like what I have seen so far. why does this not work? class Tag(models.Model): text = models.CharField(max_length=200) children = models.ManyToManyField('self', blank=True, null=True, symmetrical=True, related_name='parents

Re: Django and related_name

2009-07-29 Thread Asinox
6:23 PM, Asinox wrote: > > > Hi guys, first im so sorry with my english, im new with Django, u > > know ;) > > > I have a problem with a related_name, the tables are fine, but the > > problem is that in the Select (DropDown) the data display is "bad",

Re: Django and related_name

2009-07-29 Thread Ramiro Morales
On Wed, Jul 29, 2009 at 6:23 PM, Asinox wrote: > > Hi guys, first im so sorry with my english, im new with Django, u > know ;) > > I have a problem with a related_name, the tables are fine, but the > problem is that in the Select (DropDown) the data display is "bad", i

Re: Django and related_name

2009-07-29 Thread Mike Dewhirst
Asinox wrote: > > > Hi guys, first im so sorry with my english, im new with Django, u > know ;) > > I have a problem with a related_name, the tables are fine, but the > problem is that in the Select (DropDown) the data display is "bad", in > this w

Django and related_name

2009-07-29 Thread Asinox
Hi guys, first im so sorry with my english, im new with Django, u know ;) I have a problem with a related_name, the tables are fine, but the problem is that in the Select (DropDown) the data display is "bad", in this way: Tarifas_object: Html code: Tarifas object how ill display t

Re: related_name in filter search

2008-10-13 Thread Karen Tracey
; > http://dpaste.com/84076/ > > Thanks in advance! > I can't recreate your error because any attempt to use the models.py you point to produces an error on the declaration of the Edizione ForeignKey field within model Notizia: edizione = models.ForeignKey(Edizione, related_n

Re: related_name in filter search

2008-10-13 Thread Alessandro
2008/10/11 Karen Tracey <[EMAIL PROTECTED]>: > You've got a typo in there somewhere, because there is no 'notizie' in the > query you posted, you've got 'schede' like above. So I'm not sure exactly > what you tried nor exactly what error you got. Cut and paste of code and > error messages is bes

Re: related_name in filter search

2008-10-13 Thread Alessandro Ronchi
2008/10/11 Karen Tracey <[EMAIL PROTECTED]>: > You've got a typo in there somewhere, because there is no 'notizie' in the > query you posted, you've got 'schede' like above. So I'm not sure exactly > what you tried nor exactly what error you got. Cut and paste of code and > error messages is bes

Re: related_name in filter search

2008-10-11 Thread Karen Tracey
On Fri, Oct 10, 2008 at 3:19 PM, Alessandro <[EMAIL PROTECTED]>wrote: > In a project I have > class Scheda(models.Model): >referente = models.ForeignKey(User,related_name="schede", > editable=False) > > and I can use: > User.objects.distinct().filter(sc

related_name in filter search

2008-10-10 Thread Alessandro
In a project I have class Scheda(models.Model): referente = models.ForeignKey(User,related_name="schede", editable=False) and I can use: User.objects.distinct().filter(schede__isnull=False): in another I have class Notizia(models.Model): edizione = models.ForeignKe

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-18 Thread Andre Meyer
hi Rajesh so, implemented it as you told and it works very well. thanks for your patience and all the explanations. cheers André On Thu, Jul 17, 2008 at 7:22 PM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > > > > > still, it's not exactly clear to me why the admin does not work the > same > >

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Rajesh Dhawan
> > > still, it's not exactly clear to me why the admin does not work the same > > as > > > other templates. > > > The Admin is not a template. So, I don't know what you mean by that. > > admin is not using templates? well, i did not check the implementation. Sorry, if I wasn't clear. The admin

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Andre Meyer
hi Rajesh On Thu, Jul 17, 2008 at 6:55 PM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > Hi, > > > still, it's not exactly clear to me why the admin does not work the same > as > > other templates. > > The Admin is not a template. So, I don't know what you mean by that. admin is not using templa

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Rajesh Dhawan
Hi, > still, it's not exactly clear to me why the admin does not work the same as > other templates. The Admin is not a template. So, I don't know what you mean by that. > > in my own template, it is no problem to refer to comments of a post using, > e.g. > > {% for comment in post.comments.all

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Andre Meyer
agine you have a first model class and a second model class with a > > ForeignKey referring to the first one. for example, a Post model (taken > from > > the tutorial blog app) and a Comment model. of course, a post can have > > multiple comments, so the Post model gets an att

Re: how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Rajesh Dhawan
del. of course, a post can have > multiple comments, so the Post model gets an attribute 'comments' (specified > using related_name). > > how can the comments be displayed in the list view of the posts using > newforms-admin? i would like to indicate whether there are commen

how to access foreignkey field (related_name) in newforms-admin list view?

2008-07-17 Thread Andre Meyer
ments' (specified using related_name). how can the comments be displayed in the list view of the posts using newforms-admin? i would like to indicate whether there are comments and how many, if any. but when adding the 'comments' attribute to the list_display of PostOptions, syncdb

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 relations have the same name. --~--~-~--~~~--

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

Re: related_name

2007-08-06 Thread Lic. José M. Rodriguez Bacallao
right now, I find out how but, anyway, I'll give U an example: every ForeigmKey have a related_name parameter in its constructor, the problem is how to change that value once we construct the ForeignKey object. I did so changing the value of the: foreignkey_object.rel.related_name at runtime

Re: related_name

2007-08-04 Thread Amirouche
On Aug 1, 10:07 pm, "Lic. José M. Rodriguez Bacallao" <[EMAIL PROTECTED]> wrote: > how can I change the "related_name" value in a ForeignKey field dynamically > at model creation time? > What do you really mean

related_name

2007-08-01 Thread Lic. José M. Rodriguez Bacallao
how can I change the "related_name" value in a ForeignKey field dynamically at model creation time? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

related_name

2007-08-01 Thread Lic. José M. Rodriguez Bacallao
how can I change the "related_name" value in a ForeignKey field dynamically at model creation time? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Re: Accessor for field 'somefield' clashes with related field ... Add a related_name argument to the definition for 'somefield'

2006-12-24 Thread Malcolm Tredinnick
=True) Why it gives you errors..until you change it to this: class Loan(models.Model): loan_id = models.AutoField(primary_key=True) originator =models.ForeignKey(UserInfo, related_name="originator",null=True) obligor = models.ForeignKey(UserInfo, related_name="obligor&quo

Accessor for field 'somefield' clashes with related field ... Add a related_name argument to the definition for 'somefield'

2006-12-23 Thread [EMAIL PROTECTED]
: class Loan(models.Model): loan_id = models.AutoField(primary_key=True) originator =models.ForeignKey(UserInfo, related_name="originator",null=True) obligor = models.ForeignKey(UserInfo, related_name="obligor",null=True) Why doesn't django just just look at th

Re: Difficulty accessing via related_name

2006-09-09 Thread Russell Keith-Magee
On 9/10/06, Hawkeye <[EMAIL PROTECTED]> wrote: > > Ah ha! Thank you... I now see the error of my ways! > > Since I'm using unique=True, is there any way to avoid the [0] mumbo > jumbo? (I don't see any but I figure it won't hurt to ask). No. A foreign key is a many-to-one relation. In your case,

Re: Difficulty accessing via related_name

2006-09-09 Thread Hawkeye
Ah ha! Thank you... I now see the error of my ways! Since I'm using unique=True, is there any way to avoid the [0] mumbo jumbo? (I don't see any but I figure it won't hurt to ask). Thanks, --Ben --~--~-~--~~~---~--~~ You received this message because you are

Re: Difficulty accessing via related_name

2006-09-09 Thread Russell Keith-Magee
On 9/10/06, Hawkeye <[EMAIL PROTECTED]> wrote: > print "User's Foo: %s" % request.user.foo > > == request.user.foo is a manager, same as User.objects. The manager itself isn't a list of objects; you need to use one of the manager methods (like all(), filter() etc) to get the act

Difficulty accessing via related_name

2006-09-09 Thread Hawkeye
Hi folks, I'm trying to develop an application that 'extends' the User object. I'm using the 'related_name' argument for ForeignKey to access the related objects through request.user I have a class, similar to this == class Foo(models.Model):

Re: ManyToMany with related_name?

2006-04-12 Thread Russell Keith-Magee
d. To avoid confusion, the reverse representation of the relationship (person_set, or whatever related_name specifies) is not added to instances of Person. Obviously, there are some use cases (such as yours) where this is not the case - to handle these, you need to set symmetrical=False: insert_into = mo

ManyToMany with related_name?

2006-04-12 Thread Dave St.Germain
ield('self',  null=True,  blank=True,      related_name='insert') The problem is that the model doesn't seem to use the related_name option.  PressRun objects have an insert_into property, but no insert property.  I'm actually trying