Re: access an attribute of a target model in a many-to-many relationship

2022-11-29 Thread Viper Code
when I try to access an attribute of a target model in a many to many > relationship, I get an error : AttributeError: 'ManyRelatedManager' object > has no attribute 'full_name' > so, how to do ? > > An exemple: > > Class Person(models.Model): > full_nam

access an attribute of a target model in a many-to-many relationship

2022-11-29 Thread Issa N'golo Coulibaly
Hi, when I try to access an attribute of a target model in a many to many relationship, I get an error : AttributeError: 'ManyRelatedManager' object has no attribute 'full_name' so, how to do ? An exemple: Class Person(models.Model): full_name = models.CharField(max_l

Migration problems when using intermediate (through) table on many-to-many relationship

2020-06-18 Thread 'Rodrigo Estevão' via Django users
I've been facing a migration problem when using a *through* table on many-to-many relationship. When I create the migration using modles configured as follow ... # src/apps/core/valuation/models.py from django.utils import timezone from django.db import models from django.utils.transl

Many to many relationship

2020-03-17 Thread Soumen Khatua
Hi Folks, I'm using many to many relationship of a model by I'm not able update one person record. I don't know how to update a particular person's record when I'm using many to many relationship. Thank you Regards, Soumen -- You received this message because you are

Re: Django update field in many to many relationship

2019-02-14 Thread sum abiut
Thanks, The Leave_current_balance is from Leave_Balance model which why i haven't included it. I am not sure how to fix that. Sum On Fri, Feb 15, 2019 at 12:42 PM Simon Charette wrote: > Your DirectorForm model form doesn't include 'Leave_current_balance' in > it's Meta.fields > hence no form fie

Re: Django update field in many to many relationship

2019-02-14 Thread Simon Charette
Your DirectorForm model form doesn't include 'Leave_current_balance' in it's Meta.fields hence no form field is generated for it. Cheers, Simon Le jeudi 14 février 2019 17:50:21 UTC-5, suabiut a écrit : > > Hi, > > I have two models many to many relationships, I am trying to update the > field

Re: Django update field in many to many relationship

2019-02-14 Thread sum abiut
TraceBack: Request Method: POST Request URL: http://127.0.0.1:8000/unitDirectorForm/25/ Django Version: 1.11.18 Python Version: 2.7.15 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages',

Django update field in many to many relationship

2019-02-14 Thread sum abiut
Hi, I have two models many to many relationships, I am trying to update the field using a form. when a leave is submitted the director is notified by email. the director can login to the system to approve the leave using the form. once the leave is approved, I want to adjust the Leave_current_bala

Re: Getting complex query set with a many to many relationship in django

2018-02-23 Thread Andy
If you want to have Articles then get Article.objects.filter(section=xy).oder_by('section__order') Am Donnerstag, 22. Februar 2018 20:47:31 UTC+1 schrieb James Farris: > > I am trying to *get all article objects that are part of a section* in an > edition that is in an issue. I am stumped, even

Getting complex query set with a many to many relationship in django

2018-02-22 Thread James Farris
I am trying to *get all article objects that are part of a section* in an edition that is in an issue. I am stumped, even after looking at the documentation for django 2.x I can get all edit

Re: How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread Melvyn Sopacua
On Tuesday 13 June 2017 05:32:35 Stodge wrote: > Thanks. Yes I can use the m2m_changed signal but I need to know > specifically if a record was added or if it was removed, not just that > the m2m changed. So you haven't actually checked the callback signature[1] then (psst, the 'action' keyword a

Re: How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread Mike Stoddart
Ah of course, why didn't I think of that! Thanks. On Tue, Jun 13, 2017 at 8:41 AM, Larry Martell wrote: > On Tue, Jun 13, 2017 at 7:54 AM, Stodge wrote: > > I have a model with a many to many relationship. I need to know when a > > record is added to or removed f

Re: How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread Larry Martell
On Tue, Jun 13, 2017 at 7:54 AM, Stodge wrote: > I have a model with a many to many relationship. I need to know when a > record is added to or removed from the many to many. > > Is this possible? Thanks Perhaps you can use a database trigger. -- You received this message bec

Re: How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread Stodge
when a > record is added or removed. > > Nevertheless, you can make use of django signals (Thanks to melvyn). It > will be of great help. > > Yingi Kem > > On 13 Jun 2017, at 12:54 PM, Stodge > > wrote: > > I have a model with a many to many relationship. I ne

Re: How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread yingi keme
I dont particularly understand how you wish to be updated and know when a record is added or removed. Nevertheless, you can make use of django signals (Thanks to melvyn). It will be of great help. Yingi Kem > On 13 Jun 2017, at 12:54 PM, Stodge wrote: > > I have a model with a man

How to know when a record is added to or removed from a many to many relationship?

2017-06-13 Thread Stodge
I have a model with a many to many relationship. I need to know when a record is added to or removed from the many to many. Is this possible? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

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
/ On 13 January 2015 at 08:06, Tobias Dacoir wrote: > I'm trying to access the value of a many-to-many relationship during the > save() method of my model but it always returns the state it had before, > even though the first thing I do is call super.save(). > > class Data

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

2015-01-12 Thread Tobias Dacoir
I'm trying to access the value of a many-to-many relationship during the save() method of my model but it always returns the state it had before, even though the first thing I do is call super.save(). class Database(models.Model): ... questions = models.ManyToManyField(Que

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
_types.all() with a custom function >but this is starting to happen more frequently now and is becoming a real >pain. > > *Description:* > > I have two Django apps under one project. One of the apps makes use of > models in another app using a many-to-many relationship. >

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

Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
pain. *Description:* I have two Django apps under one project. One of the apps makes use of models in another app using a many-to-many relationship. This has been working smoothly for months, and in fact it works fine on my production machine but fails on my development machine. The scenario l

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2014-05-11 Thread João Pedro Melo
', 'last_name': > u'Jones', 'zip': 43215.0, 'title': u'Mr.', 'dob': '1956-12-29', > 'phone_primary': u'614-468-5940', 'state': u'OH', 'address': u'142, Quilly > Lane', &

Re: 3 table many to many relationship

2014-04-26 Thread Malik Rumi
Merci beaucoup On Wed, Apr 23, 2014 at 10:43 PM, Simon Charette wrote: > Django allows you to explicitly specify an intermediary model for > many-to-many relationships with the > `through` > optio

Re: 3 table many to many relationship

2014-04-23 Thread Simon Charette
Django allows you to explicitly specify an intermediary model for many-to-many relationships with the `through` option. class A(models.Model): b_set = models.ManyToMany('B', related_name='a_

3 table many to many relationship

2014-04-23 Thread Malik Rumi
I was designing the models I will need for this project. I designed an intermediate table for two models, A and B, and then started to sketch out an intermediate table for two other models, A and C, when I realized that these two intermediate tables both use A, and further, the information in

Re: data not saving through a many to many relationship

2013-11-20 Thread MikeKJ
Update: So editing AdviceLevel with def edit_advice(request): if not request.user.is_authenticated(): return HttpResponseRedirect('/user/login/') this_advice = request.POST.get('advice_id') sp = Specialism.objects.all().filter(advicelevel=this_advice) de = CRSDeliveryMetho

Re: data not saving through a many to many relationship

2013-11-20 Thread MikeKJ
Decided that the relationship advice = models.ManyToManyField(Advice, through='AdviceLevel') in the Organsiation model is redundant and removed it but it hasn;t made any difference to the now NON intermdiate model AdviceLevel -- You received this message because you are subscribed to the Goo

data not saving through a many to many relationship

2013-11-20 Thread MikeKJ
In the view do_advice the specialism, delivery_method and face_to_face_locations selections are not being saved into the corresponding tables of advicelevel_specialism

Re: how to model a reflexive many to many relationship?

2013-08-28 Thread slim
lank=False) My questions : *1*. How to get the scores of a user by module and display them by course, like that : -Course A *Module 1 score : 5 *module 2 : score : 8 ... -Course B *Module 1: score 7 *2*. I need to add a many to many relationship between course and

Re: how to model a reflexive many to many relationship?

2013-08-28 Thread Wissal Wbc
nk=False) *My questions :* *1*. How to get the scores of a user by module and display them by course, like that : -Course A *Module 1 score : 5 *module 2 : score : 8 ... -Course B *Module 1: score 7 *2*. I need to add a many to many relationship between course and user bec

