Initialize a formset with manytomany relationship

2020-04-21 Thread rahul sharma
I have two models connected by manytomany relationship and I am trying to use `formset` to create a dynamic form. I am able to save the form but the problem arise when I am trying to edit the saved instance, I don't know how to properly pass the instance to the formset such that it show

Re: ManyToMany relationship with through_fields and Admin

2018-08-28 Thread akash kandpal
What changes you did ? Regards, Akash Kandpal. On Wed, Aug 29, 2018, 12:34 AM Vincent wrote: > I figured it out : > > from django.db import models > from django.contrib.auth.models import User > > > # Create your models here. > class Events(models.Model): > Name = models.CharField(max_length=6

Re: ManyToMany relationship with through_fields and Admin

2018-08-28 Thread Vincent
I figured it out : from django.db import models from django.contrib.auth.models import User # Create your models here. class Events(models.Model): Name = models.CharField(max_length=64) Date = models.DateTimeField() Description = models.CharField(max_length=200) Admin = models.ForeignKey(Use

ManyToMany relationship with through_fields and Admin

2018-08-27 Thread Vincen
Hello, I'm new to Django and i'm trying to made a simple app in which users can attend to an event. I'm trying to have this manageable through the admin site but i get the following error : : (admin.E202) fk_name 'attendees' is not a ForeignKey to 'evenement.Events'. My goal is to have an inte

Re: ManyToMany relationship

2015-08-23 Thread Carlos A. Carnero Delgado
El ago. 23, 2015 3:34 PM, "venkat" escribió: > > How can i overcome this?? > I think you should be using the related_name property in the ManyToMany fields of the model. Giving different names, of course, since that maybe the cause of your problems. It is documented, BTW. HTH, Carlos. -- You r

Re: ManyToMany relationship

2015-08-23 Thread James Schneider
> I have two models as follows > > > class Person(models.Model): > first_name = models.CharField(max_length=30) > last_name = models.CharField(max_length=30) > date_of_birth = models.DateField() > height = models.IntegerField() > def __unicode__(self): > return '%s %s' %(self.first_name, self.last_

ManyToMany relationship

2015-08-23 Thread venkat
I have two models as follows class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) date_of_birth = models.DateField() height = models.IntegerField() def __unicode__(self): return '%s %s' %(self.first_name, self.last_name) class Movie

Re: FieldError with ManyToMany relationship in ModelAdmin list_display item when server is not in DEBUG mode

2014-03-10 Thread Andrew Niccolo Pangilinan
Hi, Have you had any solutions to this yet? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, sen

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-23 Thread Timothy W. Cook
ysets/#django.db.models.**query.QuerySet.get_or_create<https://docs.djangoproject.com/en/1.5/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create> > > hth > > Mike > > >> >> >> >> >> On Tuesday, October 22, 2013 11:59:14 PM UTC+2, Ti

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-23 Thread Timothy W. Cook
someone point me to where this is explained in the docs (1.6)? >> >> I have a ManyToMany relationship in my models between Author and Paper. >> >> I am processing an XML file to create records for Papers. >> >> I want to check if an Author exists and if not cre

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-22 Thread Mike Dewhirst
ect.com/en/1.5/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create hth Mike On Tuesday, October 22, 2013 11:59:14 PM UTC+2, Timothy W. Cook wrote: Can someone point me to where this is explained in the docs (1.6)? I have a ManyToMany relationship in my models between Author and Paper. I am processin

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-22 Thread Pepsodent Cola
11:59:14 PM UTC+2, Timothy W. Cook wrote: > > Can someone point me to where this is explained in the docs (1.6)? > > I have a ManyToMany relationship in my models between Author and Paper. > > I am processing an XML file to create records for Papers. > > I want to check i

HOWTO: Create a ManyToMany Relationship?

2013-10-22 Thread Timothy W. Cook
Can someone point me to where this is explained in the docs (1.6)? I have a ManyToMany relationship in my models between Author and Paper. I am processing an XML file to create records for Papers. I want to check if an Author exists and if not create the record. This was quite easy for Foreign

Spreadsheet-like with ManyToMany relationship

