Re: Many to many field does not save in the main object

2020-08-28 Thread Annick Sakoua
I found the mistake, I removed the 'for item in instance' in my addcustomer function and Elesire suggestion about iterating in the {{customer.gp}} object in my template helped me a lof. Thank you soo much. Le mardi 25 août 2020 à 14:57:48 UTC+1, Annick Sakoua a écrit : > Hi all, > Please Hel

Re: Many to Many relationships in template

2020-02-27 Thread Gil Obradors
Hi! https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#modeladmin-objects or https://docs.djangoproject.com/en/3.0/intro/tutorial07/#writing-your-first-django-app-part-7 Missatge de Robb Rodirguez Jr. del dia dv., 28 de febr. 2020 a les 1:14: > Good day guys, im new to django im having in

Re: Many to Many field in ModelForm - with tens of thousands of records

2018-10-29 Thread Web Architect
Hi Sanjay, Thanks for the prompt response and the approach. That seems to be an efficient approach - would look into auto-complete. Thanks. On Monday, October 29, 2018 at 5:09:50 PM UTC+5:30, Sanjay Bhangar wrote: > > My recommendation would be to use a bit of Javascript to implement an > "au

Re: Many to Many field in ModelForm - with tens of thousands of records

2018-10-29 Thread Sanjay Bhangar
My recommendation would be to use a bit of Javascript to implement an "autocomplete" to fetch records via AJAX as the user types (with perhaps a minimum of 3 characters or so), so you only ever fetch a subset of records and don't overload your template. You can find quite a few 3rd party libraries

Re: Many to Many field in ModelForm - with tens of thousands of records

2018-10-29 Thread Web Architect
Would also add that the server CPU usage was hitting 100% due to the template loading issue. On Monday, October 29, 2018 at 4:48:54 PM UTC+5:30, Web Architect wrote: > > Hi, > > We are using django 1.11 for our ecommerce site. > > We are facing an issue with modelform and many to many field in

Re: Many to Many fields and through table

2018-07-04 Thread johnasmith . dev
Hi Mark, Thank you for your question, I might actually do the same. I just had issues on a model with 2 M2M relationships (one using an intermediary table, one without). I would just caveat what James Schneider said, there are some differences. My simply M2M relationship threw me Field Requir

Re: Many to Many fields and through table

2017-12-19 Thread Simon Charette
Hello Mark, The only downside I can think of is that you won't be able to create relationships from the m2m managers, you'll have to create the relationship directly instead. This isn't such a big issue if you plan on adding fields later to the intermediary model later on anyway. You can read mo

Re: Many to Many fields and through table

2017-12-19 Thread James Schneider
On Dec 19, 2017 1:53 PM, "Mark Phillips" wrote: Is there any downside to creating a through table in a many to many relationship when there isn't any "extra" related data, but there might be in the future? I have read that migrating from a simple m2m relationship to a m2m with a through table ta

Re: Many to Many in Django Admin

2017-02-23 Thread Melvyn Sopacua
On Thursday 23 February 2017 05:22:25 José Vicente Jonas França wrote: > I Like to know if its possible to display the many-to-many field in > both pages of Model at Django Admin. > If it is possible how can i do this? All available in the documentation[1]. -- Melvyn Sopacua [1] http

Re: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-14 Thread Collin Anderson
Hi, The admin first calls obj.save(), then it saves the related data. You could try putting your logic in ModeAdmin.save_related() https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_related Collin On Monday, January 12, 2015 at 5:00:54 PM UTC-5, Tobias

Re: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-12 Thread Tobias Dacoir
Thanks for the links. It might be related to that bug. In my scripts I added another save() and then it works of course and as for the Admin Panel, until I have a solution I put a message into the help text that users have to click 'save and continue' first and then 'save' afterwards. Then it's