how to model a reflexive many to many relationship?

2013-08-26 Thread slim
I'm trying to build an e-learning platform I have *users (Utilisateur) *who can take several *courses* ,each course have several *modules* and a module can be in several courses a user can be a student or teacher or admin, a student is "managed" by a teacher or several and a teacher can also be

Many to many relationship MongoDB

2013-05-27 Thread Hélio Miranda
I'm trying to make a many to many relationship in mongodb using tastypie and mongoengine. But I'm having some difficulty. I have players that can have various clubs and clubs that have multiple players. What I'm doing is this: *class Club(mongoengine.Document):* *ClubNam

Re: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Thomas Lockhart
tance of B). tia - Tom On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart mailto:tlockhart1...@gmail.com>> wrote: I've got two models with one having a many-to-many relationship with the other: class A(models.Model): name = models.CharField(&quo

Re: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Kurtis Mullins
art > wrote: > >> I've got two models with one having a many-to-many relationship with the >> other: >> >> class A(models.Model): >> name = models.CharField("name") >> >> class B(models.Model): >> haveone = models.ManyToManyFie

Re: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Kurtis Mullins
Have you tried b.haveone.all()? On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart wrote: > I've got two models with one having a many-to-many relationship with the > other: > > class A(models.Model): > name = models.CharField("name") > > class B(models.Model):