2013-05-08 Thread Kismet 010
I need to mimic a *spreadsheet* with Django for a simple school app like '*task/student > score*', so I have this models: - Actividad (tasks) - Alumno (students) > M2M to 'Actividad' through 'Calificacion' - Calificacion (scores) I don't know how to proceed, if I need a formset or wh

Re: ManyToMany relationship and raw sql queries

2013-05-01 Thread Siddharth Ghumre
Hi , Did you try python psycopg2. A simple deomostration. Ex:- import psycopg2 conn=psycopg2.connect("dbname='xxx' user='xxx' host='localhost' password='xxx'") cur = conn.cursor() query="""SELECT * FROM bookmarkmanager_bookmark b ' 'LEFT JOIN bookmarkmanager_bookmark_tags bt

Re: ManyToMany relationship and raw sql queries

2013-04-27 Thread Marc R
did you use Bookmark.objetcs.all().select_related() ? As this will create a join query... at least for your model you show in the message I have found that for very complex joins, you need to use raw query and not a Model. On Thursday, April 25, 2013 10:44:28 AM UTC-4, Matthieu Bouron wrote

Re: ManyToMany relationship and raw sql queries

2013-04-25 Thread Matthieu Bouron
On Thursday, April 11, 2013 5:39:57 PM UTC+2, Tom Evans wrote: > > On Thu, Apr 11, 2013 at 3:42 PM, Matthieu Bouron > > wrote: > > Hello, > > > > Is there a way to handle many-to-many relationship with raw sql queries > ? > > I have the following model: > > > > from django.db import models

Re: ManyToMany relationship and raw sql queries

2013-04-11 Thread Tom Evans
On Thu, Apr 11, 2013 at 3:42 PM, Matthieu Bouron wrote: > Hello, > > Is there a way to handle many-to-many relationship with raw sql queries ? > I have the following model: > > from django.db import models > > class Tag(models.Model): > name = models.CharField(max_length=512, unique=True) > >

ManyToMany relationship and raw sql queries

2013-04-11 Thread Matthieu Bouron
Hello, Is there a way to handle many-to-many relationship with raw sql queries ? I have the following model: from django.db import models class Tag(models.Model): name = models.CharField(max_length=512, unique=True) class Bookmark(models.Model): link = models.CharField(max_length=512)

FieldError with ManyToMany relationship in ModelAdmin list_display item when server is not in DEBUG mode

2013-03-14 Thread Eric Bass
I can not for the life of me figure out why my list_display works when the django server is in DEBUG=True but not when it is in DEBUG=False. I am using Django 1.4.3 (mod_wsgi 3.4/Python 2.7) Here is the partial stack trace... File "/home/difuzi0n/webapps/wedding/lib/python2.7/django/db/m

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT
I found where the problem is... It is not a problem in the ManyToManyField but in the intermediate table. Django refused that my intermediate table doesn't have an unique id ! So, in the sql which created django, it created automatically an unique id named "id", but in my database I didn't cr

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT
Ok, it is still not working. Django can't find the intermediate table. And I can't put an "inlines" into an "inlines" ! My RunHasSample are already in a field "inlines" in the RunAdmin, so I cannot put the lines in an "inlines" field into the class RunHasSamplesInLine -- You received this me

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT
> > In [10]: run1= Run(project=Project.objects.get(pk=1), > sequencing_type=SequencingType.objects.get(pk=1)) > In [11]: run1.save() > In [12]: Run.objects.all() Out[12]: [] > In [13]: s1=RunHasSample(run=run1, sample=Sample.objects.get(pk=1), > dna_quantification_ng_per_ul=1) > In [14]

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-19 Thread smcoll
It's true: the Run model does not have a "lines" attribute; the RunHasSample model does. Also, `s1` is not a Line nor a Sample, it's an instance of the intermediary RunHasSample. So you're not going to be able to directly add a Line instance to a Run instance- you'll have to add it to the rel

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-19 Thread Louise OTT
> > In [10]: run1= Run(project=Project.objects.get(pk=1), >> sequencing_type=SequencingType.objects.get(pk=1)) > > >> In [11]: run1.save() > > >> In [12]: Run.objects.all() > > Out[12]: [] > > >> In [13]: s1=RunHasSample(run=run1, sample=Sample.objects.get(pk=1), >> dna_quantification_ng_per_ul=

Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-19 Thread smcoll
didn't get any answer. I think > this is something really simple. I just need to fullfill my database via a > ManyToMany field... Why doesn't it work ? I don't know, but I am > desperate... > > I give you the link : > http://stackoverflow.com/questions/12918651/addi

Re: presenting a manytomany relationship in a tabular way

2012-08-03 Thread goabbear
Hi, thanks for the links, I have look at these docs but I can't figure out how to mix actions with a spreadsheet like presentation :-/ Is it possible to create admin forms like we can standards forms? Another way I could try is to use filter_horizontal (I like this presentation), but for a m2m re

Re: presenting a manytomany relationship in a tabular way

2012-07-31 Thread Melvyn Sopacua
On 31-7-2012 11:33, goabbear wrote: > There's 3 tables, user(name, mail), mailinglist(name) and an intermediate > table subscription where are stored all the users joining some > mailinglists. > How can I present the "subscription" table to the admins like a > spreadsheet, where the first colu

presenting a manytomany relationship in a tabular way

2012-07-31 Thread goabbear
Hi all, I start with django but after some searches I can't do what I want in the admin section of my app. There's 3 tables, user(name, mail), mailinglist(name) and an intermediate table subscription where are stored all the users joining some mailinglists. How can I present the "subscription"

Re: ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Ignacio Soto
ok, it looks very nice i will try and let you know.. thanks 2012/7/24 Tomas Neme > > > as shown in the picture, this i could do by add a method in the model > > getTienda1 and return the stock and do it for each store, but i want it > to > > be created dinamically because the user could create a

Re: ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Tomas Neme
> as shown in the picture, this i could do by add a method in the model > getTienda1 and return the stock and do it for each store, but i want it to > be created dinamically because the user could create a new store and it will > not be there. > > so this is my cuestion: can i do that? Interesting

ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Ignacio Soto
Hey guys i have an issue, i don know if it really can be done. im using django 1.3 i have a model producto(product) and Tienda(store) and a product could be in one or more stores, so i created a many to many relationship but y have a stock in each store, so i use the intermediary model Produc

Linking ManyToMany relationship to dynamically update from values of an html SelectBox

2011-11-08 Thread Newton B
I have the following models class Group(models.Model): name = models.CharField(max_length=32, unique=True) class Subgroup(models.Model): name = models.CharField(max_length=32, unique=True) group = models.ForeignKey(Group) class KeywordsList(models.Model): name = models.CharField(

Re: Form/view for ManyToMany relationship

2011-03-05 Thread werefr0g
Le 05/03/2011 00:01, kgardenia42 a écrit : Thanks. This is pretty close to what I'm doing. However, I'd like to not have to write all the associated boiler-plate (i.e. I have to figure out if any film/actor relationships have been deleted since the last save and explicitly write code to remo

Re: Form/view for ManyToMany relationship

2011-03-04 Thread kgardenia42
On Fri, Mar 4, 2011 at 1:08 PM, werefr0g wrote: > On Thu, Mar 3, 2011 at 11:50 AM, werefr0g wrote: > > Hello, > > Sorry if I misunderstand, but what is wrong about using a ModelForm on your > Film bounded to the film instance? > > My bad... how did I missed the intermediary model involved in the

Re: Form/view for ManyToMany relationship

2011-03-04 Thread werefr0g
sorry, I failed to pass the request to the view's function,.. Le 04/03/2011 22:08, werefr0g a écrit : On Thu, Mar 3, 2011 at 11:50 AM, werefr0g wrote: Hello, Sorry if I misunderstand, but what is wrong about using a ModelForm on your Film bounded to the film instance? My bad... how did I miss

Re: Form/view for ManyToMany relationship

2011-03-04 Thread werefr0g
On Thu, Mar 3, 2011 at 11:50 AM, werefr0g wrote: Hello, Sorry if I misunderstand, but what is wrong about using a ModelForm on your Film bounded to the film instance? My bad... how did I missed the intermediary model involved in the ManyToMany relashionship. Sorry. When I tried that I kept

Re: Form/view for ManyToMany relationship

2011-03-03 Thread kgardenia42
On Thu, Mar 3, 2011 at 11:50 AM, werefr0g wrote: > Hello, > > Sorry if I misunderstand, but what is wrong about using a ModelForm on your > Film bounded to the film instance? When I tried that I kept running into this error: "Cannot set values on a ManyToManyField which specifies an intermediar

Re: Form/view for ManyToMany relationship

2011-03-03 Thread werefr0g
Hello, Sorry if I misunderstand, but what is wrong about using a ModelForm on your Film bounded to the film instance? Regards -- 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.

Form/view for ManyToMany relationship

2011-03-03 Thread kgardenia42
Hi list, Considering this schema (below) I'm trying to figure out how to create a ModelForm which links Actors to Films (all known actors in a multi- select widget). I can't seem to figure out how to do this in a way that ModelForm will do the heavy lifting. I would like to make a page (e.g. /fi

Re: Query involving manytomany relationship

2011-03-02 Thread gontran
I will answer to myself (after having been trying for over an hour, I found the answer a couple of minutes after posting my question) products = Product.objects.filter(productlicence__client=client).distinct() -- You received this message because you are subscribed to the Google Groups "Django

Re: Query involving manytomany relationship

2011-03-02 Thread gontran
Sorry for the question, but I've been trying for over an hour and just when I post this message, I find the answer!! Here is it: products = Product.objects.filter(productlicence__client=client).distinct() Hope that it will be useful -- You received this message because you are subscribed to the

Query involving manytomany relationship

2011-03-02 Thread gontran
Hello everybody this is maybe simple but I can't succeed in making a query. here is my model: class Client(models.Model): user= models.OneToOneField(User) product_licence= models.ManyToManyField('ProductLicence', blank=True, null=True) class ProductLicence(models.

Re: intermediate table in manytomany relationship not created

2010-08-06 Thread bksfu
Thanks, Carlos! Brian On Aug 5, 12:59 pm, Carlos Daniel Ruvalcaba Valenzuela wrote: > There is an option to default to InnoDB tables on the configuration: > > http://docs.djangoproject.com/en/dev/ref/databases/#creating-your-tables > > Regards, > Carlos Daniel Ruvalcaba Valenzuela > > On Thu, Au

Re: intermediate table in manytomany relationship not created

2010-08-05 Thread Carlos Daniel Ruvalcaba Valenzuela
There is an option to default to InnoDB tables on the configuration: http://docs.djangoproject.com/en/dev/ref/databases/#creating-your-tables Regards, Carlos Daniel Ruvalcaba Valenzuela On Thu, Aug 5, 2010 at 12:48 PM, bksfu wrote: > When Django created the above tables, they were created with

Re: intermediate table in manytomany relationship not created

2010-08-05 Thread bksfu
When Django created the above tables, they were created with the MyISAM engine. If the intermediate table has to have foreign keys back to the Phone and Room tables, this would be illegal from MySQL's perspective, which can apparently only form foreign key constraints between InnoDB tables. If th

intermediate table in manytomany relationship not created

2010-08-05 Thread bksfu
Hi, I have the following model: -- from django.db import models class Phone(models.Model): id = models.AutoField(primary_key=True, db_column='id') type = models.CharField(max_length=1, db_column='Type', null=False, blank=False) status = models.CharField(max_length=1, db_column

Queryset returning modelinstances of manytomany relationship?

2010-07-12 Thread Doug Warren
Say I have 2 classes as: class Bar(models.Model): prop = IntegerField() class Foo(models.Model): bar = ManyToManyField(Bar) I want to return a QuerySet containing model instances of bar that match the query: QuerySetOfFoos.objects.filter(bar__prop__gt=0) Is there an easy way to do this?

Admin.py: Creating double ended ManyToMany relationship

2010-06-29 Thread glacasse
I would also like to select multiple Foo objects from Bar in the admin page. Is that possible? How can I do that? Thank you! -- View this message in context: http://old.nabble.com/Admin.py%3A-Creating-double-ended-ManyToMany-relationship-tp29024100p29024100.html Sent from the django-users mailing

Admin.py: Creating double ended ManyToMany relationship

2010-06-29 Thread glacasse
Hi everyone, considering these two classes. class Foo(models.Model): bar = models.ManyToManyField(Bar, blank=True, null=True, default=None) class Bar(models.Model): pass I have a many to many relationship in my admin page so I can select multiple Bar objects on Foo, which is good, but I

Re: Partial ModelForm produces empty var on ManyToMany relationship

2010-04-27 Thread Tom Evans
On Tue, Apr 27, 2010 at 9:50 AM, Florian Le Goff wrote: > Hi, > > I'm using Django's 1.1.1 official release and I'm trying to build a > partial form, using ModelForm, with only one field, of the > ManyToManyField type. > > If my partial form's Meta class "fields" attribute contains several > attri

Partial ModelForm produces empty var on ManyToMany relationship

2010-04-27 Thread Florian Le Goff
Hi, I'm using Django's 1.1.1 official release and I'm trying to build a partial form, using ModelForm, with only one field, of the ManyToManyField type. If my partial form's Meta class "fields" attribute contains several attributes names, everything is working pretty smoothly. My form is produced

Re: Django 1.2b multidatabase + manytomany relationship

2010-03-26 Thread Russell Keith-Magee
On Wed, Mar 24, 2010 at 6:16 PM, mbdtsmh wrote: > Hi All, still trying to get my head around the multi db stuff in 1.2 > release. > > Here is my problem that I have hit upon. > > I have a model in my default db... > > class Set1(models.Model): >    create_date = models.DateTimeField(auto_now_add='

Django 1.2b multidatabase + manytomany relationship

2010-03-24 Thread mbdtsmh
Hi All, still trying to get my head around the multi db stuff in 1.2 release. Here is my problem that I have hit upon. I have a model in my default db... class Set1(models.Model): create_date = models.DateTimeField(auto_now_add='True') last_update = models.DateTimeField(auto_now='True',

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') synonyms = model

Re: Ordering over ManyToMany relationship omits records

2009-11-27 Thread Ramiro Morales
On Thu, Nov 26, 2009 at 6:31 PM, David wrote: > > >>> Listing.objects.order_by("book__courses") > > gives me Listings with id's (5, 1, 3, 5, 2, 4), and > > >>> Listing.objects.order_by("-book__courses") > > gives me Listings with id's (6, 4, 5, 2, 5,1) On Thu, Nov 26, 2009 at 6:38 PM, David wrot

Re: Ordering over ManyToMany relationship omits records

2009-11-26 Thread David
as if the duplicate id "swallowing up" the missing records. I have no clue why though... hope these details help clarify my problem. On Nov 26, 1:31 pm, David wrote: > When I order over a ManyToMany relationship, certain records will not > appear. The record which disappears chan

Ordering over ManyToMany relationship omits records

2009-11-26 Thread David
When I order over a ManyToMany relationship, certain records will not appear. The record which disappears changes depending on the order by which I sort it. Specifically: >>> Listing.objects.order_by("book__courses") gives me Listings with id's

Re: How do you remove a manytomany relationship in django?

2009-08-19 Thread Ray
e' I'm at a loss as to how I'm supposed to update these relationships Ray On Aug 18, 7:03 pm, Daniel Roseman wrote: > On Aug 18, 9:49 pm, Ray wrote: > > > I know in the backend, a manytomany relationship is essentially a join > > table, but there seems to be no ea

Re: How do you remove a manytomany relationship in django?

2009-08-19 Thread Daniel Roseman
On Aug 19, 10:09 pm, Ray wrote: > Hi, > thanks for the fast response! I'm trying to use the remove function > right now just like this sample code: > > # And from the other end>>> p2.article_set.remove(a5) > >>> p2.article_set.all() > [] > >>> a5.publications.all() > > [] > > fromhttp://www.djang

Re: How do you remove a manytomany relationship in django?

2009-08-18 Thread Daniel Roseman
On Aug 18, 9:49 pm, Ray wrote: > I know in the backend, a manytomany relationship is essentially a join > table, but there seems to be no easy way to delete relationships from > it. The only remove option is made only for ForeignKey relationships. > Is there a workaround? Why would d

Re: How do you remove a manytomany relationship in django?

2009-08-18 Thread Daniel Roseman
On Aug 18, 9:49 pm, Ray wrote: > I know in the backend, a manytomany relationship is essentially a join > table, but there seems to be no easy way to delete relationships from > it. The only remove option is made only for ForeignKey relationships. > Is there a workaround? Why would d

How to use inlineformset with a manytomany relationship

2009-08-18 Thread Andew Gee
Hi, Is there a way to create an inlineformset for two models with manytomany relationship. I have created: class Person(models.Model): name = models.CharField phone= models.ManyToMany(Phone) class Phone(models.Model): PHONE_CHOICES(('H','Home'),(

How do you remove a manytomany relationship in django?

2009-08-18 Thread Ray
I know in the backend, a manytomany relationship is essentially a join table, but there seems to be no easy way to delete relationships from it. The only remove option is made only for ForeignKey relationships. Is there a workaround? Why would django design a relationship that you can only add

Re: Creating Model with ManyToMany relationship from PyAMF & Flex

2009-07-14 Thread Jesse Warden
Nevermind, found this: http://www.djangoproject.com/documentation/models/many_to_many/ And got it working. woo WOOO!!! On Tue, Jul 14, 2009 at 2:28 PM, Jesse Warden wrote: > n00b here. I'd like to create a complex Model from a Flex Object > (basically decoded JSON). I've created a Model succe

Creating Model with ManyToMany relationship from PyAMF & Flex

2009-07-14 Thread Jesse Warden
n00b here. I'd like to create a complex Model from a Flex Object (basically decoded JSON). I've created a Model successfully already, but am unsure how to do this with the multiple Models that have ManyToMany relationships with each other. This works: def create_power(request, powerObj): try: p

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-06-09 Thread ringemup
No, you have to save self before you can add categories to it, because you can't save an M2M if either object is missing a primary key. In any case, it turns out that the reason is that the admin saves the submitted M2M data after the save() method is called on the main model. So it erases and

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-06-09 Thread Frédéric Hébert
Hi, > defsave(self, *args): >    models.Model(save, *args) >    category = Category.objects.all()[0] >    self.categories.add(category) > > This does not work, I'm sure it's saving ManyToMany relationships > later on in thesaveprocess.  Is there a way to make this work? > IMHO, it's make sense :

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-05-24 Thread ringemup
(self, *args): > models.Model.save(self, *args) > category = Category.objects.all()[0] > self.categories.add(category) > > However, that point is not the problem. Even with the proper syntax, > it doesn't save the ManyToMany relationship.

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-04-27 Thread Adam Olsen
proper syntax, it doesn't save the ManyToMany relationship. -- Adam Olsen SendOutCards.com http://www.vimtips.org http://last.fm/user/synic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-04-27 Thread Alex Gaynor
On Mon, Apr 27, 2009 at 1:24 PM, Adam Olsen wrote: > > I've got two models, something like this: > > class Category(models.Model): >name = models.CharField(max_length=60) > > class Product(models.Model): >sku = models.CharField(max_length=20) >categories = models.ManyToManyField(Categ

Overriding save() method on models to automatically add ManyToMany relationship

2009-04-27 Thread Adam Olsen
I've got two models, something like this: class Category(models.Model): name = models.CharField(max_length=60) class Product(models.Model): sku = models.CharField(max_length=20) categories = models.ManyToManyField(Category) I want to overload the save method to automatically add cer

Re: ManyToMany relationship being 'lost'?

2009-04-27 Thread Rubens Altimari
Hey Jorge, > The relation disappears when (existing a relation) y use this modelForm > without including any info for the friends field (I don't what to edit this > information at this point). At this moment, django erases the relation > within A an B because wasn't explicit declared and the form

Re: ManyToMany relationship being 'lost'?

2009-04-27 Thread Jorge Bastida
Hello Rubens,I have similar problems months ago. In my application there is a ManyToMany relation within two classes (A and B) let's name the relation as "friends". The application works fine but in unpredictable situations rows from the auxiliary table that makes the relation disappears randomly.

Re: ManyToMany relationship being 'lost'?

2009-04-27 Thread Rubens Altimari
Russ, Thanks fo the reply! > The only thought I have is that you appear to be using a pre-existing > table to manage the m2m relationship, rather than the default produced > Django table. This shouldn't pose a problem, but it does lead me to > wonder if there is some other process that could be

Re: ManyToMany relationship being 'lost'?

2009-04-27 Thread Rubens Altimari
Hi Malcolm, >> class BidirectionalField(models.ManyToManyField): >>     def __init__(self, *args, **kwargs): >>         super(BidirectionalField, self).__init__(*args, **kwargs) >>         self.creates_table = False > BY the way, this has been discussed in the past and is really the wrong > way

Re: ManyToMany relationship being 'lost'?

2009-04-25 Thread Malcolm Tredinnick
On Fri, 2009-04-24 at 15:32 -0300, Rubens Altimari wrote: > Hello, > > > Sorry if this is a known issue, but I didn't find anything elsewhere. > > > I have these two models related by a many-to-many relationship. I'm > using the 'default' admin application to edit data, and in order to be > ab

Re: ManyToMany relationship being 'lost'?

2009-04-24 Thread Russell Keith-Magee
On Sat, Apr 25, 2009 at 2:32 AM, Rubens Altimari wrote: > Hello, > Sorry if this is a known issue, but I didn't find anything elsewhere. > I have these two models related by a many-to-many relationship. I'm using > the 'default' admin application to edit data, and in order to be able to > edit bo

ManyToMany relationship being 'lost'?

2009-04-24 Thread Rubens Altimari
Hello, Sorry if this is a known issue, but I didn't find anything elsewhere. I have these two models related by a many-to-many relationship. I'm using the 'default' admin application to edit data, and in order to be able to edit both sides of the relationship, I'm using the snippet provided by pow

Forms and ManyToMany relationship with intermediary model

2008-12-22 Thread Bernard
Hey there, I've been searching this group for a working example of a complex form using a ManyToMany relationship with an intermediary model. I've read this documentation to know a bit more about the ManyToMany relationship: http://docs.djangoproject.com/en/dev/topics/db/models/#in

Re: Manager to add entries where there is a ManyToMany relationship

2008-10-26 Thread TiNo
> > 1. How do I create a Model Manager? See http://docs.djangoproject.com/en/dev/topics/db/managers/ 2. Within a view, what is the best way to add entries into tables that > have a M2M relationship with an intermediate table? I've been reading > the following documentation with command line opt

Re: Manager to add entries where there is a ManyToMany relationship

2008-10-25 Thread dodgyville
Hi, I have the same problem. Does anyone have any suggestions for how to save forms when the "through" attribute is used on a ManyToMany attribute? Regards, Luke SnappyDjangoUser wrote: > Hi Everyone, > > I need some guidance with adding table entries where I have a M2M > table relationship. I

Re: Manager to add entries where there is a ManyToMany relationship

2008-10-09 Thread Jason Sypolt
I have the same problem. Does anyone have an example of what we the code in the view would look like? On Sep 25, 2:37 pm, SnappyDjangoUser <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > Am I on the right track with my M2M model definition (which includes > an intermediate table)?  I still need hel

Re: ManyToMany relationship on self through other table

2008-10-02 Thread chris
Dear Karen, Thank you very much for your response. It was very helpful and solved my problem! As I said, I am just beginning with Django, so could not quite understand where the problem lies. However, I will try to post a more useful and descriptive phrasing of the problem, including traceback

Re: ManyToMany relationship on self through other table

2008-10-01 Thread Karen Tracey
On Tue, Sep 30, 2008 at 4:52 AM, chris <[EMAIL PROTECTED]> wrote: > > Hi there, > > Just starting to use django, so forgive me if this has been answered > before (a quick search at djanog-search did not turn up something > useful). > What I am trying to do is similar to this (from > http://www.dja

Re: ManyToMany relationship on self through other table

2008-10-01 Thread felix
Exception Value: has more than 1 ForeignKey to hmm. I'm not sure. you might be able to get it to work by fudging something or other. but when it gets complicated like this, and it gets complicated for django's ORM, then I think its better to rearrange the approach. On Oct 1, 2:18 pm, chri

Re: ManyToMany relationship on self through other table

2008-10-01 Thread chris
Dear Felix, Thanks for following up on this. I put the traceback up here: http://paste.pocoo.org/show/86707/ I will try to follow your advice to work around the error and define the tables differently, since you are right about the way this should work in the admin interface. But I still thin

Re: ManyToMany relationship on self through other table

2008-09-30 Thread felix
post the traceback. I may not be able to help you since I haven't tried to do person-to-person at all. it might be simpler to just do Friends and Idols (without using through and without friends and idols being fields on Person) and then add methods to Person that fetch those relationships. or

Re: ManyToMany relationship on self through other table

2008-09-30 Thread chris
On Sep 30, 8:07 pm, felix <[EMAIL PROTECTED]> wrote: > are you actually getting a runtime error or an error when trying to > syncdb ? syncdb works fine, but then I get a runtime error when I want to edit such a record in the admin interface. The traceback complains about the two foreign keys

Re: ManyToMany relationship on self through other table

2008-09-30 Thread felix
are you actually getting a runtime error or an error when trying to syncdb ? On Sep 30, 10:52 am, chris <[EMAIL PROTECTED]> wrote: > Hi there, > > Just starting to use django, so forgive me if this has been answered > before (a quick search at djanog-search did not turn up something > useful). >

ManyToMany relationship on self through other table

2008-09-30 Thread chris
Hi there, Just starting to use django, so forgive me if this has been answered before (a quick search at djanog-search did not turn up something useful). What I am trying to do is similar to this (from http://www.djangoproject.com/documentation/models/m2m_recursive/): from django.db import model

Re: Manager to add entries where there is a ManyToMany relationship

2008-09-25 Thread SnappyDjangoUser
Hi Everyone, Am I on the right track with my M2M model definition (which includes an intermediate table)? I still need help with 2 questions: 1. How do I create a Model Manager? 2. Within a view, what is the best way to add entries into tables that have a M2M relationship with an intermediate

Manager to add entries where there is a ManyToMany relationship

2008-09-24 Thread SnappyDjangoUser
Hi Everyone, I need some guidance with adding table entries where I have a M2M table relationship. I am adding entires via a Quote ModelForm. The problem is that I am getting the following error when submitting the form: "Cannot set values on a ManyToManyField which specifies an intermediary m

Re: Problem displaying value(s) from ManyToMany relationship

2008-05-19 Thread phillc
variable name collision. caused by locals() On May 18, 8:05 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote: > Very odd. On a whim, I changed: > > > {% for instructor in instructors %} > {{ instructor.first_name }} #there is no value output > here > {% endif %} > > > to > > > {% for i in inst

Re: Problem displaying value(s) from ManyToMany relationship

2008-05-18 Thread Brandon Taylor
Very odd. On a whim, I changed: {% for instructor in instructors %} {{ instructor.first_name }} #there is no value output here {% endif %} to {% for i in instructors %} {{ i.first_name }} #this works?! here {% endif %} Can anyone offer some reason why that would work? Just for my

Re: Problem displaying value(s) from ManyToMany relationship

2008-05-18 Thread Brandon Taylor
Here is my code: #in models.py class Instructor(models.Model): prefix = models.CharField(max_length=50, blank=True, null=True) first_name = models.CharField(max_length=50) middle_name = models.CharField(max_length=50, blank=True, null=True) last_name = models.CharField(max_length=

Problem displaying value(s) from ManyToMany relationship

2008-05-18 Thread Brandon Taylor
Hi everyone, I have a ManyToMany field on a model, and when I want to get the related items and display them in a template in a for loop, the loop executes the correct number of times, but in my output blocks there are no values. If I print the object, I get an array of values, same as any other

ManytoMany relationship question

2008-03-25 Thread guillaume
Hi list, I'm building an app where a model has a manyTomany relationship with User model. There are two things I can't figure out : 1. How can I add to User admin form the list of items related to it ? 2. How can I add a specific field to the relation table ? Thanks,

Re: How would I add a custom widget in the admin for a ManyToMany relationship?

2006-12-08 Thread Adrian Holovaty
On 12/8/06, naitsirhc <[EMAIL PROTECTED]> wrote: > I'm kind of surprised that I didn't find > mention of the 'raw_id_admin' in my previous searches - is it > relatively new? Nope, it's not new -- raw_id_admin has been around since before Django was open-sourced. Adrian -- Adrian Holovaty holov

Re: How would I add a custom widget in the admin for a ManyToMany relationship?

2006-12-08 Thread naitsirhc
Thank you very much for your help. I should be able to modify this to suit my needs perfectly. I'm kind of surprised that I didn't find mention of the 'raw_id_admin' in my previous searches - is it relatively new? I see that it has been involved in some active development in the Django source c

  1   2   >