Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-23 Thread danielp...@gmail.com
you can use django-ajax-selects library https://github.com/crucialfelix/django-ajax-selects/ Define a lookup channel: yourapp/lookups.py from ajax_select import register, LookupChannel from .models import Tag @register('tags') class TagsLookup(LookupChannel): model = Tag def get

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-19 Thread Sebastian Jung
This is Admin Frontend this has nothing to do with normal Frontend. In Admin Frontend i have no experience... Am Di., 19. Okt. 2021 um 09:55 Uhr schrieb 'Maryam Yousaf' via Django users : > It is not working with SelectMultiple. I can select multiple values but it > is not showing any drop down.

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Shaheed Haque
On Mon, 18 Oct 2021 at 15:41, Sebastian Jung wrote: > When u use SelectMultiple then you get a select widget where you can > select many options Your code are wrong in forms.py in widgets= > > Am Mo., 18. Okt. 2021 um 16:22 Uhr schrieb 'Maryam Yousaf' via Django > users : > >> It is alrea

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Sebastian Jung
When u use SelectMultiple then you get a select widget where you can select many options Your code are wrong in forms.py in widgets= Am Mo., 18. Okt. 2021 um 16:22 Uhr schrieb 'Maryam Yousaf' via Django users : > It is already selectmultiple . I need dropdown where I can select multiple >

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Sebastian Jung
Hello, then change in widgets Select() to SelectMultiple(). https://docs.djangoproject.com/en/3.2/ref/forms/widgets/#selectmultiple Regards Am Mo., 18. Okt. 2021 um 15:51 Uhr schrieb 'Maryam Yousaf' via Django users : > Hi, > > I have one manytomany field in one of my model which is currently

DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread 'Maryam Yousaf' via Django users
Hi, I have one manytomany field in one of my model which is currently coming as Multiselect but I need a dropdown where user can select multiple values as I have huge data to show. I am trying this in forms.py but it is not showing dropdown field. Kindly help me out. *Model.py:* class Chai

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

Many to many field does not save in the main object