Re: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-12 Thread Lachlan Musicman
Is that related to this bug? https://code.djangoproject.com/ticket/8892 https://code.djangoproject.com/ticket/10811 In short - if FK fields aren't saved as objects themselves first, then they aren't correctly added to the new objects? I had trouble with this once. Maybe put in a save after the g

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Thanks man. This was a huge relief! On Tue, Oct 21, 2014 at 2:35 PM, Collin Anderson wrote: > Hi Paul, > > 1. How did you know!?! >> > I hack... kidding :). I suspected something wasn't getting loaded, and the > list of installed apps was in the traceback you posted. > > 2.I have the same code i

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Collin Anderson
Hi Paul, 1. How did you know!?! > I hack... kidding :). I suspected something wasn't getting loaded, and the list of installed apps was in the traceback you posted. 2.I have the same code in production and it was working with no problems. > Any idea why? > In development, most, if not all of yo

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
I am SHOCKED. That was the problem. THANK YOU I guess that leads to a couple of questions: 1. How did you know!?! 2.I have the same code in production and it was working with no problems. Any idea why? Cheers! On Tuesday, October 21, 2014 1:12:33 PM UTC-3, Collin Anderson wrote: > > Hi Pau

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Collin Anderson
Hi Paul, Try putting 'trending' in INSTALLED_APPS. Collin -- 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

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Collin Anderson
Hi Paul, This is great. The traceback helps. Could post more of your convert_queryset_to_lists. It looks like a list comprehension and there may be more complicated things going on there. Thanks, Collin -- You received this message because you are subscribed to the Google Groups "Django user

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Here is the stack trace... Environment: Request Method: POSTRequest URL: http://127.0.0.1:8000/trending/trend/ Django Version: 1.6Python Version: 2.6.7Installed Applications:('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.cont

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Hey Collin, I had no problem in the shell... In [4]: AffectedPart.objects.all().count() Out[4]: 4090 # pick a random AffectedPart In [5]: affpart = AffectedPart.objects.all()[22] In [6]: affpart.damage_types.all() Out[6]: [] I'm not sure why this doesn't work running under the server.

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Daniel Roseman
On Tuesday, 21 October 2014 14:32:04 UTC+1, Paul Childs wrote: > > *What's been done so far:* > >- I was on Django 1.5 and upgraded to 1.6 (cannot go higher as we are >on Python 2.6) and this did not solve the problem. >- I have researched this issue to death and cannot seem to find a

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Collin Anderson
Hi Paul, Interesting. Your code should work fine. So if you run this code in the shell it gives a FieldError? affpart.damage_types.all() What do your sitar models look like? There should not be a ManyToManyField in the other direction. Collin -- You received this message because you are sub

Re: many-to-many between apps

2013-07-31 Thread Mike Dewhirst
On 31/07/2013 5:08pm, Mike Dewhirst wrote: Is it possible to establish a many-to-many relationship between a model in one app and a model in another app? Yes. I needed to avoid importing the class and use ... class Region(models.Model): ... various fields ... ref = models.ManyToMan

Re: many-to-many queryset question

2012-01-07 Thread Carsten Fuchs
Hi Peter, Am 2012-01-07 03:40, schrieb Peter of the Norse: One possibility is to try two excludes. bad_authors = Authors.objects.exclude(pk__in=SetOfAuthors) qs = Entry.objects.exclude(authors__in=bad_authors) This will return all entries that don't have authors in SetOfAuthors. It might even

Re: many-to-many queryset question

2012-01-06 Thread Peter of the Norse
One possibility is to try two excludes. bad_authors = Authors.objects.exclude(pk__in=SetOfAuthors) qs = Entry.objects.exclude(authors__in=bad_authors) This will return all entries that don't have authors in SetOfAuthors. It might even be easier, if you can skip creating SetOfAuthors in the first

Re: many-to-many queryset question

2011-12-06 Thread Felipe Morales
could you possibly show the query generated?... # print qs.query 2011/12/6 Carsten Fuchs > Hi all, > > looking at the example models Author and Entry at > https://docs.djangoproject.**com/en/1.3/topics/db/queries/, > I would like to run

Re: Many to many fields to string

2010-08-12 Thread Steve Holden
On 8/12/2010 8:11 PM, Wendy wrote: > Thanks so much both of you, totally works and makes sense. I used > Joseph's version because of the commas, but they both helped me > understand what was happening. > I notice that it seems to be ok to put the if statement on one line: > > {% if filmmakers|len