Obtaining objects from a many-to-many relationship

2012-06-01 Thread Thomas Lockhart
I've got two models with one having a many-to-many relationship with the other: class A(models.Model): name = models.CharField("name") class B(models.Model): haveone = models.ManyToManyField(A) What is the idiom for getting all instances of A which are referenced in B? I f

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
> > > >        instance = Customer() > > > > >        for form in form_list: > > > > >            for field, value in form.cleaned_data.iteritems(): > > > > >          

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
instance = Customer() > > > >for form in form_list: > > > >for field, value in form.cleaned_data.iteritems(): > > > >if field != 'category': > > > > setattr(instance, field, value

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
gt;                    setattr(instance, field, value) > > > ----- > > > > I'm sure there is a MUCH more elegant way of getting just the categories > > > from the forms and field/value pairs, this is brute force (n

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
gt; > show code that could get the specific forms and field/values for > categories. > > > > Furbeenator > > > > > > > > > > > > > > > > On Wed, Nov 2, 2011 at 10:28 AM, youpsla wrote: >

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Wed, Nov 2, 2011 at 10:28 AM, youpsla wrote: > > Hello, > > i'm currently doning a website where user can register (without > > password, without auth module of Django). They put some informations > > and at the end (Step5Form) do multiple choices by clicking on > >

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
gt; > i'm currently doning a website where user can register (without > > password, without auth module of Django). They put some informations > > and at the end (Step5Form) do multiple choices by clicking on > > checkboxes. When

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
ently doning a website where user can register (without > password, without auth module of Django). They put some informations > and at the end (Step5Form) do multiple choices by clicking on > checkboxes. When I click on validate on the last step I've "instance > needs to have

Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
e a primary key value before a many-to-many relationship can be used" error. I've search the web to find a solution but . :- ( Here is my code: models.py for Customer (in clients application) - class Customer (models.Model): email_ad

Re: View to edit many-to-many relationship with extra fields

2010-10-02 Thread ses1984
; >http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-o... > > > I have two models with a many-to-many relationship through another > > table with extra fields. In this case, I have one extra field which > > represents the weight of the relationship. > > &

Re: View to edit many-to-many relationship with extra fields

2010-10-02 Thread Felix Dreissig
te: > http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships > > I have two models with a many-to-many relationship through another > table with extra fields. In this case, I have one extra field which > represents the weight of the relationship. > > I&

View to edit many-to-many relationship with extra fields

2010-10-01 Thread ses1984
http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships I have two models with a many-to-many relationship through another table with extra fields. In this case, I have one extra field which represents the weight of the relationship. I'm working

Re: Is there a way to easily implement the 'choose box' in a many to many relationship within the admin site, similar to the 'Change User' interface

2010-09-22 Thread Laszlo Antal
I think what you are looking for is filter_horizontal. Add it to your in your modeladmin class. lzantal On Sep 22, 2010, at 7:57 PM, Markitos wrote: > For some reason django only provides a simple list in a many to many > relationship displayed in the admin interface of model you'

Is there a way to easily implement the 'choose box' in a many to many relationship within the admin site, similar to the 'Change User' interface

2010-09-22 Thread Markitos
For some reason django only provides a simple list in a many to many relationship displayed in the admin interface of model you've created yourself. To select multiple values from this list you need to hold the shift key down. Its so clumsy. The admin interface for maintaining the

ModelAdmin save_model method not saving many to many relationship value

2010-06-05 Thread Ryno in Stereo
I have a Page model that uses the sites framework and I've added a save_model method on its admin class to check if the template or sites collections are empty. If they are, I want to populate them with default values. Why not do this in the model declaration? - I can't seem to populate a defau

Re: How to display a _unicode_ string when involving a many to many relationship?

2010-04-01 Thread Daniel Roseman
in view, like so: > > Sample1 >       tag1       value1 >       tag2       value2 >       tag3       value3 > sample2 >      tag1        value4 >      tag2        value5 > > Sample and tag are manytomany, and each tag should have one value at a > time.  It's this

Re: How to display a _unicode_ string when involving a many to many relationship?

2010-03-31 Thread Daniel
e3 sample2 tag1value4 tag2value5 Sample and tag are manytomany, and each tag should have one value at a time. It's this many to many relationship that I'm having trouble with. Am I to use inlines, the "through" attribute, write a custom method, or do

Re: How to display a _unicode_ string when involving a many to many relationship?

2010-03-31 Thread Daniel Roseman
On Mar 31, 8:26 pm, Daniel wrote: > Hi guys, > > I'd appreciate a little advice on the following: > > I'm trying to get a unicode string representation of my model named > Sample.  But that Sample model has a many to many relationship with > another model, Facet.

How to display a _unicode_ string when involving a many to many relationship?

2010-03-31 Thread Daniel
Hi guys, I'd appreciate a little advice on the following: I'm trying to get a unicode string representation of my model named Sample. But that Sample model has a many to many relationship with another model, Facet. So Sample's unicode method: def _

django admin instance needs to have a primary key value before a many-to-many relationship can be used

2010-03-11 Thread JeffH
, I try to create a FactSet and get "FactSet instance needs to have a primary key value before a many-to-many relationship can be used" As if it's trying to save items in the join table before saving the FactSet item itself. I'm running Django 1.1.1. I'm probably overlooking s

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

Many-To-Many Relationship with intermediate table

2010-03-07 Thread jorge.silva
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 as I'm here I'm also trying to learn something ;) My situation is