2020-08-25 Thread Annick Sakoua
Hi all, Please Help. I have been on this problem for 2 weeks now :( I have an object: customer that has 1 manytomany relationship with another object: gp. I created some gp instances in the admin page. When I select one gp in the select dropdown list of existing gp in my addcustomer form an

Please help I want to list down all the users with the sharewith from the frontend in backend I used Many to Many field and also my data is not getting into database

2020-07-16 Thread mick
views.py def notesadd(request): form = NoteForm(request.POST or None) if form.is_valid(): form.save() form=NoteForm() context = { 'form': form } print('submitted') return render(request, 'notes.html', context) models.py class Notes(mode

how to retrieve maximum value in many to many field

2020-07-13 Thread Rajshree Some
Table1 id 1 Item1 Good 2 Item2 bad Table2 Id table1_id marks 1. 1 23 2. 1 54 3. 2 66 4. 2 55 -- You received this message because you are subscribed to

How can I delete the parent object related through a many to many field?

2020-03-24 Thread Mark Phillips
I have three related models - Document, Collection, and CollectionDocument. A Collection object is made up of a group of documents. class Document(Model): document_id = models.AutoField(primary_key=True) class Collection(Model): collection_id = models.AutoField(primary_key=True) docume

help on how to pass a many to many field to form template

2020-03-05 Thread Tosin Ayoola
good day, I have to models, using a many to many relationship, I want to access the fields in they model in my form template, how do i achieve this? i attached my view, model and template code screenshot, hopping anyone can help -- You received this message because you are subscribed to the Googl

Re: Issue with unique key error on Many to Many field

2019-11-10 Thread Malibu
Hi, thanks for the answer. Of course, the moment I posted the question I figured out what it was. I ended up checking my primary keys, and found that they didn't have unique constraints. I added them and all was fine. Must have fallen off during an import. On Sunday, 10 November 2019 13:55:0

Re: Issue with unique key error on Many to Many field

2019-11-10 Thread Integr@te System
Hi Issuer, Check your tracker_passenger. https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.ManyToManyField On Sun, Nov 10, 2019, 21:40 Malibu wrote: > Hi there. I've been doing Django for awhile but I am stumped on this > one.. I have a many to many relationship with

Issue with unique key error on Many to Many field

2019-11-10 Thread Malibu
Hi there. I've been doing Django for awhile but I am stumped on this one.. I have a many to many relationship with a 'through' definition main.models: class Client(models.Model): uid = models.CharField(max_length=128, unique=True) key = models.CharField(max_length=128) img = model

select quantity for each items selected in many to many field

2019-07-20 Thread namo
hi there, i'm working on an restaurant ordering system , when someone order more than one product with different quantities for each product , be able to select its quantities it may order 3 Pizza with 2 sandwich , how to let the customer to define the quantities of each product , and then calc

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

2018-10-29 Thread Web Architect
, 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 it as > follows: > >> > >> Lets say there are two model

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

2018-10-29 Thread Sanjay Bhangar
gt;> >> We are using django 1.11 for our ecommerce site. >> >> We are facing an issue with modelform and many to many field in it as >> follows: >> >> Lets say there are two models: >> >> class A(models.Model): >>c = models.CharFiel

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 man

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

2018-10-29 Thread Web Architect
Hi, We are using django 1.11 for our ecommerce site. We are facing an issue with modelform and many to many field in it as follows: Lets say there are two models: class A(models.Model): c = models.CharField() class B(models.Model): a = models.ManyToManyField('A')

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread carlos
mansi thakkar, wrote: >>> >>>> Hello , >>>> >>>> In my database, there is one table named Product and the other table is >>>> Ingredient. Both are related with ManyToMany Relationship using bridge >>>> entity (table) named Product

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread Muhammad bin-haneef
;>> >>> In my database, there is one table named Product and the other table is >>> Ingredient. Both are related with ManyToMany Relationship using bridge >>> entity (table) named ProductIngredient. >>> >>> I am trying to display Many To Many fiel

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread mansi thakkar
ello , >> >> In my database, there is one table named Product and the other table is >> Ingredient. Both are related with ManyToMany Relationship using bridge >> entity (table) named ProductIngredient. >> >> I am trying to display Many To Many field named ingred

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread Julio Biason
one table named Product and the other table is > Ingredient. Both are related with ManyToMany Relationship using bridge > entity (table) named ProductIngredient. > > I am trying to display Many To Many field named ingredient in my Django > admin site. > > Here is the attached cod

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread mansi thakkar
atabase, there is one table named Product and the other table is >> Ingredient. Both are related with ManyToMany Relationship using bridge >> entity (table) named ProductIngredient. >> >> I am trying to display Many To Many field named ingredient in my Django >> ad

Re: Display Many to Many Field in Django admin site

2018-04-03 Thread squal poreover
entity (table) named ProductIngredient. > > I am trying to display Many To Many field named ingredient in my Django > admin site. > > Here is the attached code and screen shot of the error. > > I would like to know the solution of this error and also any other way to > displ

Can I test for count of a many to many field, in a Q query, along with other filters?

2018-01-16 Thread Mark London
If I'm creating a query using Q, can I make one of Q tests, be a count of a manytomany field?I.e., one of the Q filters, should test to see if a specific manytomany field, has a count greater than 5, I know that I can use annotate to test for count. But can annotate be specified within a

Clarification on __in when attribute on left is a many to many field

2018-01-15 Thread Jeff Tchang
In the documentation on this page: https://docs.djangoproject.com/en/2.0/topics/db/examples/many_to_many/ you have the following example: >>> Article.objects.filter(publications__in=[1,2]).distinct()>> [, >> Python>]> Does the __in for many to many fields mean for ANY publication in [1,2]. So

Override save method to add list in the many to many field

2017-01-04 Thread Robin Lery
I have this model to save post from the users: class Tag(models.Model): name = models.CharField(max_length=255, unique=True) def add_tags(obj_id, body): object = Post.objects.get(id=obj_id) tag_list = [Tag.objects.create(name=word) for word in body.split()] for tag in tag_list:

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-24 Thread Carsten Fuchs
Hi all, just wanted to let you know that I was successful! I followed Gergely's final recipe, using RunPython for the data migrations and separate migration files for each of the steps. For step 3 (the deletion of the ManyToManyField) I temporarily had to remove the django.contrib.admin from

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carl Meyer
Hi Gergely, On 07/23/2015 02:27 PM, Gergely Polonkai wrote: > Yes, you are right, my attempt is not the solution to your problem; it > seems that this m2m field really cannot be modified like this. With some > slight modifications, though, it may be. > > 1) create the through table > 2) migrate d

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Gergely Polonkai
Hello, I'm sorry, I was not around my mailbox lately. Yes, you are right, my attempt is not the solution to your problem; it seems that this m2m field really cannot be modified like this. With some slight modifications, though, it may be. 1) create the through table 2) migrate data with RunPytho

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carsten Fuchs
Hi Carl, Am 23.07.2015 um 18:28 schrieb Carl Meyer: Overall I think it might be simpler to go with your initial approach. I'd first rename the old field to some other temporary name (you don't have to update any other code to use this name, as you'll commit all of these migrations in one commi

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carl Meyer
Hi Carsten, On Thursday, July 16, 2015 at 12:44:55 PM UTC-6, Carsten Fuchs wrote: > > Am 2015-07-16 um 18:15 schrieb Gergely Polonkai: > > 1) create the "through" model, add it to the migration file > > 2) migrate all m2m instances (e.g. iterate over all Bereich objects then > > iterate through

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-23 Thread Carsten Fuchs
Am 16.07.2015 um 16:05 schrieb Carsten Fuchs: Alas... are there any viable alternatives to this? I'd be very grateful for any hint! :-) Anyone please? Best regards, Carsten -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe fr

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-20 Thread Carsten Fuchs
Hi Gergely, Am 16.07.2015 um 20:44 schrieb Carsten Fuchs: 3) change the m2m field by adding the through option, and add this change to the migrations file. [...] And won't this last step trigger the same error as before? ("... you cannot alter to or from M2M fields, or add or remove through=

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread BHAGYARAJ POLA
> > hey hi, I want to create web based visualization by using django framework in python. i need to have a front end interface which will communicate with the database. The front end should look like similar to this. http://specobs.ee.washington.edu/ For Map you can use Google Maps API, S

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Carsten Fuchs
Hi Gergely, many thanks for your quick reply! Am 2015-07-16 um 18:15 schrieb Gergely Polonkai: 1) create the "through" model, add it to the migration file 2) migrate all m2m instances (e.g. iterate over all Bereich objects then iterate through its users, creating a UserBereichAssignment object

Re: Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Gergely Polonkai
ed for the previous implicit intermediate model and the new > UserBereichAssignment? > > I'm also aware of https://code.djangoproject.com/ticket/23034, but I'm > not sure what to make of it, or if it is even applicable here. > > > Thus, what would be a go

Migrate a many-to-many field to an explicit intermediate ("through") model?

2015-07-16 Thread Carsten Fuchs
t/23034, but I'm not sure what to make of it, or if it is even applicable here. Thus, what would be a good way to proceed? To the best of my understanding, I could do this manually, that is: create an entirely new many-to-many field, e.g. class Bereich(models.Model): benutzer

Re: How to read part of many-to-many field in the template

2014-06-15 Thread alghafli
Thank you for the fast reply. I did what you suggested and it worked fine :) على الأحد 15 حزيران 2014 16:39, كتب Elliot Bradbury: Hi Mohammad, Check out slice . It's a builtin template filter that can be used like this: {%