Re: Many to many fields to string

2010-08-12 Thread Wendy
Thanks so much both of you, totally works and makes sense. I used Joseph's version because of the commas, but they both helped me understand what was happening. I notice that it seems to be ok to put the if statement on one line: {% if filmmakers|length > 2 and not forloop.first %}, {% endif %}

Re: Many to many fields to string

2010-08-11 Thread Joseph Spiros
Er, I forgot to add an {% endwith %} at the end. You don't HAVE to use the with tag at all, but it can make things a bit easier. On 8/11/10 6:18 PM, Joseph Spiros wrote: > You'll want to loop through the objects and print the appropriate > property of the objects that consists of just the name. He

Re: Many to many fields to string

2010-08-11 Thread Joseph Spiros
You'll want to loop through the objects and print the appropriate property of the objects that consists of just the name. Here's some template code that does that, and also separates with commas and "and", using a serial comma (aka Oxford comma). (This assumes that your Filmmaker model has a "name

Re: Many to many fields to string

2010-08-11 Thread Carlos Daniel Ruvalcaba Valenzuela
Use a for loop, there is tags to know if you are at the last item of the list, so to not add the and: {% for filmmaker in film.filmmakers.all %} {{ filmmaker.name }} {% if not forloop.last %} and {% endif %} {% endfor %} Assuming you are using django 1.2, but you get the idea. http://docs.django

Re: Many to many ajax widget for admin

2010-08-02 Thread Carlos Ricardo Santos
Already tried to find a better approach without success, raw_id is now the best option. On 2 August 2010 10:54, Sævar Öfjörð wrote: > If someone is interested, > I just used raw_id_fields in my intermediary inline modeladmin. > > class AuthorshipInline(admin.TabularInline): >raw_id_fields =

Re: Many to many ajax widget for admin

2010-08-02 Thread Sævar Öfjörð
If someone is interested, I just used raw_id_fields in my intermediary inline modeladmin. class AuthorshipInline(admin.TabularInline): raw_id_fields = ('author',) This isn't exactly what I was going for, but it takes the really big select fields out of the picture. - Sævar On Jul 27, 5:24 a

Re: Many to many ajax widget for admin

2010-07-26 Thread ringemup
You might want to check out grappelli and its Related Lookups feature: http://code.google.com/p/django-grappelli/ On Jul 26, 4:30 pm, Sævar Öfjörð wrote: > Hi > > I have some models (Song and Author) that are related through an > intermediary model (Authorship) like this: > > class Song(models

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-26 Thread Nick Serra
Can you be more clear on the exact result you're trying to achieve? Do you want to see, for a given high school, how many recruit objects are foreign keyed to it? On Apr 26, 7:38 am, Nuno Maltez wrote: > Are you saying that: > > collegelist = > college.current_objects.filter(collegechoices__scho

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-26 Thread Nuno Maltez
Are you saying that: collegelist = college.current_objects.filter(collegechoices__school=highschoolid).exclude(name='Undeclared').distinct().annotate(ccount=Count('collegechoices')) gives you the same results as collegelist = college.current_objects.exclude(name='Undeclared').distinct().annota

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-19 Thread Matt
Oops. That title should be "conditional if," of course. On Apr 19, 2:43 pm, Matt wrote: > Hoping you all can tell me what I'm doing that's stupid here. I have > three models: > > class highschool(models.Model): >     name = models.CharField(max_length=50) >     address = models.CharField(max_leng

Re: many to many based upon common field

2010-04-14 Thread Francis Gulotta
I think that might be a better way, but the data should never change so I'm ok with the denormalization. How would I access the po_num in that example? Order.edi.po_num? or Order.PoNum.po_num? I think though I was asking the wrong question. I updated this on Stack Overflow. What I really need to

Re: many to many based upon common field

2010-04-13 Thread Ian Lewis
wizard, Would it make sense to use the intermediate table to hold the field? Using the stack overflow example: class Edi856(models.Model): pass class Order(models.Model): edi = models.ManyToManyField(Edi856, through='PoNum') def in_edi(self): '''Has the edi been processed?''

Re: Many to Many...so many queries

2010-03-23 Thread TheIvIaxx
yes, this util helped a lot! 300 down to 20 i think. I had a SQL query ready, but then you lose all the ORM goodness. I would think this should be part of the ORM, no? In the SQL, I just had to add another join to the query generated by the select_related() method. The problem is you get dupli

Re: Many to Many...so many queries

2010-03-23 Thread TheIvIaxx
as far as I could tell, select_related did not follow m2m relationships, only FK. On Mar 18, 2:12 am, bruno desthuilliers wrote: > On Mar 18, 8:42 am, koenb wrote: > > > Take a look at something like django-selectreverse [1] for inspiration > > on how to reduce your querycount for M2M relations.

Re: Many to Many...so many queries

2010-03-19 Thread Sam Walters
Yes, this conversation hits the nail on the head. 'select related' only works with forward facing keys. http://code.google.com/p/django-selectreverse/ is a resonably good piece of code to improve performance: using a structure like: class model1(model.Models) 1<* class model2(model.Models

Re: Many to Many...so many queries

2010-03-18 Thread koenb
On 18 mrt, 10:12, bruno desthuilliers wrote: > On Mar 18, 8:42 am, koenb wrote: > > > Take a look at something like django-selectreverse [1] for inspiration > > on how to reduce your querycount for M2M relations. > > > Koen > > > [1]http://code.google.com/p/django-selectreverse/ > > I must be mis

Re: Many to Many...so many queries

2010-03-18 Thread bruno desthuilliers
On Mar 18, 8:42 am, koenb wrote: > Take a look at something like django-selectreverse [1] for inspiration > on how to reduce your querycount for M2M relations. > > Koen > > [1]http://code.google.com/p/django-selectreverse/ > I must be missing the point, but it looks seriously like reinventing t

Re: Many to Many...so many queries

2010-03-18 Thread bruno desthuilliers
On Mar 17, 6:55 pm, TheIvIaxx wrote: > I made a mistake in my model definitions above. And a couple errors in the "view" code snippet too FWIW !-) >  The Term field on > Image is a ManyToMany() not ForeignKey(). > > Anyhow I did look into value_list, however it didn't add much, if any, > perfor

Re: Many to Many...so many queries

2010-03-18 Thread koenb
Take a look at something like django-selectreverse [1] for inspiration on how to reduce your querycount for M2M relations. Koen [1] http://code.google.com/p/django-selectreverse/ On 17 mrt, 18:55, TheIvIaxx wrote: > I made a mistake in my model definitions above.  The Term field on > Image is

Re: Many to Many...so many queries

2010-03-17 Thread TheIvIaxx
I made a mistake in my model definitions above. The Term field on Image is a ManyToMany() not ForeignKey(). Anyhow I did look into value_list, however it didn't add much, if any, performance gain. But the select_related did! That was exactly what I needed. Thanks Bruno for the tip. On Mar 17

Re: Many to Many...so many queries

2010-03-17 Thread bruno desthuilliers
On Mar 17, 4:37 am, TheIvIaxx wrote: > i suppose i could, but that will be a last resort :)  What about > dropping down to raw SQL just to get the IDs: > > SELECT term_id FROM image_term WHERE image_id = %i > > or is that discouraged?  Can it be done with the ORM? You'd have the exact same result

Re: Many to Many...so many queries

2010-03-17 Thread bruno desthuilliers
On Mar 17, 4:24 am, TheIvIaxx wrote: > Hello all, i have a question about a certain query i have.  Here is my > model setup: > > class Term(): >     term = CharField() > > class Image(): >     image = FileField() >     terms = ForeignKey(Term) > > These have been abbreviated for simiplicity, ut yo

Re: Many to Many...so many queries

2010-03-16 Thread Kenneth Gonsalves
On Wednesday 17 Mar 2010 9:07:47 am TheIvIaxx wrote: > i suppose i could, but that will be a last resort :) What about > dropping down to raw SQL just to get the IDs: > > SELECT term_id FROM image_term WHERE image_id = %i > > or is that discouraged? Can it be done with the ORM? > look at 'get

Re: Many to Many...so many queries

2010-03-16 Thread aditya
You can, and I'd be interested to know how much of a speedup that gives. Here's the relevant page on writing raw SQL: http://docs.djangoproject.com/en/dev/topics/db/sql/ If you know SQL (and it looks like you do) it should be familiar territory. The interesting bits are deferring fields, and addin

Re: Many to Many...so many queries

2010-03-16 Thread TheIvIaxx
i suppose i could, but that will be a last resort :) What about dropping down to raw SQL just to get the IDs: SELECT term_id FROM image_term WHERE image_id = %i or is that discouraged? Can it be done with the ORM? On Mar 16, 8:32 pm, aditya wrote: > Is there any way you could reduce the # of

Re: Many to Many...so many queries

2010-03-16 Thread aditya
Is there any way you could reduce the # of images to return? Another thing you could do is cache this info so you don't have to do it multiple times. Aditya On Mar 16, 10:24 pm, TheIvIaxx wrote: > Hello all, i have a question about a certain query i have.  Here is my > model setup: > > class Ter

Re: Many-To-Many Relationship with intermediate table

2010-03-07 Thread Dennis Kaarsemaker
On zo, 2010-03-07 at 05:01 -0800, jorge.silva wrote: > Hi there! > > As far as I've read in the Django wiki this is a very common > situation, yet I can't get it right > I've inherited a legacy database which I'm slowly trying to model in > Django to benefit from the free Admin site. As long a

Re: Many-to-many through multiple tables

2009-11-28 Thread Jonathan
The BusinessVersion isn't relevant, I posted the whole model to put it in context. It's a web app to track software through the software development lifecycle. Regardless of the lifecyle stage (development, test, production), all instances of an application consist of the same Group of packages (p

Re: Many-to-many through multiple tables

2009-11-28 Thread t0ster
May be Group should include packages of specific versions: class Group(models.Model): name = models.CharField(max_length=100) product = models.ForeignKey(Product) -packages = models.ManyToManyField(Package) +packages = models.ManyToManyField(PackageVersion) class Profile(models.M

Re: Many-to-many through multiple tables

2009-11-28 Thread Jonathan
Hi, I've slimmed it down to the relevant fields. I'm a bit of a noob, but I think I'm basically trying to build a generic framework that can be made specific in a profile. Profile = BusinessVersion + Group + LifecycleStage + Package.Versions Jonathan class Product(models.Model): name = mode

Re: Many-to-many through multiple tables

2009-11-28 Thread t0ster
Could you post your models.py code here? On Nov 28, 1:10 pm, Jonathan wrote: > This may be more of a general database design question, but I want to > come up with something that works with Django's ORM. > > I have four bits of information that I want to link together. Generic > packages, package

Re: Many to many relation - parents without any children

2009-11-15 Thread Tomasz Zieliński
On 15 Lis, 09:34, Nagy Károly wrote: > Tomasz Zieli ski wrote: > > How about something like this (should work, although I haven't checked > > it): > > > Author.objects.annotate(article_num=Count('articles')).filter > > (article_num=0) > > > - where articles=ManyToManyField('Article') > > This is

Re: Many to many relation - parents without any children

2009-11-15 Thread Nagy Károly
Tomasz Zieliński wrote: > How about something like this (should work, although I haven't checked > it): > > Author.objects.annotate(article_num=Count('articles')).filter > (article_num=0) > > - where articles=ManyToManyField('Article') > This is so elegant, so i have to upgrade to 1.1 now... :)

Re: Many to many relation - parents without any children

2009-11-14 Thread Tomasz Zieliński
On 14 Lis, 23:20, Nagy Károly wrote: > Please help me in orm level filtering many-to-many relations. > > I have to filter all "authors" who does not belongs to any "articles". > Or the opposite of this, list of orphaned articles... > > I dont want to write sql in the model if possible. How abou

Re: many to many add by ids

2009-09-30 Thread Tom Evans
On Tue, 2009-09-29 at 16:16 -0700, rich.al...@gmail.com wrote: > I have the following I'm trying to optimize. > > Input (from the web) is > > sids = "1,2,3,5" (a list of ids is posted, say they are article ids) > > Now, to add them to a many to many, I'd like to just > > try: > authors.articl

Re: Many-to-many column admin interface

2009-08-30 Thread Thomas Guettler
Thank you for this link. Looks good Sven Richter schrieb: > Ah, and google does help or at least django_snippets. > I found the solution here: > http://www.djangosnippets.org/snippets/1295 > > The trick is to create a column in both models and in one with the option to > not syncdb. > Its really

Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Yea, i thought about that, but for me this seems like an ugly workaround. Dont misunderstand me, i dont know enough about django and its database internals, but why should i use a third model for something i can access directly? The solution i posted above was exactly what i was looking for and wh

Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
But i wonder how this would help me further. In the End it doesnt matter for me on which model i define the M2M relation. But i need to access the M2M Table from both models, at least in the view or in the template if not in the admin interface. I am having a hard time finding out how to achieve t

Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Ah, and google does help or at least django_snippets. I found the solution here: http://www.djangosnippets.org/snippets/1295 The trick is to create a column in both models and in one with the option to not syncdb. Its really simple, just 6 lines at all. Greetings and a nice Weekend Sven On Fri,

Re: Many-to-many column admin interface

2009-08-28 Thread patrickk
I could be mistaken ... but why not using a third model. C(models.model): a = models.ForeignKey('A') b = models.ForeignKey('B') when editing either A or B, you could use C as inlines. regards, patrick On 28 Aug., 17:18, Sven Richter wrote: > But i wonder how this would help me further.

Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
I've opened a bug/feature request at: http://code.djangoproject.com/ticket/11795#comment:2 if someone is interested. Greetings Sven On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote: > > On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter > wrote: > > I found this thread: > > > http://stackove

Re: Many-to-many column admin interface

2009-08-28 Thread Craig McClanahan
On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter wrote: > I found this thread: > http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship > on Stackoverflow, but when i try the suggested TabularInline thing i get the > error: > > has no ForeignKey to 'politlog.entr

Re: Many-to-many column admin interface

2009-08-27 Thread Sven Richter
I found this thread: http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship on Stackoverflow, but when i try the suggested TabularInline thing i get the error: has no ForeignKey to Greetings Sven On Thu, Aug 27, 2009 at 5:03 PM, Thomas Guettler wrote: > >

Re: Many-to-many column admin interface

2009-08-27 Thread Thomas Guettler
Hi, I had the same question some time ago and found no answer, but maybe you try harder. Sven Richter schrieb: > Hi, > > i have a new problem with my many-to-many field. > > I have two models A and B. > A(models.model): > b = models.ManyToManyField('app.B') > > Now when i edit A in the admi

Re: Many-to-many column

2009-08-26 Thread Sven Richter
Thank you very much. I think i get the idea. Greetings Sven On Tue, Aug 25, 2009 at 10:51 PM, Peter Bengtsson wrote: > > I fear your only option is to write a recursive function which you > feed with what you define to be "the end of the chain". > You can collect all the entries in a mutable l

Re: Many-to-many column

2009-08-25 Thread Peter Bengtsson
I fear your only option is to write a recursive function which you feed with what you define to be "the end of the chain". You can collect all the entries in a mutable list. Some example, untested, code: def get_all_parents(list_, current): for entry in current.following_to.all(): lis

Re: many to many model

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 03:49 -0700, elminio wrote: > Hi, > tahnks for reply I added additional ManyToManyfield to one table and > admin panel looks ok but in fact even using syncdb new intermediate > table wasn't created. > Is there anything else I should do ? Syncdb does not incrementally update

Re: many to many model

2009-08-03 Thread elminio
Hi, tahnks for reply I added additional ManyToManyfield to one table and admin panel looks ok but in fact even using syncdb new intermediate table wasn't created. Is there anything else I should do ? --~--~-~--~~~---~--~~ You received this message because you are

Re: many to many model

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 02:24 -0700, elminio wrote: > Hello, > > My problem is that I have (for example), a model teacher - subject > many to many. So that I made additional table named teacherSubject > with both ids. Instead of thinking about what database tables would be created, use Django's OR

Re: Many to Many is empty when saving parent object

2009-03-17 Thread Brandon Taylor
Ah, gotcha, so my signal is attached to the wrong sender. I was thinking I would have access to the categories during the Entry's save operation due to the m2m relationship on the field, but obviously not. I'll move the signal and see what happens. Thank you, Brandon On Mar 16, 6:53 pm, Malcolm

Re: Many to Many is empty when saving parent object

2009-03-16 Thread Malcolm Tredinnick
On Mon, 2009-03-16 at 08:48 -0700, Brandon Taylor wrote: > Hi everyone, > > I'm running Python 2.6.1, Django Trunk. > > I have a model (Entry) with a ManyToMany (Categories). I need to be > able to iterate over these categories whenever my parent model is > saved. > > I've tried overriding save

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
I'll give it a go :) Thanks for your help Ben. On Dec 9, 9:50 am, Ben Eliott <[EMAIL PROTECTED]> wrote: > hmm, don't know. that's the documented approach. you might want to   > investigate intermediary tables/models etc. > > On 9 Dec 2008, at 09:24, Darthmahon wrote: > > > > > Ahh yes possibly. A

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott
hmm, don't know. that's the documented approach. you might want to investigate intermediary tables/models etc. On 9 Dec 2008, at 09:24, Darthmahon wrote: > > Ahh yes possibly. Any downsides to using this? > > On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote: >> Do you want something li

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
Ahh yes possibly. Any downsides to using this? On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote: > Do you want something like this? > friends_new = models.ManyToManyField("self",symmetrical=False) > > On 9 Dec 2008, at 09:06, Darthmahon wrote: > > > > > Hi Guys, > > > Just bumping this up

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott
Do you want something like this? friends_new = models.ManyToManyField("self",symmetrical=False) On 9 Dec 2008, at 09:06, Darthmahon wrote: > > Hi Guys, > > Just bumping this up as I still can't figure out why this is > happening :/ > > On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote: >>

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
Hi Guys, Just bumping this up as I still can't figure out why this is happening :/ On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Guys, > > I've got a model that has a Many to Many relationship on one of the > fields. This relationship is basically on itself though like this: > >

Re: Many-to-Many to exists table

2008-12-03 Thread nucles
Thank you Thomas for your feedback! We need a Many-To-Many Relation not to "group", but to "user_auth_group". I try to draw the desirable result: user --- user_auth_group group | | user_auth_group_area

Re: Many-to-Many to exists table

2008-12-02 Thread Thomas Guettler
If I understood you problem: {{{ from django.contrib.auth.models import Group class Area(models.Model): groups=models.ManyToManyField(Group) }}} This creates a Many-To-May relation to Group. Copied from brain to keyboard (untested) HTH, Thomas nucles schrieb: > Hello Django-People, > >

Re: many to many matrix

2008-11-20 Thread Malcolm Tredinnick
On Thu, 2008-11-20 at 00:19 -0800, frans wrote: > Hi, I was wondering if there is some way to create a "matrix display" > for viewing/editing many to many relationships between objects ? > > I've been thinking to use django for network documentation. My idea is > to put all the networks we host

Re: Many to Many where two fields in one model are related

2008-09-30 Thread Steve Bergman
Thank you. That looks to be exactly what I need. I remember seeing that on the ToDo list leading up to 1.0, but didn't realize how it applied to my situation. -Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: Many to Many where two fields in one model are related

2008-09-30 Thread Rajesh Dhawan
> I'm working on an app for planning balanced daily diets. And I'm > having trouble figuring out how to set up my models. I have: > > Ingredient(models.Model): > ingredient_name = CharField(max_length=50) > unit = CharField(max_length=15) > calories = DecimalField(max_digits=6, deci

Re: Many-to-Many different models (quasi-tagging)

2008-09-29 Thread Joshua Jonah
I never thought of that, i can just use the comments system, thanx for that Malcolm. Malcolm Tredinnick wrote: > On Mon, 2008-09-29 at 20:45 -0700, joshuajonah wrote: > >> Also i should say, I'd like to be able to attach multiple "notes" to >> any given model. >> > > Replace "note" with "

Re: Many-to-Many different models (quasi-tagging)

2008-09-29 Thread Malcolm Tredinnick
On Mon, 2008-09-29 at 20:45 -0700, joshuajonah wrote: > Also i should say, I'd like to be able to attach multiple "notes" to > any given model. Replace "note" with "comment" and it's basically the same setup. So have a look at how Django's comments app does this (django.contrib.comments.models).

Re: Many-to-Many different models (quasi-tagging)

2008-09-29 Thread joshuajonah
Also i should say, I'd like to be able to attach multiple "notes" to any given model. On Sep 29, 11:42 pm, joshuajonah <[EMAIL PROTECTED]> wrote: > Hi guys, > >     I'm making a little basic intranet CRM. Here's the models right > now, pretty straight forward: > > class Person(models.Model): >  

Re: Many-To-Many with extra fields

2008-09-23 Thread akonsu
this is untested: m = Membership.objects.select_related().get(person__name='ringo') ringo = m.person i agree, this is not as convenient as could be. may be it will be in the next version? konstantin On Sep 23, 5:16 pm, Nate Thelen <[EMAIL PROTECTED]> wrote: > Yeah, that would work, too.  I was

Re: Many-To-Many with extra fields

2008-09-23 Thread Nate Thelen
Yeah, that would work, too. I was thinking more like if you got the ringo like this: ringo = Person.objects.select_related(depth=2).get(name='ringo') how could you get the data without having to make another DB call. Ideas? Thanks, Nate On Sep 23, 2:04 pm, akonsu <[EMAIL PROTECTED]> wrote: >

Re: Many-To-Many with extra fields

2008-09-23 Thread akonsu
hello, how about for m in Membership.objects.filter(person=ringo) : print m.date_joined konstantin On Sep 23, 4:58 pm, Nate Thelen <[EMAIL PROTECTED]> wrote: > So if I have a Person object "ringo" and I want to get info about the > Groups he is a member of, I would do this: > > for group in ri

Re: Many-To-Many with extra fields

2008-09-23 Thread Nate Thelen
So if I have a Person object "ringo" and I want to get info about the Groups he is a member of, I would do this: for group in ringo.group_set.all() print( group.name ) My question is, how do I print the "date_joined" without having to do this: for group in ringo.group_set.all() print( M

Re: Many-To-Many with extra fields

2008-09-19 Thread Russell Keith-Magee
On Sat, Sep 20, 2008 at 8:37 AM, Nate Thelen <[EMAIL PROTECTED]> wrote: > > Looking at the docs here: > > http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships > > I cannot find any reference to how to access the data in the > "Membership" table. For ex

Re: Many-To-Many with extra fields

2008-09-19 Thread Rock
In my code I have a reference and a name such that I can do perform a "get" to procure the reference to the correct intermediate object. Then I simply interrogate that object directly. It should be possible to do a "values" style query instead if you only want a particular field or set of fields.

Re: Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
i see that there exists a handy way -- *icontains* does exactly what iam looking at On Sun, Aug 31, 2008 at 9:35 PM, Vadivel Kumar <[EMAIL PROTECTED]> wrote: > Thanks Michael, > > I solved the problem - i had a silly mistake in the way how i handled to > check the existing tag. But, now the pro

Re: Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
Thanks Michael, I solved the problem - i had a silly mistake in the way how i handled to check the existing tag. But, now the problem is when i check the given tag text against the database, i do it as like below, newTag = request.POST['tag'] existingTag = Tags.objects.filter(TagNa

Re: Many to Many field Assignment

2008-08-31 Thread Michael Newman
On Aug 31, 11:14 am, "Vadivel Kumar" <[EMAIL PROTECTED]> wrote: > I know this might sound very newbie .. its true > > How can i assign an exising record of the child table to an parent record. > For example I have two models, > >     class User (models.Model): >          ... all other fields ... >

Re: Many to many array accessible from template?

2008-07-16 Thread Jashugan
On Jul 13, 6:10 am, Darthmahon <[EMAIL PROTECTED]> wrote: > Alex, > > I don't understand what you mean by that? message.users.all prints out > a list of users based on the many to many. I just want to check if the > current user is in message.users.all - are you saying I can't because > I am passi

  1   2   3   >