Re: Migrating Many-To-Many Relationship

2010-01-13 Thread Tomasz Zieliński
On 12 Sty, 22:53, David Nolen wrote: > When migrating an existing db how do you create a proper join table > for a ManyToMany field. I think I've got it mostly worked out except > for the bit that looks like this in Django generated SQL: > > CREATE TABLE `blog_posts_authors` ( >   `id` int(11) N

Migrating Many-To-Many Relationship

2010-01-12 Thread David Nolen
When migrating an existing db how do you create a proper join table for a ManyToMany field. I think I've got it mostly worked out except for the bit that looks like this in Django generated SQL: CREATE TABLE `blog_posts_authors` ( `id` int(11) NOT NULL AUTO_INCREMENT, `post_id` int(11) NOT NUL

Re: Should (or can) you have many to many relationship with abstract base class

2009-10-17 Thread Peter Mott
rying to develop my models and I have a sort > of general philosophical question about what the ORM is capable of, > and how it should be used. > > So lets say, for example you are designing a website for a network of > people who take care of pets. The caretaker would have a man

Re: Should (or can) you have many to many relationship with abstract base class

2009-10-16 Thread Kurt Neufeld
> and how it should be used. > > So lets say, for example you are designing a website for a network of > people who take care of pets. The caretaker would have a many-to-many > relationship with pets, since one caretaker could take of more than > one pet, and one pet might very

Should (or can) you have many to many relationship with abstract base class

2009-10-16 Thread Chip Grandits
lets say, for example you are designing a website for a network of people who take care of pets. The caretaker would have a many-to-many relationship with pets, since one caretaker could take of more than one pet, and one pet might very well have more than one caretaker. Of course pet is an

Re: Thoughts on many-to-many relationship

2009-07-31 Thread Wyley
Hi Prabhu, You are correct about how to fix the error you're seeing, but I think you're confused about why you're seeing it. As with all relationships, an object in a many-to-many relationship must have a primary key value before you can point a foreign key value at it from anoth