Re: How to read part of many-to-many field in the template

2014-06-15 Thread Elliot Bradbury
Hi Mohammad, Check out slice . It's a builtin template filter that can be used like this: {% for author in book.authors.all|slice:"3" %} {# HTML up in here #} {% endfor %} Good luck, Elliot On Sun, Jun 15, 2014 at 9:31 AM,

How to read part of many-to-many field in the template

2014-06-15 Thread alghafli
Hello django users. I am working on my first django project and I faced a little problem. I have a library database with books. A book element may have several authors. In the view function I query the database for books. I want to show the *first three* authors. I was thinking to do something s

Re: How to query multiple described objects exist in a many to many field

2013-12-05 Thread Aamu Padi
Thank you so much! That was a very helpful explanation. And it worked perfectly!!! Just, one more question please. Suppose, the user wants to send a message to a group of users, how do I find the thread in this situation? Eg: user1 wants to send a message to both the user2 and user3. How to find

Re: How to query multiple described objects exist in a many to many field

2013-12-04 Thread Tom Evans
On Wed, Dec 4, 2013 at 10:24 AM, Aamu Padi wrote: > How do I check whether there is a thread containing only the sender (user 1) > and the recipient (user 2), and no other users. > > models.py > > class Thread(models.Model): > user = models.ManyToManyField(User) > is_hidden = m

