manytomany field errors

2023-03-21 Thread Abhishek ozha
models::from django.db import models from apps.user.models.users import User class Team(models.Model): user = models.ManyToManyField(User, related_name="staff_teams") team = models.CharField(max_length=50) description = models.TextField(max_length=250) verbose_name_plural = "Teams" def __str__(

QuerySet Caching of ManyToMany fields

2022-04-21 Thread Russell Melick
Hi All, We've been working on improving the performance of our backend recently, and have started analyzing the database queries generated by Django more thoroughly. We quickly realized that we were mis-using our ManyToMany fields. We had assumed that the results of accessing an M2M

Django Serialization: ManyToMany Field doesn't input into database

2022-04-12 Thread Jeffrey Ma
The code runs and all fields except the manytomany field is written into the mysql database. I am posting json to the django backend which will be written into the database. For more information: https://stackoverflow.com/questions/71849923/django-serializer-inserting-nothing-into-database-no

Mange ManyToMany relational model for offline syncing

2021-09-22 Thread Shuham Bansal
Hi, Anyone who can help me to manage ManyToMany relation model for offline data syncing. My points are following. 1. How we can detect updated data, or deleted data in ManyToMany table (which is created by djnago default to manage realtion data) 2. Can we access ManyToMany table's prima

Need help for offline data sync of ManyToMany relation table

2021-09-22 Thread Shuham Bansal
Hi, I want to know about, how we can manage ManyToMany relation table for offline data sync, where frontend pass the data as different model for ManyToMany relation field. Can anyone suggest me some tips. Thanks -- You received this message because you are subscribed to the Google Groups

get_changeform_initial_data with ManyToMany

2021-07-09 Thread Thibault Thomas
Hello, How can I use admin's get_changeform_initial_data function to prepopulate a many to many relationship widget ? I have the following models in models.py : ___ *class Piece(models.Model):* vehicules = models.ManyToManyField(Vehicule, thr

How do I return a queryset of all items (X) ManyToMany related to model class (Y) and include values for (Y) in the same result in each item X

2021-07-05 Thread mtp...@gmail.com
I have the following two model classes: ``` class Property(models.Model): """Represents property class model""" serial_no = models.CharField(unique=True,max_length=255,blank=True,null=True) map_no = models.CharField(max_length=255,blank=True,null=True) lr_no = models.CharField(ma

Re: Specifying a database connection for ManyToMany add()

2021-06-23 Thread Mike Dewhirst
On 23/06/2021 7:18 pm, Jayanth Shankar wrote: Hi, I am trying to add items to a ManyToMany relationship, but I would like to make the operation use a particular database connection, like one might do when calling save() on a model instance. However, looking at the source for ManyToMany.add

Specifying a database connection for ManyToMany add()

2021-06-23 Thread Jayanth Shankar
Hi, I am trying to add items to a ManyToMany relationship, but I would like to make the operation use a particular database connection, like one might do when calling save() on a model instance. However, looking at the source for ManyToMany.add(), the function defaults to checking the

Re: How to avoid select lists on formsets and ManyToMany?

2021-04-01 Thread Ryan Nowakowski
1, 2021 10:23:03 PM CDT, Clive Bruton wrote: >I have a ManyToMany model set, that on the edit uses a formset to add/ >edit rows. I have this working, but the unfortunate part of it is >that the select that results from the ManyToMany relationship >populates with 16,000 records. >

How to avoid select lists on formsets and ManyToMany?

2021-04-01 Thread Clive Bruton
I have a ManyToMany model set, that on the edit uses a formset to add/ edit rows. I have this working, but the unfortunate part of it is that the select that results from the ManyToMany relationship populates with 16,000 records. What I would like to do is, once the records are added, just

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
After playing with this to answer your question and to correct my previous response, I found that it does work as documented when using a "through" model without using "through_fields". from django.db import models class Person(models.Model): name = models.CharField(max_length=255) fr

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread gjgilles via Django users
iendship = Friendship.objects.get_or_create(personA=self, >>> personB=person) >>>         if symmetric: >>>             # avoid recursion >>>             person.add_friendship(self, False) >>>         return friendship >>> >>> >>> Re

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
: # avoid recursion person.add_friendship(self, False) return friendship Regards, David On 17 Oct 2020, at 05:38, gjgilles via Django users wrote: There are no responses to the same question on stackoverflow, so hopefully someone here can provide a solution.

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread coolguy
> > Regards, David > > On 17 Oct 2020, at 05:38, gjgilles via Django users < > django...@googlegroups.com> wrote: > > There are no responses to the same question on stackoverflow, so hopefully > someone here can provide a solution. > <https://stackoverflow.com

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
de a solution.<https://stackoverflow.com/questions/64346385/how-to-make-a-recursive-manytomany-relationship-symmetrical-with-django> I've read the docs.<https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.ManyToManyField.symmetrical> I've read this question too,<h

How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread gjgilles via Django users
There are no responses to the same question on stackoverflow, so hopefully someone here can provide a solution. <https://stackoverflow.com/questions/64346385/how-to-make-a-recursive-manytomany-relationship-symmetrical-with-django>   I've read the docs. <https://docs.djangoproj

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: How to read Objects from ManyToMany Relation class in django

2019-12-29 Thread Integr@te System
Hi, Check url.py with typo error at closed parenthesic. On Sun, Dec 29, 2019, 20:35 manas srivastava wrote: > > > > I have made a class called friend where i want to connect users as > followers. Here From this class i am unable to read the users those are > following another user. For Eg if 'a

Re: ManyToMany no Model

2019-06-19 Thread Sipum Mishra
Ggt yano jika teme sulo faso tadan siku. Lhggg On Wed, 19 Jun, 2019, 5:55 PM Christian Oliveira, < christianoliveir...@gmail.com> wrote: > Bom dia, como posso fazer para acessar os dados de uma tabela derivada de > um ManyToMany?? > > -- > You received this message because

Re: How to access manytomany field content

2019-06-19 Thread Андрей Сердюк
So You should to show Your template first and use ModelForm to inherit it with model You need in meta options. -- 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 d

Re: How to access manytomany field content

2019-06-19 Thread Alagiri Rajesh
Hi @Андрей Сердюк, Thank you for quick response. Some clarifications please? So you are saying that i need to create a new class for the category? the current code for one of my app where i am using category field is as below: class Listing(models.Model): > user= models.Foreig

How to access manytomany field content

2019-06-19 Thread Андрей Сердюк
Hi, if Your code looks like this: class Category(models.Model): name = models.CharField(maxlength=32) pass class Goods(models.Model): categories = models.ManyToManyField(Category, on_delete=models.CASCADE) You would get it with this code: category = Category.objects.get(pk=23) goods

How to access manytomany field content

2019-06-19 Thread Alagiri Rajesh
Hi I am using the "Django Category" app (https://github.com/praekelt/django-category) I have installed the same and also have implemented the same. How do i access the category title and other details. Have tried to use the documentation but using

ManyToMany no Model

2019-06-19 Thread Christian Oliveira
Bom dia, como posso fazer para acessar os dados de uma tabela derivada de um ManyToMany?? -- 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-user

Order_by ManyToMany relation?

2019-06-05 Thread Mei B
I have a form for a model that contains a ManyToMany relationship to model B. By default, manytomany relationship on forms are SelectMuliple and orders them by alphabetical. How can I order by if they already have a relation? In my forms.py class FormA(forms.ModelForm): class Meta

[formset] ManyToMany

2019-04-09 Thread Robin Riis
if i have the following models: class Wiggs_Filter(models.Model): wiggs_nr = models.CharField(max_length=30, unique=True, blank=True, null=True) picture = models.ImageField(upload_to='filter/', default='filter/saknas.jpg') description = models.CharField(max_length=100, blank=True, null

Issue with ManyToMany Relations

2019-03-01 Thread Julio Cojom
I'm writting 2 models with ManyToMany Relations, first I make a model to list all my requirements class Requirements(models.Model): requirement = models.CharField(max_length=150) def __str__(self): return self.requirement So in this example my list of requirements will be: - Person

Generic method that can take any Django Model and provide information about manytomany field.

2018-09-11 Thread Akshay Gaur
Also posted here : https://stackoverflow.com/questions/52280584/any-way-to-fetch-the-through-fields-for-an-object-linked-via-many2many-field-wit I am trying to write a generic method that can take any Django Model and returns it in a dictionary form. So for example, if my models are defined thu

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

How to get multiple entries for ManyToMany relations in filter_horizontal Admin

2018-07-24 Thread Christian Merlau
Hey, I am trying to solve following problem and I got stuck. Any help is appreciated... I have two models which represent a product and its parts. class Product(models.Model): name = models.CharField(max_length=200) average_daily = models.FloatField(default=0) average_monthly = models.Inte

Bi-directional ManyToMany usage with ModelForm

2018-05-09 Thread Bernhard Miller
Hello, I'm currently implementing a django-based project that features users and user groups. The two are connected by a ManyToMany relationship. Using the generic django helpers (ModelForm, UpdateView, CreateView, ...) I would like to be able to edit this many to many connection from

Re: M2M Magic Accessors without explicit ManyToMany Field

2018-05-08 Thread Vijay Khemlani
commenter suggested using `add_to_class` on one of the 3rd party > models. It passes trivial test cases, but has hair and some of the magic > breaks because it's treated as a `through=` relationship even though it's a > trivial M2M table. > > I'm hoping someone who u

M2M Magic Accessors without explicit ManyToMany Field

2018-05-08 Thread Clayton D
) table. A commenter suggested using `add_to_class` on one of the 3rd party models. It passes trivial test cases, but has hair and some of the magic breaks because it's treated as a `through=` relationship even though it's a trivial M2M table. I'm hoping someone who understands the

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-06 Thread Web Architect
Hi Furbee, Thanks for the suggestion. Would look into it. Thanks. On Sunday, February 4, 2018 at 10:32:20 AM UTC+5:30, Furbee wrote: > > You can set up an index on multiple field, as well, so if you’re searching > for As without a reference from B or C, using the index_together operative > i

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-03 Thread Furbee
You can set up an index on multiple field, as well, so if you’re searching for As without a reference from B or C, using the index_together operative in the class Meta for that model. I’m not completely sure, but I think this may speed up you query time. Thanks, Furbee On Saturday, February 3, 2

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-03 Thread Vijay Khemlani
Well, you should've said that in the first post. First I would try with a saner DB (Postgres) Also I don't think 300 ms is particularly bad, but in that case start looking into caching alternatives (e.g. memcached) or a search index (e.g. ElasticSearch) On Sat, Feb 3, 2018 at 3:14 AM, Web Archit

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Furbee, Thanks for your response. With my experience I have always noticed that a query within query kills the mysql and Mysqld CPU usage hits the ceiling. I would still check your alternate. I have mentioned the size of A and B in response to Vijay's reply. On Saturday, February 3, 201

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Vijay, Thanks for your response. In my scenario, there is also another model with manytomany relation with A: class C(models.Model): a = manytomany('A', related_name='cs', through='D') so, for around 25K records in A, 45K records in D and 18K records in

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Furbee
There are a couple options you could try to see which is the best fit for your data. With DEBUG=True in settings.py you can check the actual queries and process time. It depends on the sizes of A and B. Another query you can run is: A.objects.exclude(id__in=B.objects.all().values_list('a_id', flat

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Vijay Khemlani
"with large of records in A and B, the above takes lot of time" How long? At first glance it doesn't look like a complex query or something particularly inefficient for a DB. On Fri, Feb 2, 2018 at 11:31 AM, Andy wrote: > not that i know of > > > Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schri

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
not that i know of Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect: > > Hi Andy, > > Thanks for your response. I was pondering on option a before posting this > query thinking there could be better ways in django/SQL to handle this. But > now I would probably go with a. > > Than

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Andy, Thanks for your response. I was pondering on option a before posting this query thinking there could be better ways in django/SQL to handle this. But now I would probably go with a. Thanks. On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote: > > a) Maybe its an option to p

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
a) Maybe its an option to put the foreign key to the other model? This way you dont need to make a join to find out if there is a relation. b) Save the existing ralation status to model A c) cache the A.objects.filter(bs__isnull=False) query But apart from that i fear you cannot do much more, s

Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi, I am trying to optimise Django queries on my ecommerce website. One of the fundamental query is where I have no clue how to make efficient. It could be trivial and probably been known long time back. But I am new to Django and would appreciate any help. This is primarily for one to many or

Re: ManyToMany widget in admin - the "user - permission way.."

2017-11-28 Thread Matemática A3K
> > I have this error: > > Unhandled exception in thread started by check_errors..wrapper at 0x7f2fa8d646a8> > > Traceback (most recent call last): > > File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", > line 228, in wrapper > > fn(*args, **kwargs) > > File "/usr/lo

Re: ManyToMany widget in admin - the "user - permission way.."

2017-11-28 Thread Allan Nava
ormal multi- > > select box. > > > > My models could look like this: > > > > class Interest(models.Model): > > name= models.CharField(max_length=255) > > > > class Person(models.Model): > > name= models.CharField(max_length=255) &g

ManytoMany Relation and Custom widget in Django

2017-11-17 Thread Paul
last children categories Options I thought: 1. Change the ManyToMany coresponding default Fields - looks like there are no good hooks and/or inheritance 2. Use a non-default custom Field instean of ManytoMany(like Charfield) - more complex on clean,saving Form 3. Change/Inherit the widget. My is

ManytoMany Relation and Custom widget in Django

2017-11-13 Thread Paul
was already chosen should be available. *From where I start:* I know that to ManyToMany relation corresponds a ModelMultipleChoiceField Field. To a ModelMultipleChoiceField corresponds a SelectMultiple widget. I thought of creating an widget that inherits from SelectMultiple and change the

Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
, 'is_active', 'groups') search_fields = [ 'date_joined', 'email', 'first_name', 'last_name', 'username', ] ordering = ['-date_joined', 'username']

Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
use this code for ManytoMany fields in django admin : filter_horizontal = ('groups', 'user_permissions',) On Fri, Nov 3, 2017 at 1:45 PM, Paul wrote: > I have a Product model, an Image Model and a Category Model. > > A Product can have multiple Images(Foreign

ManytoMany field in Django admin not appearing

2017-11-03 Thread Paul
I have a Product model, an Image Model and a Category Model. A Product can have multiple Images(Foreign Key) and a Product can be in multiple Categories a Category can contain multiple Products. A Category can have multiple subcategories(key to itself). class Category(MetaData): parent =

Re: How to add more fields to each ManyToMany Field in Django?

2017-09-05 Thread Omer Iqbal
Thank you - The problem is solved. I had deleted the migration files because It was showing no table error. But on deleting the database file (db.sqlite3) and re-applying migrations, It worked. -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: How to add more fields to each ManyToMany Field in Django?

2017-09-05 Thread Omer Iqbal
t; >> Hi, >> >> >> >> >> >> >> >> Is it possible to add one or more field (Char Field) to the options of >> ManyToMany field? >> >> My current models result in this: >> >> <https://i.stack.imgur.com/Fz1tr.png

Re: How to add more fields to each ManyToMany Field in Django?

2017-09-04 Thread Mark Phillips
; Is it possible to add one or more field (Char Field) to the options of > ManyToMany field? > > My current models result in this: > > <https://i.stack.imgur.com/Fz1tr.png> > > > > *My Models:* > > > class engineeringUni(models.Model): > > >

How to add more fields to each ManyToMany Field in Django?

2017-09-04 Thread Omer Iqbal
Hi, Is it possible to add one or more field (Char Field) to the options of ManyToMany field? My current models result in this: <https://i.stack.imgur.com/Fz1tr.png> *My Models:* class engineeringUni(models.Model): field2 = models.CharField(max_length=200) d

Re: Retrieve field values from ManyToMany field in model

2017-06-28 Thread Mark Phillips
Melvyn, Thanks for your response. My original question was how to get the string names for the metadata and document out of the many to many table in the __str__ model method. I was able to accomplish this by the following class DocumentMetaData(models.Model): document = models.ManyToManyFiel

Re: Retrieve field values from ManyToMany field in model

2017-06-26 Thread Melvyn Sopacua
On Sunday 25 June 2017 15:08:25 Mark Phillips wrote: > I have this class > > class DocumentMetaData(models.Model): > document = models.ManyToManyField(Document) > metadata = models.ManyToManyField(MetaData) > metadatavalue = models.ManyToManyField(MetaDataValue) That design is wrong.

Re: Retrieve field values from ManyToMany field in model

2017-06-25 Thread Mark Phillips
On Sun, Jun 25, 2017 at 4:20 PM, Vijay Khemlani wrote: > A DocumentMetaData instance may be associated with multiple documents > and multiple metadata according to your model, so your question is > ambiguous. > Sorry about the confusion. When I create a DocumentMetaData, then there is a single r

Re: Retrieve field values from ManyToMany field in model

2017-06-25 Thread Vijay Khemlani
A DocumentMetaData instance may be associated with multiple documents and multiple metadata according to your model, so your question is ambiguous. If you want a particular DocumentMetaData to only refer to a single document and a single metadata then change the ManyToManyField for a ForeignKey I

Retrieve field values from ManyToMany field in model

2017-06-25 Thread Mark Phillips
I have this class class DocumentMetaData(models.Model): document = models.ManyToManyField(Document) metadata = models.ManyToManyField(MetaData) metadatavalue = models.ManyToManyField(MetaDataValue) def __str__(self): return "%s - %s" % (self.document, self.metadata) The D

ManyToMany without through table

2016-11-18 Thread 'kgardenia42' via Django users
Lets say I have a User who I want to allow to have many different UserProfile objects (for multi-tenancy). class User(models.Model): # other user fields ... profiles = models.ManyToManyField('UserProfile', related_name='profiles', blank=True, null=True) class UserProfile(models.Model)

ManyToMany without through table

2016-11-18 Thread 'kgardenia42' via Django users
Lets say I have a User who I want to allow to have many different UserProfile objects (for multi-tenancy). class User(models.Model): # other user fields ... profiles = models.ManyToManyField('UserProfile', related_name='profiles', blank=True, null=True) class User

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-03 Thread Michal Petrucha
Hi Bruce, On Mon, May 02, 2016 at 02:31:37PM -0700, Bruce Whealton wrote: > Michal, >I had to read your response a few times but I finally got it. I was > reading > that all migrations are created in development only and then applied during > production. > So, during development you u

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Bruce Whealton
Michal, I had to read your response a few times but I finally got it. I was reading that all migrations are created in development only and then applied during production. So, during development you use makemigrations and then when deployed you migrate. Thus, if you add a new feature

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Michal Petrucha
On Mon, May 02, 2016 at 08:37:43AM -0700, Bruce Whealton wrote: > I'm not sure if it is ok to use python manage.py makemigrations on the > production server or if one should just do that locally and then import it. Hi Bruce, Migrations are a part of your application's code base, and they should

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-05-02 Thread Bruce Whealton
As an update to this... I decided to simplify things a bit. For my contacts application, I decided to start with just one table. I got that working in a Ubuntu Vbox environment, inside a virtualenv. I'm not sure if it is ok to use python manage.py makemigrations on the production server o

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-26 Thread Mike Dewhirst
y") class Meta: verbose_name = 'Connection' verbose_name_plural = 'Connnections' Good luck Mike Bruce Anyway, I will try to remove the ManyToMany statement from the Connections Model. Â I would then have one Contact or Organization maps to

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-26 Thread Bruce Whealton
Having followed all the suggestions, I am now stuck. I have simplified the database by removing one model. I get to the point of python manage.py makemigrations and it returns with what looks right. However, the migrate command just throws out a bunch of errors. For some reason, it is looki

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-26 Thread Bruce Whealton
have a table now for that model. I wonder if I need a ForeignKey field in the ContactsOrOrganization table? Bruce Anyway, I will try to remove the ManyToMany statement from the Connections Model. I would then have one Contact or Organization maps to many Connection types. On Sunday, April

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-26 Thread Bruce Whealton
OK, for starters, I understand the need for Null=True and blank=True. So, jumping down...Not sure a better way to do this but I will leave my comments for reference including my models and then respond to the questions So sorry for my delay, I wasn't well this past weekend. >> >> My proble

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-23 Thread Mike Dewhirst
On 23/04/2016 11:22 PM, Bruce Whealton wrote: Hello all,      So, I setup django in a virtualenv on my Ubuntu environment.  I was reading the docs and thought I had things right for creating the 3 models I wanted with this application. I am using Postgresql.  I have the Postgresql dr

Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-23 Thread Camilo Torres
On Saturday, April 23, 2016 at 10:00:45 AM UTC-4:30, Bruce Whealton wrote: > > Hello all, > So, I setup django in a virtualenv on my Ubuntu environment. I > was reading the docs and thought I had things right > for creating the 3 models I wanted with this application. I am using > Pos

Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-23 Thread Bruce Whealton
Hello all, So, I setup django in a virtualenv on my Ubuntu environment. I was reading the docs and thought I had things right for creating the 3 models I wanted with this application. I am using Postgresql. I have the Postgresql driver for Python/Django installed in the virtualenv.

django-extensions: dumpscript/runscript manytomany with through= broken?

2016-04-02 Thread Daniel Wilcox
Hello, I was wondering if anyone knows a good way to handle restoring a backup taken with a m2m intermediary model. I'm trying to upgrade from my sqlite database to a real database and would like to keep the data that was created thus far. Basically the models look like this: class Message(model

Re: Show labels next to ManyToMany raw_id_fields

2016-03-03 Thread Tim Graham
ticket is: https://code.djangoproject.com/ticket/26313 On Tuesday, February 17, 2009 at 4:52:25 PM UTC-5, Alex Gaynor wrote: > > > > On Tue, Feb 17, 2009 at 4:50 PM, João Olavo Baião de Vasconcelos < > joao...@gmail.com > wrote: > >> On Tue, Feb 17, 2009 at 5:15 PM, Alex Gaynor > > wrote: >> >>> S

Re: help with ManyToMany

2016-02-02 Thread dave.l
o from class studiogroup one or >> more entries from the class studio so simple, >> >> christos >> >> Τη Τετάρτη, 27 Ιανουαρίου 2016 - 5:50:21 μ.μ. UTC+2, ο χρήστης dave.l >> έγραψε: >>> >>> Hi, >>> >>> I have recently retur

Re: help with ManyToMany

2016-01-31 Thread Peter of the Norse
> your code is correct,where are the problem ?in the admin first add Studio and > sfter this select on the field studio from class studiogroup one or more > entries from the class studio so simple, > > christos > > Τη Τετάρτη, 27 Ιανουαρίου 2016 - 5:50:21 μ.μ. UTC+2,

Re: help with ManyToMany

2016-01-28 Thread dave.l
t;> Hi, >> >> I have recently returned to a Django project after a few years and I'm a >> little rusty on ManyToMany fields. >> >> Here's my very simple models: >> >> >> class Studio(models.Model): >> name = models.CharF

Re: help with ManyToMany

2016-01-27 Thread Xristos Xristoou
> > I have recently returned to a Django project after a few years and I'm a > little rusty on ManyToMany fields. > > Here's my very simple models: > > > class Studio(models.Model): > name = models.CharField(max_length=255, unique=True) > > c

help with ManyToMany

2016-01-27 Thread dave.l
Hi, I have recently returned to a Django project after a few years and I'm a little rusty on ManyToMany fields. Here's my very simple models: class Studio(models.Model): name = models.CharField(max_length=255, unique=True) class StudioGroup(models.Model): d

Database Relation: ManyToMany with extra information?

2016-01-15 Thread Balázs Oroszi
VersionedSoftware simply with a regular ManyToMany (if you don't need other link specific fields). Greets, Balázs -- 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, se

Database Relation: ManyToMany with extra information?

2016-01-15 Thread maxi . matthe
version. So, P has like a ManyToMany relation to S, however for each "link" the extra-field Version would be required. In a table layout, this could look like this: Table PC, with columns: Name, IP ... Table Software with columns: Name, Description, ... Table InstalledSof

passing list of objects as manytomany field type in django

2016-01-06 Thread Akash Tomar
I want to know if we can pass a list of objects (in this case list of blog objects to the Entry model as the manytomany object parameter). On doing so i am not getting the desired result. Please help. models.py class Blog(models.Model): id=models.AutoField(primary_key=True) class Entry

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
Thanks :-) Should have guessed it was that easy! On Wed, Dec 23, 2015 at 12:44 PM, Vijay Khemlani wrote: > You should be able to query it as a ForeignKey > > Jobs.objects.filter(names__is_a_problem=True).distinct() > > (distinct to prevent repeated jobs with more than one worker problem) > > > O

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Vijay Khemlani
You should be able to query it as a ForeignKey Jobs.objects.filter(names__is_a_problem=True).distinct() (distinct to prevent repeated jobs with more than one worker problem) On Wed, Dec 23, 2015 at 9:31 AM, Jonty Needham wrote: > I have a model of the form: > > class Jobs(models.Model): >

Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
I have a model of the form: class Jobs(models.Model): names = models.ManyToManyField(Workers) class Workers(modesl.Model): is_a_problem = True And I want the set of jobs that are done by workers who are a problem. Something like Jobs.objects.filter(names__is_contained_in=Workers

Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread filias
1] https://docs.djangoproject.com/en/1.8/releases/1.8/#model-meta-api > [2] > https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField.related_name > > Le vendredi 4 décembre 2015 07:08:51 UTC-5, filias a écrit : >> >> Indeed something in the proje

Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread Simon Charette
.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField.related_name Le vendredi 4 décembre 2015 07:08:51 UTC-5, filias a écrit : > > Indeed something in the project's code must be wrong but it is not the > bi-directional ManyToMany as this has been working in django 1.4, 1.5, 1.6 > and 1.7. One m

Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread filias
Indeed something in the project's code must be wrong but it is not the bi-directional ManyToMany as this has been working in django 1.4, 1.5, 1.6 and 1.7. One might want to had the ManyToMany in both models so to be able to add more information, as it is stated in the django docs

Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread Remco Gerlich
lias wrote: > Hi, > > I have recently upgraded to sjango 1.8 and I have 2 models with a > bi-directional ManyToMany field. It looks like this > > class Pizza(Model): > available_toppings = ManyToManyField('Topping') > > class Topp

Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread filias
Hi, I have recently upgraded to sjango 1.8 and I have 2 models with a bi-directional ManyToMany field. It looks like this class Pizza(Model): available_toppings = ManyToManyField('Topping') class Topping(Model): all_pizzas = ManyToManyField(Pizza

Re: How to implement clean() for a model with ManyToMany fields?

2015-10-17 Thread John Lawlor
reiche: > raise ValidationError("This calender entry won't be > displayed anywhere.") > > > What I would like to do in clean() is making sure that not all three > ManyToMany fields are empty/blank all at the same time. > > However, it doesn&#x

Re: ManyToMany doesn't support validators?

2015-10-13 Thread Tim Graham
The rationale is described in https://code.djangoproject.com/ticket/19671. On Tuesday, October 13, 2015 at 7:06:16 AM UTC-7, Mike Herring wrote: > > Doc here: > > https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField > > ManyToManyField does not support validato

ManyToMany doesn't support validators?

2015-10-13 Thread Mike Herring
Doc here: https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField ManyToManyField does not support validators. Is there a particular reason that ManyToManyField doesn't support validators? I would like to add a validator to require the user to select at least

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

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

  1   2   3   4   5   6   7   8   9   10   >