Thoughts on many-to-many relationship

2009-07-31 Thread prabhu S
Hi All, When I try to create a Group (django.contrib.auth.models.Group) dynamically, I get the below error. 'Group' instance needs to have a primary key value before a many-to- many relationship can be used. This is because I am trying to add permissions to the group object and tryi

Re: Removing objects with many-to-many relationship

2009-07-30 Thread Brian May
On Thu, Jul 30, 2009 at 04:47:05AM -0700, rudy wrote: > class ContentTopic(models.Model): > name = models.CharField() > code = models.CharField() > > class ContentItem(models.Model): > topic = models.ManyToManyField(ContentTopic, db_index=True, > blank=True, related_name='content_item

Re: Removing objects with many-to-many relationship

2009-07-30 Thread Steve Schwarz
On Thu, Jul 30, 2009 at 6:47 AM, rudy wrote: > > Hello, everyone! > > I'd like to remove some object with many-to-many relationship from > Django admin interface. Standard removing also removes all related > objects and the list of removed objects displayed on confirmat

Removing objects with many-to-many relationship

2009-07-30 Thread rudy
Hello, everyone! I'd like to remove some object with many-to-many relationship from Django admin interface. Standard removing also removes all related objects and the list of removed objects displayed on confirmation page. But I don't need to remove related objects! Assume we have Co

Formsets with many to many relationship

2009-07-16 Thread Justin
I am trying to figure out the best way to have an inline formset with a many to many relationship. Right now I am the relationship is through a intermediate model as shown here in the docs http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships. It

Re: filtering the join table in a many-to-many relationship

2009-06-01 Thread Ben Adida
Sam, Thanks for the rapid response. I think I see what you mean, but I'm not sure it solves my problem. Looking at the example you sent, here's how my problem would look in that context: - Friendship has an extra column called "degree_of_friendship", which can be "meh", "good", or "great" - I w

Re: filtering the join table in a many-to-many relationship

2009-06-01 Thread Sam Chuparkoff
On Mon, 2009-06-01 at 16:01 -0700, Ben Adida wrote: > I have a ManyToMany self relationship with a custom join table (I > don't think the self-reference is important to the problem, but it > might be, so I'm mentioning it): > > class Documents > related_docs = models.ManyToManyField("self", > t

filtering the join table in a many-to-many relationship

2009-06-01 Thread Ben Adida
Hi folks, I've looked through the forum and can't find an answer to this one. I have a ManyToMany self relationship with a custom join table (I don't think the self-reference is important to the problem, but it might be, so I'm mentioning it): class Documents related_docs = models.ManyToManyF

Re: Using CheckboxSelectMultiple with a many to many relationship.

2009-05-30 Thread Steve Holden
julianb wrote: > On Aug 22, 4:32 pm, acreek wrote: >> I just have not figured out the correct way to pass along the coupons >> that are a part of the Flyer model. Can anyone give me a hint on how >> to go about this properly? > > Here's how I'd do it: > http://dpaste.com/hold/73229/ > > Now you

Gathering related objects for a set of objects, across a many-to-many relationship

2009-05-07 Thread Steve Howard
Hi, I'm wondering what the best/canonical way is to gather the set of related objects for each of a number of objects, going across a Many-to-Many relationship. Here's an example, since that probably didn't make sense by itself: class Label(Model): name = CharField(...) cl

Re: Question about INNER JOIN vs LEFT JOIN and some strange issue when model binds to in self through many-to-many relationship.

2009-02-09 Thread Malcolm Tredinnick
On Mon, 2009-02-09 at 06:56 -0800, AlexMVdovin wrote: > At first step I will describe my models: > > class Meter(models.Model): > id = models.IntegerField(primary_key=True) > > some stuff here... > > collector = models.ManyToManyField("self", > through='MeterCollector', symm

Question about INNER JOIN vs LEFT JOIN and some strange issue when model binds to in self through many-to-many relationship.

2009-02-09 Thread AlexMVdovin
At first step I will describe my models: class Meter(models.Model): id = models.IntegerField(primary_key=True) some stuff here... collector = models.ManyToManyField("self", through='MeterCollector', symmetrical=False) class MeterCollector(models.Model): meter = models.F

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-22 Thread Keyton Weissinger
Hi Malcolm, Thank you VERY much for taking the time to explain this to me. It makes perfect sense and since yesterday I've delved a bit deeper (than ever) into the django code itself to understand a little more. You are ABSOLUTELY right to point out that I'm in user-beware country. I don't apolog

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-22 Thread Malcolm Tredinnick
On Wed, 2009-01-21 at 19:38 -0800, Keyton Weissinger wrote: > OK. I figured it out and it was VERY STRANGE. Maybe some one reading > this can tell me WWWHHHYYY my solution works. For now, it's voodoo to > me... You're going to kick yourself after this. The reason for the failure turns out to be r

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
x27;OH', 'address': u'142, Quilly >>> Lane', 'type': u'Student', 'email': u'miles.l.ye...@spambob.com'} >>> mystudent = Student(**mydict) The import of ImportOptionsForms, it turns out, called the above code. OK. T

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
Hmm. Thanks Martin. I will try with the SVN HEAD revision. I have already tried the Student(**mydict) approach and get the exact same issue. I will test tonight and respond. Thanks very much for taking time... Keyton On Jan 21, 3:24 pm, Martin Conte Mac Donell wrote: > Again, i can't reproduce

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Martin Conte Mac Donell
Again, i can't reproduce your problem. It's working using SVN HEAD with your model and this view: http://dpaste.com/111590/. Could you try to use that dict and Student(**mydict) instead of "model_import_info.model_for_import.objects.create" ? Regards, M On Wed, Jan 21, 2009 at 3:06 PM, Keyton W

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
I'm on django 1.0.1 (NOT 1.0.2). Do you think that has any impact on this problem? I will try upgrading tonight. Any other ideas? K On Jan 21, 8:33 am, Keyton Weissinger wrote: > More information... > > I stuck the following into my code at the same place the other code is > bombing. I did thi

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
More information... I stuck the following into my code at the same place the other code is bombing. I did this just to make sure that I wasn't getting anything weird in the dictionary here that I wasn't getting in the command line. mydict = {'city': u'Columbus', 'first_name': u'Miles', 'last_nam

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
Oh, and I have printed the import_object_dict, it has exactly what I think it should... Argh! ;-) K On Jan 21, 12:12 am, Martin Conte Mac Donell wrote: > On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger wrote: > > > Oh and just to re-state, this exact same code works like a champ on > > imp

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-21 Thread Keyton Weissinger
Hi Martin, Thanks for the suggestion. I've tried it both ways to no avail. All, Here's the code from django.db.models.base.py (in the Model.__init__) where the trouble seems to start (around line 224): # Now we're left with the unprocessed fields that *must* come from # keyword

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Martin Conte Mac Donell
On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger wrote: > > Oh and just to re-state, this exact same code works like a champ on > import of School or Parent data (neither of which have a ManyToMany > field). > > Keyton I can't reproduce this exception. Try to print import_object_dict just befo

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Keyton Weissinger
import_object_dict={'address': u'142, Quilly Lane', 'city': > > > u'Columbus', 'dob': '1956-12-29', 'email': > > > u'miles.l.ye...@spambob.com', 'first_name': u'Yeung', '

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Keyton Weissinger
#x27;: '1956-12-29', 'email': > > u'miles.l.ye...@spambob.com', 'first_name': u'Yeung', 'phone_primary': > > u'614-468-5940', 'school': , > > 'state': u'OH', 'title': u

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Malcolm Tredinnick
pe': u'Student', 'zip': 43215.0} > > Note that I am NOT yet trying to SAVE the Student object, just > instantiate it. > > But every time I try to instantiate this new Student, I get the > following error: > 'Student' instance needs to have a

Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2009-01-20 Thread Keyton Weissinger
'phone_primary': u'614-468-5940', 'school': , 'state': u'OH', 'title': u'Mr.', 'type': u'Student', 'zip': 43215.0} Note that I am NOT yet trying to SAVE the Student object, just instantiate

Implementing "Friends application" using many-to-many relationship on self

2008-10-07 Thread NEX
Hi everybody, I was trying to add friend network feature to my site. But I have to use User model from django.contrib.auth . I tried extending User model and added a many-to-many field in the extended model. But then I was unable to retrieve all the connections(friends) using the "_set" feature. P

Re: How to add more information to a many-to many relationship related to the model itself with 'symmetrical = True'

2008-10-06 Thread Matrixer
and wonder is there other solution --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to

  1   2   >