How to query multiple described objects exist in a many to many field

2013-12-04 Thread Aamu Padi
How do I check whether there is a thread containing only the sender (user 1) and the recipient (user 2), and no other users. models.py class Thread(models.Model): user = models.ManyToManyField(User) is_hidden = models.ManyToManyField(User, related_name='hidden_thread', blank=T

showing many-to-many field in admin interface

2012-08-09 Thread Mo Mughrabi
hello everyone, am trying to build a single model that will be used for uploaded images/files. Am trying to use it in the best way in the admin pages, so when i associate it with a specific model as a many-to-many field it would appear in a friendly way for users to upload images. My attachment

Re: sql for Many To Many Field in existing django model

2012-03-24 Thread Nikhil Verma
Hi I am able to create the field through in postgres. When i execute that sql statement :- CREATE TABLE "visit_visit_research" ( "id" serial NOT NULL PRIMARY KEY, "visit_id" integer NOT NULL REFERENCES "visit_visit" ("id") DEFERRABLE INITIALLY DEFERRED, "research_id" integer NOT NULL

Re: sql for Many To Many Field in existing django model

2012-03-22 Thread Joel Goldstick
On Thu, Mar 22, 2012 at 6:55 AM, Nikhil Verma wrote: > Hi All > > I want to add a ManyToManyField  to an existing django model. > > I can use sql app_name and see the statement. > > My models > > Class Visit(modes.Model): >   x = something >   . .. >   .. and so on >  # finally Here i want

sql for Many To Many Field in existing django model

2012-03-22 Thread Nikhil Verma
Hi All I want to add a ManyToManyField to an existing django model. I can use sql app_name and see the statement. My models Class Visit(modes.Model): x = something . .. .. and so on # finally Here i want to add that field research protol research_protocol = models.ManyToMa

Re: Delete a many to many field who is in another table

2011-11-30 Thread jose osuna perez
I try to make this using delete, remove.. Also I using too if request.POST.get('experimentosDelete','')!='': for i in request.POST.getlist('experimentosDelete'): exp=Experimentos.objects.get(proyecto=datos,id=i) exp.experimentos=[] ...

Re: Delete a many to many field who is in another table

2011-11-30 Thread Tom Evans
On Wed, Nov 30, 2011 at 11:42 AM, jose osuna perez wrote: > Hi, I am finally going to finish the project started and where I end > up liking this xD Django that the problem I have is the clearing of a > field. > ... > I try like this: > > if request.POST.get('experimentosDelete','')!='': >        

Re: Delete a many to many field who is in another table

2011-11-30 Thread Salvatore Iovene
Hi, after: exp.experimentos.remove(request.POST.get('experimentosDelete')) You should do: exp.save() I hope this helps. Salvatore. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.googl

Delete a many to many field who is in another table

2011-11-30 Thread jose osuna perez
Hi, I am finally going to finish the project started and where I end up liking this xD Django that the problem I have is the clearing of a field. I have the following tables. class Proyectos(models.Model): titulo=models.CharField(max_length=100) creacion=models.DateField(default=datetime.d

Re: Help with many-to-many field update

2011-11-24 Thread Leslie Maclachlan
Hi Mario, Thanks so much - I updated my view as below and it is now working as expected! Regards, Leslie if form.is_valid(): new_item = form.save(commit=False) new_item.client = orderClient new_item.orderdate = datetime.now() new_item.orderIP = remot

Re: Help with many-to-many field update

2011-11-24 Thread Mario Gudelj
Hey Leslie, Try add() method like in this answer on SO http://stackoverflow.com/questions/1226290/django-manytomany-relation-add-error Cheers, On 25 November 2011 00:43, Nichehosters wrote: > Hi, > I am relatively new to Django, and am trying to update a many-to-many > related table using a Mo

Help with many-to-many field update

2011-11-24 Thread Nichehosters
Hi, I am relatively new to Django, and am trying to update a many-to-many related table using a ModelForm. I see fro the documentation that if I use save(commit=False) - which I do - I need to use save_m2m() after saving the initial form. I am using the save_m2m(), but my related table does not ge

Re: object appears twice after filtering by many to many field

2010-12-22 Thread Dan Fairs
> Thanks for the quick replay. > The problem is the clip duplication, when relaying on clip_set.count() > and also in the admin site when you see raw duplication after > filtering , it is not very reasonable :) > Ah, I didn't realise it was in the admin. It'll still be the same underlying proble

Re: object appears twice after filtering by many to many field

2010-12-22 Thread tom
Thanks for the quick replay. The problem is the clip duplication, when relaying on clip_set.count() and also in the admin site when you see raw duplication after filtering , it is not very reasonable :) 1. in order to change this behavior in the admin site I need to manipulate main.py and add dist

Re: object appears twice after filtering by many to many field

2010-12-22 Thread Dan Fairs
> Hi all! > I have 2 models: Clip, Tag. > class Clip(models.Model): > name = models.CharField(max_length=80) > tags = models.ManyToManyField(Tag, through = 'TagsToClips') > > class Tag(models.Model): > tagName = models.CharField(max_length=80, unique=True) > > class Tag

object appears twice after filtering by many to many field

2010-12-22 Thread tom
Hi all! I have 2 models: Clip, Tag. class Clip(models.Model): name = models.CharField(max_length=80) tags = models.ManyToManyField(Tag, through = 'TagsToClips') class Tag(models.Model): tagName = models.CharField(max_length=80, unique=True) class TagsToClips(models.M

object appears twice after filtering by many to many field

2010-12-22 Thread tom
Hi all! I have 2 models: Clip, Tag. class Clip(models.Model): name = models.CharField(max_length=80) tags = models.ManyToManyField(Tag, through = 'TagsToClips') class Tag(models.Model): tagName = models.CharField(max_length=80, unique=True) class TagsToClips(models.M

Editing a many to many field in a save method

2010-11-30 Thread When ideas fail
Hi, I've got the following model and I want it so that each delivery has a default category of undefined class Delivery(models.Model): . categories = models.ManyToManyField(Category, blank = True, null = True) . Then if other categories are selected undefined is automatically

Re: How to display many-to-many field as a list of text input fields?

2010-09-02 Thread Steve Holden
On 9/2/2010 4:27 PM, adelein wrote: > When I display the ToolBoxEditForm it uses a multiple select field. > But what I want is a form that lets the user edit each tool he has in > the toolbox as a text field. I cant figure out how to do this with the > many-to-many field. >

How to display many-to-many field as a list of text input fields?

2010-09-02 Thread adelein
When I display the ToolBoxEditForm it uses a multiple select field. But what I want is a form that lets the user edit each tool he has in the toolbox as a text field. I cant figure out how to do this with the many-to-many field. class Tool(models.Model): tool_name = models.CharField(unique

Querying a many-to-many field based on entries' number in the relationship

2010-09-01 Thread Jordon Wii
Hi, I have a model named 'Period' and a model named 'Schedule'. They have a many-to-many relationship. I need to get all Period's whose position in the relationship is a certain number (All second periods in each schedule, for example). I could use raw SQL to query the m2m database, but is this

Re: Initial data in a many to many field

2010-03-25 Thread mjlissner
x27;barmembership' : [bar_memberships]}) > > I don't know why you're not using the "instance" argument to populate the form > > profileForm = ProfileForm(instance=userProfile) > > but you need to give the ModelForm a list of PKs for the many-to-many-fie

Re: Initial data in a many to many field

2010-03-25 Thread Nuno Maltez
ileForm = ProfileForm( >        initial = {'barmembership' : [bar_memberships]}) I don't know why you're not using the "instance" argument to populate the form profileForm = ProfileForm(instance=userProfile) but you need to give the ModelForm a list of PKs for the man

Initial data in a many to many field

2010-03-24 Thread mjlissner
I've been struggling with this literally for hours. I'm trying to use a ModelForm with initial values being set as those that are already in the DB for a user. This works marvelously for every field that I have EXCEPT for the one manytomany field I have in my model. For that one, I can submit the

Re: sitemap how to publish many to many field?

2009-12-11 Thread Michael
Hi there, > > I am playing around with Django's sitemap app and I have a question. > When I pass a normal query in a sitemap class like Shop.objects.all() > everything works fine. My problem begins when I try to publish a model > with a many to many field in it. > > When I te

sitemap how to publish many to many field?

2009-12-10 Thread Michael
Hi there, I am playing around with Django's sitemap app and I have a question. When I pass a normal query in a sitemap class like Shop.objects.all() everything works fine. My problem begins when I try to publish a model with a many to many field in it. When I test this code below in the P

Re: Using raw_id_fields with a many-to-many field

2008-10-29 Thread Brian Rosner
On Wed, Oct 29, 2008 at 4:35 PM, AndrewD <[EMAIL PROTECTED]> wrote: > > # models.py > class Membership(models.Model): > person = models.ForeignKey(Person) > group = models.ForeignKey(Group) > > # admin.py > class MembershipInline(admin.TabularInline): > model = Membership >

Re: Using raw_id_fields with a many-to-many field

2008-10-29 Thread AndrewD
I have a ManyToMany field that works as a raw_id_fields item. It is an intermediary ManyToMany model class using the through='ClassName' feature. The admin.py shows that ManyToMany model using an Inline admin class. The Inline class has the raw_id_fields and extras attributes. Here is an example

Re: Using raw_id_fields with a many-to-many field

2008-10-10 Thread Karen Tracey
On Thu, Oct 9, 2008 at 5:59 PM, Hancock, David (dhancock) < [EMAIL PROTECTED]> wrote: > I've found that using raw_id_fields saves a lot of time for our users > over loading an entire many-to-many select. (But for shorter lists, the > many-to-many widget is by far the best interface I've seen for

Using raw_id_fields with a many-to-many field

2008-10-09 Thread Hancock, David (dhancock)
I've found that using raw_id_fields saves a lot of time for our users over loading an entire many-to-many select. (But for shorter lists, the many-to-many widget is by far the best interface I've seen for multiple selections.) There's an aspect of the raw_id_fields (this is in the admin interface)

Re: how to add more information in a model with a many-to-many field to itself, and 'symmetrical=True'

2008-10-06 Thread Karen Tracey
Answered on the other thread started with the same question. Karen --~--~-~--~~~---~--~~ 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 unsubscri

how to add more information in a model with a many-to-many field to itself, and 'symmetrical=True'

2008-10-06 Thread Matrixer
in django, it's not allowed to create an intermediary model, when 'symmetrical' is set to True in this kind of many-to-many relationship, then how to add more information for the relationship, is there any good solutions for this, or do I have to use the unsymemtrical one instead and do some extra

Re: Getting specific data from a many to many field.

2008-09-16 Thread Daniel Roseman
On Sep 16, 4:16 pm, "Lance F. Squire" <[EMAIL PROTECTED]> wrote: > On Sep 16, 2:30 am, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > try: > >     return > > self.system_pictures.filter(image_category__name='Header_Pic')[0] > > except IndexError: > >     pass > > > which will always get the first

Re: Getting specific data from a many to many field.

2008-09-16 Thread R. Gorman
> > > try: > >     return > > self.system_pictures.filter(image_category__name='Header_Pic')[0] > > except IndexError: > >     pass > Make sure you have the indentation set correctly. The second and third line of the posted code should actually be one line. I think the formatting was changed w

Re: Getting specific data from a many to many field.

2008-09-16 Thread R. Gorman
> > try: > >     return > > self.system_pictures.filter(image_category__name='Header_Pic')[0] > > except IndexError: > >     pass > > > which will always get the first related image in that category, and > > silently swallows the error that's thrown if there's no such picture. > > Can't seem to ge

Re: Getting specific data from a many to many field.

2008-09-16 Thread Lance F. Squire
On Sep 16, 2:30 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > > Sorry, my mistake. filter() always gives you a queryset - because > there might be more than one instance of the related model that fits > the criteria - so you can't jut reference the location/width directly. > The best way is to

Re: Getting specific data from a many to many field.

2008-09-15 Thread Daniel Roseman
On Sep 16, 2:30 am, "Lance F. Squire" <[EMAIL PROTECTED]> wrote: > On Sep 15, 5:21 pm, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > Probably the easiest solution, if you know you're > > always going to be requesting a certain lookup, is to define a custom > > method on the model: > > > class

Re: Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
On Sep 15, 5:21 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > Probably the easiest solution, if you know you're > always going to be requesting a certain lookup, is to define a custom > method on the model: > > class System(models.Model): > ... field declarations ... > > def get_heade

Re: Getting specific data from a many to many field.

2008-09-15 Thread Daniel Roseman
On Sep 15, 9:25 pm, "Lance F. Squire" <[EMAIL PROTECTED]> wrote: > On Sep 15, 4:13 pm, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > So, putting that all together: > > > {% for pic in info.system_pictures.all %} > >     {% ifequal pic.image_category.name 'Header_Pic' %} > >         > >     {%

Re: Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
On Sep 15, 4:13 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > So, putting that all together: > > {% for pic in info.system_pictures.all %} > {% ifequal pic.image_category.name 'Header_Pic' %} > > {% endifequal %} > {% endfor %} > Sweet! That works. Thanks! I'll try to rememb

Re: Getting specific data from a many to many field.

2008-09-15 Thread Daniel Roseman
On Sep 15, 8:50 pm, "Lance F. Squire" <[EMAIL PROTECTED]> wrote: > Using Fedora 8, Django  version 0.96.3 > > I'm currently trying to pull two specific images from a list of images > associated with a model. > > Currently the Models are like this: > > class ImageCat(models.Model): >     name = mod

Getting specific data from a many to many field.

2008-09-15 Thread Lance F. Squire
Using Fedora 8, Django version 0.96.3 I'm currently trying to pull two specific images from a list of images associated with a model. Currently the Models are like this: class ImageCat(models.Model): name = models.CharField(maxlength=80) class Image(models.Model): name = models.Ch

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 ... >

Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
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 ... Tags = models.ManyToManyField(Tag) class Tag (models.Mode):

Re: list_display a Many to Many field

2008-07-10 Thread [EMAIL PROTECTED]
No, authors is the related manager, so it's all method returns a QuerySet with all the relevant items. On Jul 10, 8:25 am, Fernando Rodríguez <[EMAIL PROTECTED]> wrote: > El mié, 09-07-2008 a las 06:40 -0700, urukay escribió: > > > > > this should work: > > > def get_authors(self): > >     return

Re: list_display a Many to Many field

2008-07-10 Thread Fernando Rodríguez
El mié, 09-07-2008 a las 06:40 -0700, urukay escribió: > > this should work: > > def get_authors(self): > return self.authors.all() Thanks Radovan. Shouldn't it be self.authors.objects.all()? --~--~-~--~~~---~--~~ You received this message because you are

Re: list_display a Many to Many field

2008-07-09 Thread urukay
this should work: def get_authors(self): return self.authors.all() list_display = ('title', 'Publisher', 'publicationDate', 'get_authors' ) Radovan Fernando Rodríguez wrote: > > > Hi, > > I'm trying to display a many

list_display a Many to Many field

2008-07-09 Thread Fernando Rodríguez
Hi, I'm trying to display a many to many field in the admin interface. This is my model: class Book(models.Model): title = models.CharField(maxlength = 100, db_index = True) authors = models.ManyToManyField(Author) Publisher = models.ForeignKey(Publisher) publicatio

Re: many to many field

2008-06-25 Thread Stephan Jäkel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 'cause the current patch in the ticket doesnt seem to work perfect until now, i created a small hack http://steph.rdev.info/devel/m2m_custom_columnnames-r7732.patch example: class Article(models.Model): categories = models.ManyToManyField(

Re: many to many field

2008-06-24 Thread Stephan Jäkel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thanks for the advice. great stuff. i'll follow the ticket. best regards, Ramiro Morales wrote: | On Tue, Jun 24, 2008 at 3:40 PM, Stephan Jäkel <[EMAIL PROTECTED]> wrote: |> -BEGIN PGP SIGNED MESSAGE- |> Hash: SHA1 |> |> OK. I hoped, there

Re: many to many field

2008-06-24 Thread Ramiro Morales
On Tue, Jun 24, 2008 at 3:40 PM, Stephan Jäkel <[EMAIL PROTECTED]> wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > OK. I hoped, there is a possibility to use ManyToManyField. Well, the > Model-way is already implemented but i would like to use > ManyToManyField. Anyway, it works. >

Re: many to many field

2008-06-24 Thread Stephan Jäkel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 OK. I hoped, there is a possibility to use ManyToManyField. Well, the Model-way is already implemented but i would like to use ManyToManyField. Anyway, it works. joshuajonah wrote: | You need to define your many-to-many table in the model, and then u

Re: many to many field

2008-06-24 Thread joshuajonah
You need to define your many-to-many table in the model, and then use the "db_column" option to name the fields in that table. http://www.djangoproject.com/documentation/models/custom_columns/ On Jun 24, 1:43 pm, Stephan Jäkel <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Has

  1   2   >