Re: i have issue in serializer foreign key relations

2022-08-21 Thread user8234
Can you explain how is your data or database schema, your model is based on a ORM design?, I mean that you probably need to check API token validation El dom., 21 de agosto de 2022 12:23 p. m., Shams Ulhaq < ulhaqshams...@gmail.com> escribió: > i have a code that have multiple relation for gettin

i have issue in serializer foreign key relations

2022-08-21 Thread Shams Ulhaq
i have a code that have multiple relation for getting data i need someone who can help me in getting data in serializer -- 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 em

Re: relations

2022-01-27 Thread frank dilorenzo
After numerous attempts I think I found my solution. (NO ERRORS) supplier/models.py shipment = models.ForeignKey( Shipment, on_delete=models.DO_NOTHING, null=True, blank=True) specie/models.py no reference to any other model supplier/

Re: relations

2022-01-27 Thread frank dilorenzo
Well my friend, the only reason I have to do the imports is because each model is in it's own app. In every example I have seen the models are usually small and contained in one app. Perhaps I need to redesign my project to have everything lumped together? In my project I have an app for base, sh

Re: relations

2022-01-26 Thread bnmng
Hi, You shouldn't have to import since the models are in the same models.py On Wednesday, January 26, 2022 at 2:26:13 PM UTC-5 frank...@gmail.com wrote: > After trying the suggestions I get these errors. > > supplier.models: > > class Supplier(models.Model): > > name = models.CharField(m

Re: relations

2022-01-26 Thread frank dilorenzo
After trying the suggestions I get these errors. supplier.models: class Supplier(models.Model): name = models.CharField(max_length=50) phone = models.CharField(max_length=15, null=True, blank=True) email = models.CharField(max_length=120, null=True, blank=True) country = model

Re: relations

2022-01-26 Thread frank dilorenzo
Thank you so much. Have a great day! frank- On Wed, Jan 26, 2022 at 6:51 AM bnmng wrote: > I would start by defining Supplier in your models.py, then Shipment with a > ForeignKey reference to Supplier > > I'm assuming (forgive me if I'm wrong) that not only can a shipment have > many species,

Re: relations

2022-01-26 Thread bnmng
I would start by defining Supplier in your models.py, then Shipment with a ForeignKey reference to Supplier I'm assuming (forgive me if I'm wrong) that not only can a shipment have many species, but a species can be in many shipments, so if that's the case, the most obvious way is to go with Ma

relations

2022-01-24 Thread frank dilorenzo
I have tried several different ways but I cannot seem to get this right. What I have is a list of suppliers. Each supplier can have many shipments and each shipment can have many species. Seems simple enough but apparently I must be more simple. I need a suggestion of how to relate these tab

Re: View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-19 Thread Marko
Yes, my example is not right. Both should be the same! nader...@gmail.com schrieb am Donnerstag, 19. August 2021 um 16:59:01 UTC+2: > I noticed that subassembly 6 has different components in use. Is that what > you want. > > On Wed, Aug 18, 2021, 10:57 AM M. GW wrote: > >> Hi, >> >> I am now tr

Re: View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-19 Thread Marko
Hey, thank you. I tried your approach and is looks very promising but I am getting an error. Here is my view: *class AssemblyDetailView(LoginRequiredMixin, DetailView):* *model = Assembly* *template_name = "engineering/assembly/assembly_detail.html"* *assem = Assembly.objects.all()*

Re: View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-19 Thread Nader Elsisi
I noticed that subassembly 6 has different components in use. Is that what you want. On Wed, Aug 18, 2021, 10:57 AM M. GW wrote: > Hi, > > I am now trying, for days, to get a tree like view from my assembly model > into my template. I think I have read everything what I have found on > StackOver

Re: View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-19 Thread David Crandell
I would create two dictionaries, one for subassembly and one for component. then in your view, loop through the first group, pulling your data from a master dataset: assem = Assembly.objects.all() sa = assem.subassembly.all() comp = assem.component.all() send 'sa' and 'comp' to your template as

View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-18 Thread M. GW
Hi, I am now trying, for days, to get a tree like view from my assembly model into my template. I think I have read everything what I have found on StackOverflow and other sites. Somehow I am not able to get it working. I am trying to not use any 3rd party extensions => I'm happy to be proven

Re: Django User Roles and user relations

2020-02-20 Thread onlinejudge95
On Thu, Feb 20, 2020 at 5:53 PM Kirankumar wrote: > Hii All.. > > I'm trying to give level roles like admin defaultly it is > available and Manager group and normal user groups in my django > aplication... > > Generally admin can fetch all the records created by all > users..N

Django User Roles and user relations

2020-02-20 Thread Kirankumar
Hii All.. I'm trying to give level roles like admin defaultly it is available and Manager group and normal user groups in my django aplication... Generally admin can fetch all the records created by all users..Now my requirement is the user which is in manager group can fet

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

Re: Accessing child relations when overriding save()

2019-02-10 Thread Mike Dewhirst
On 10/02/2019 6:22 pm, Nick Emery wrote: I am trying to wrap up my first app using Django (specifically Django Rest Framework which may change the save behavior), but have run into an issue that I haven't been able to solve for about 10 hours now. I am trying to override the save() method of a

Re: Accessing child relations when overriding save()

2019-02-10 Thread Nick Emery
UPDATE: Finally figured it out! I ultimately did this by overriding `perform_create()` in my [Django Rest Framework view](https://www.django-rest-framework.org/api-guide/generic-views/) and making my changes after saving the object. On Sunday, February 10, 2019 at 8:34:44 AM UTC-5, Nick Emery w

Re: Accessing child relations when overriding save()

2019-02-10 Thread Nick Emery
The child objects are created separately beforehand with NULL parents (they don't have to have parents, they can be orphans). One other thing I noticed is that looking at the SQL statements executed by my app I can't even see the UPDATE on the foreign keys of the children (even though I KNOW it'

Re: Accessing child relations when overriding save()

2019-02-10 Thread Shashank Singh
And how? On Sun, 10 Feb, 2019, 9:23 PM Shashank Singh When do you create child objects?? > > On Sun, 10 Feb, 2019, 9:17 PM Nick Emery >> Tried this too but save() never actually gets called on the child (it >> seems that the foreign key field of the child is updated at the database >> level and

Re: Accessing child relations when overriding save()

2019-02-10 Thread Shashank Singh
When do you create child objects?? On Sun, 10 Feb, 2019, 9:17 PM Nick Emery Tried this too but save() never actually gets called on the child (it > seems that the foreign key field of the child is updated at the database > level and never goes through the Django orm Child). > > On Sunday, Februar

Re: Accessing child relations when overriding save()

2019-02-10 Thread Nick Emery
Tried this too but save() never actually gets called on the child (it seems that the foreign key field of the child is updated at the database level and never goes through the Django orm Child). On Sunday, February 10, 2019 at 8:37:54 AM UTC-5, Shashank Singh wrote: > > Override the save() of th

Re: Accessing child relations when overriding save()

2019-02-10 Thread Shashank Singh
Override the save() of the child? On Sun, 10 Feb, 2019, 7:04 PM Nick Emery I am trying to wrap up my first app using Django (specifically Django > Rest Framework which may change the save behavior), but have run into an > issue that I haven't been able to solve for about 10 hours now. > > I am tr

Accessing child relations when overriding save()

2019-02-10 Thread Nick Emery
I am trying to wrap up my first app using Django (specifically Django Rest Framework which may change the save behavior), but have run into an issue that I haven't been able to solve for about 10 hours now. I am trying to override the save() method of a model to modify a field on a bunch of chi

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

Re: selecting an item whose relations are all in some desired set

2016-05-17 Thread Florian Iragne
Le 17/05/2016 16:18, David Xiao a écrit : Hi Florian, That's technically correct, but the universe of all possible items might be very large or even infinite so it's not really practical to do it that way. I understand, but i don't now your case precisely. In my case, i do this for a few t

Re: selecting an item whose relations are all in some desired set

2016-05-17 Thread David Xiao
Hi Florian, That's technically correct, but the universe of all possible items might be very large or even infinite so it's not really practical to do it that way. Dave On Tue, May 17, 2016 at 9:32 AM florian wrote: > > > Le mardi 17 mai 2016 14:04:28 UTC+2, David Xiao a écrit : >> >> Hi Vitor,

Re: selecting an item whose relations are all in some desired set

2016-05-17 Thread florian
Le mardi 17 mai 2016 14:04:28 UTC+2, David Xiao a écrit : > > Hi Vitor, > > Sorry I realized that my example should have used a ManyToManyField > instead of a 1-to-many. Let me try again: > > class Bundle(Model) > items = ManyToManyField("Item") > > class Item(Model) > pass > > (So one item

Re: selecting an item whose relations are all in some desired set

2016-05-17 Thread David Xiao
Hi Vitor, Sorry I realized that my example should have used a ManyToManyField instead of a 1-to-many. Let me try again: class Bundle(Model) items = ManyToManyField("Item") class Item(Model) pass (So one item can belong many Bundles and one Bundle can have many Items.) Suppose I've create

Re: selecting an item whose relations are all in some desired set

2016-05-13 Thread Vitor Freitas
Hi David, Perhaps you can try using *exclude *instead of *filter*: https://docs.djangoproject.com/en/1.9/topics/db/queries/#retrieving-specific-objects-with-filters But wasn't 100% clear for me what you are trying to achieve, so I don't know if the following query will be give you the desired res

selecting an item whose relations are all in some desired set

2016-05-13 Thread David Xiao
Django is missing the "not in" operator and I have a situation where the workarounds (using ~Q or using exclude) don't seem to give a satisfactory solution. Suppose I have two models: from django.db.models import Model, ForeignKey class Bundle(Model): pass class Item(Model): bundle = Forei

How to update values in instance when have a custom .update() to update many-to-many relations in DRF writable nested serializer?

2016-04-05 Thread Manjit Kumar
Field(auto_now_add=True, blank=True) update_ts = models.DateTimeField(auto_now_add=True, blank=True) Now I was required to update this membership using django rest framework. I tried update those using Writable nested serializers <http://www.django-rest-framework.org/api-guide/relation

Re: Relations one-to-many on django

2016-02-23 Thread Vijay Khemlani
Each product is only associated with one category, so you can only do produto.categoria If you want to iterate over all categories, and then through the products of each category, you could do {% for categoria in categorias %} {% for produto in categoria.produto_set.all %} do comething with prod

Re: Relations one-to-many on django

2016-02-23 Thread James Schneider
> > I try to use >> >> {% if categorias %} >> >> {% for categoria in produto.categoria_set() %} At no time can parentheses be used when referencing variables. The correct way to write this tag would be {% for categoria in produto.categoria_set %

Relations one-to-many on django

2016-02-23 Thread Douglas Bonafe
Hello everybody! I'm new on this forum and in django. I'm using Python 2.7 environment. I have the following models.py: class Categoria(models.Model): > > DEFAULT_CATHEGORY = 0 > nome = models.CharField(max_length=255, null=False, default='0') > > def __unicode__(self): > retu

Re: FK relations hell : help with `_set` feature

2015-03-30 Thread François GUÉRIN
Le lundi 30 mars 2015 14:31:19 UTC+2, Daniel Roseman a écrit : > > > On Monday, 30 March 2015 13:04:00 UTC+1, François GUÉRIN wrote: >> >> Hi all, >> >> I'm using django for a couple of years, and I've a question about >> relations in the ORM a

Re: FK relations hell : help with `_set` feature

2015-03-30 Thread Daniel Roseman
On Monday, 30 March 2015 13:04:00 UTC+1, François GUÉRIN wrote: > > Hi all, > > I'm using django for a couple of years, and I've a question about > relations in the ORM and templates. I massively use class-based generic > views. > > I' currently wor

FK relations hell : help with `_set` feature

2015-03-30 Thread François GUÉRIN
Hi all, I'm using django for a couple of years, and I've a question about relations in the ORM and templates. I massively use class-based generic views. I' currently working with a model which have many other models FKing to it : class People(models.Model): last_name = m

Possible bug in prefetch_related used with Reverse generic relations

2015-02-02 Thread Todor Velichkov
no attribute 'object_id' > *Why i think this may be a bug?* Because of the error. Normally if *prefech_related* can't resolve a relation it complains like that: AttributeError: Cannot find 'some_field' on TaggedItem object, 'some_field' > is an invalid pa

How to use natural keys when dumping/loading fixture data for models that use generic relations?

2014-10-02 Thread Stodge
> > "permissions": [], > > "public": false, > > "users": [] > > } > > } > > > I can't use this fixture as it's referencing an object ID. How do I use natural keys when dumping/loading fixtur

Querying across Generic Relations

2013-10-28 Thread Lee Hinde
I have a table, Credit, that I want to query based on a value several hops away. There's a CreditLineItems that has a Generic Foreign Key to one of two tables, each of which has a Foreign Key to the table I want to search. I've not as yet setup a reverse relation in the related tables. My question

Re: quick question: RE model relations

2013-09-02 Thread Andre Terra
How about posting both models.py from galleryview and event to something like https://gist.github.com/ ? Maybe we can work from there. Cheers, AT On Mon, Sep 2, 2013 at 2:07 PM, Bobby Roberts wrote: > i tried doing that and now get this error: > > Error: One or more models did not validate:

Re: quick question: RE model relations

2013-09-02 Thread Bobby Roberts
i tried doing that and now get this error: Error: One or more models did not validate: galleryview.galleryphoto: Accessor for field 'GalleryId' clashes with related field 'Gallery.Gallery_Id'. Add a related_name argument to the definition for 'GalleryId'. galleryview.galleryphoto: Reverse query

Re: quick question: RE model relations

2013-09-02 Thread Bobby Roberts
thanks for the info... yes the name is funny for the model isn't it? I try to write confusing code. Always test in production On Monday, September 2, 2013 12:24:41 PM UTC-4, Bobby Roberts wrote: > > I'm creating an event module and want people to be able to associate a > picture gallery with

Re: quick question: RE model relations

2013-09-02 Thread Andre Terra
As per the current docs[0], you need to provide a dotted path to your model in the form app.ModelName when defining a ForeignKey. So try this instead: GalleryId = models.ForeignKey('galleryview.Gallery', verbose_name=_('Gallery Id'), related_name='Gallery_Id',blank=True, null=True, help_text=_("Y

quick question: RE model relations

2013-09-02 Thread Bobby Roberts
I'm creating an event module and want people to be able to associate a picture gallery with the event: from django.utils.translation import get_language, ugettext, ugettext_lazy as _ from django.contrib import admin from django.db import models from django.contrib.auth.models import User from

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
Hi Tom, On Wednesday, June 12, 2013 10:25:24 AM UTC+2, Tomáš Ehrlich wrote: > > Hi Benjamin, > you can create explicit OneToOne field with parent_link=True > > https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.OneToOneField.parent_link > > > Then you can set different r

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Tomas Ehrlich
) Benjamin Wohlwend napsal(a): > Hi, > > I have a bit of a problem with inherited reverse relations and django model > inheritance. Consider these models: > > > class Content(models.Model): > display = models.BooleanField() > > > class Link(Content): > u

Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
Hi, I have a bit of a problem with inherited reverse relations and django model inheritance. Consider these models: class Content(models.Model): display = models.BooleanField() class Link(Content): url = models.URLField() class Teaser(Content): text = models.TextField

Re: Relations to unknown models?

2013-01-23 Thread jirka . vejrazka
@googlegroups.com Subject: Relations to unknown models? Hi. I'm looking for a solution to make site-wide comments that can be connected with different models via FK. I want to make 1 global model Comments. I want to make a relation to Articles, Relations and Solutions models. I the future I plan t

Relations to unknown models?

2013-01-23 Thread galgal
Hi. I'm looking for a solution to make site-wide comments that can be connected with different models via FK. I want to make 1 global model Comments. I want to make a relation to Articles, Relations and Solutions models. I the future I plan to add additional models. Now, Comments model s

Re: Required True to Generic Relations

2012-05-15 Thread Guevara
Solution: http://pastebin.com/011WsfzD Regards. On 15 maio, 23:43, Guevara wrote: > Hi all! > > I need a required true in Generic Relations. > Have this code: > > # Models > class Client(Person): >     addresses = GenericRelation(Address) > > class Address(model

Required True to Generic Relations

2012-05-15 Thread Guevara
Hi all! I need a required true in Generic Relations. Have this code: # Models class Client(Person): addresses = GenericRelation(Address) class Address(models.Model): # others fields content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField

Re: Question regarding Generic Foreign Keys and relations

2012-05-10 Thread David
Just an update, the following got me on the right track. http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web vi

Question regarding Generic Foreign Keys and relations

2012-05-08 Thread David
I am trying to abstract a log app that I have made for my project to make it more DRY. In order to achieve this I have tried to implement Generic FKs class Modification(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_obje

Re: Django help required with non foreign key relations

2012-04-23 Thread akaariai
On Apr 23, 8:15 am, Aditya Sriram M wrote: > Ohh this looks little promising.. > > However, > >    1. I need a few cols of table1 and few from table 2 to be displayed. How >    can we achieve that at the .filter() level? and >    2. At the view level like using the list_display () for displaying t

Re: Django help required with non foreign key relations

2012-04-22 Thread Aditya Sriram M
Ohh this looks little promising.. However, 1. I need a few cols of table1 and few from table 2 to be displayed. How can we achieve that at the .filter() level? and 2. At the view level like using the list_display () for displaying them in the Admin interface On Sunday, 22 April 2

Re: Django help required with non foreign key relations

2012-04-22 Thread akaariai
On Apr 22, 1:31 pm, Aditya Sriram M wrote: > File myapp/models.py has this sample code.. > > from django.db import models > > # model for 'user' table in database oracle_dbuser1:user > class User(models.Model): >     . . . >     customerid = models.BigIntegerField() > > # model for 'customer' tabl

Django help required with non foreign key relations

2012-04-22 Thread Aditya Sriram M
File myapp/models.py has this sample code.. from django.db import models # model for 'user' table in database oracle_dbuser1:user class User(models.Model): . . . customerid = models.BigIntegerField() # model for 'customer' table in database oracle_dbuser2:customer # Note that there is

Re: how to change column name in many2many relations?

2012-01-12 Thread Weldan
ing the model of the relation with a "through" > attribute. A little lenghty but effective... > > E. > > On Jan 12, 11:01 am, "?manu*" wrote: > > Is it possible to change the column name in many2many relations? > > > > I can change in in foreig

Re: how to change column name in many2many relations?

2012-01-12 Thread ?manu*
I have solved by defining the model of the relation with a "through" attribute. A little lenghty but effective... E. On Jan 12, 11:01 am, "?manu*" wrote: > Is it possible to change the column name in many2many relations? > > I can change in in foreignKeys with t

how to change column name in many2many relations?

2012-01-12 Thread ?manu*
Is it possible to change the column name in many2many relations? I can change in in foreignKeys with the db_column attribute. I can change the table name in many2many relations with db_table. What about column names in many2many relations? Thanks, E. -- You received this message because you

Re: Avoid m2m relations to be saved

2012-01-09 Thread Mario8k
ls.py def save(self, *args, **kwargs): print 'save()' return The m2m relations are also saved. This is a django bug? There any workaround? On 6 ene, 13:24, Mario8k wrote: > Hi, > > I need to prevent to save a model overriding the ModelAdminsave_model() > method.

Avoid m2m relations to be saved

2012-01-06 Thread Mario8k
() else: if change: #here i save another model but i never execute obj.save() How can I prevent to save m2m relations too? How I can achieve the original object not be changed? There is an old thread with the same issue: http://groups.google.com/group/django-users

Excel Import Generic Relations

2011-10-23 Thread stephenstubbs
using a get or create and so will create the foreign key if not found but only with the one field. We would like to do something similar for generic relations and manytomany fields before moving on to be able to import multiple tables at once. I'm thinking of possibly matching the object on a

Re: ORM only/defer calls do not work on cross-table relations

2011-09-27 Thread John
Works perfectly, thanks :) Tested with a join 4 levels deep too and it made just one query. I use select_related elsewhere for more generic optimizations but it hadn't occurred to me that django would need the hint once in conjunction with an only() call. Perhaps a patch to ensure that the appro

Re: ORM only/defer calls do not work on cross-table relations

2011-09-27 Thread Alasdair Nicol
Hi John, Use select_related [1] to tell Django to 'follow' the foreign key. Try the following: testmodels = models.ATestModel.objects.all().select_related('other').only('other__name') print testmodels[0].other.name Regards, Alasdair [1]: https://docs.djangoproject.com/en/dev/ref/models/qu

ORM only/defer calls do not work on cross-table relations

2011-09-27 Thread John
Hey, I'm trying to improve the performance of a Django app, and noticed that you can't seem to properly defer fields when making lookups with joins. To demonstrate, I set up a test project with the following models: class ATestModel(models.Model): other = models.ForeignKey('OtherModel') cla

Re: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat
> So you want to edit the User object through the ModelForm of the other model, > or you just want to display it? > I want to edit the User object through the ModelForm. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group

Re: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Ilian Iliev
So you want to edit the User object through the ModelForm of the other model, or you just want to display it? -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.org On Tue, Sep 20, 2011 at 4:37 PM, Jonas Geiregat wrote: > > > Hi, > > > > ModelFo

Re: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat
> Hi, > > ModelForm should automatically create a dropdown list for your foreign key. > If there is nor such drop-down created probably you are doing something wrong. > I don't want the dropdown list I want the values of the foreinkey to be expaneded into fields For example I have user as For

Re: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Ilian Iliev
Hi, ModelForm should automatically create a dropdown list for your foreign key. If there is nor such drop-down created probably you are doing something wrong. -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.org On Tue, Sep 20, 2011 at 1:26 PM,

Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat
Hello, I have a UserProfile model: class UserProfile(FacebookProfileModel): user = models.ForeignKey(User, unique=True) lastf

many to many in many relations

2011-09-12 Thread Nicklas
asp I would have nested iterations a and created a matrix of text boxes and built the insert statement from that. But I have a strong feeling that this has a much simpler solution using the philosophy of Django. Can I define ManyToMany relations to many tables like in this case? What is the right term

Re: How to use ManyToMany model relations to track user membership?

2011-09-09 Thread Darren
ease tell, what kind of relations is required to store > user's membership in multiple groups to be able to recover: > >    1. history of user participation in some groups (date joined, date > quit) >    2. list of current user groups (in join order) to determine his > current s

How to use ManyToMany model relations to track user membership?

2011-09-08 Thread jollyroger
Hi. Can someone please tell, what kind of relations is required to store user's membership in multiple groups to be able to recover: 1. history of user participation in some groups (date joined, date quit) 2. list of current user groups (in join order) to determine his current status

Problem with Many2Many relations and intra-model class save() method

2011-05-18 Thread Marc Suñé
Hi everyone, We are developing a webapp using Django. We have found a problem with m2m relations. I will Expose a simplified example of the problem; say we have 2 classes: class A(models.Model): name = models.CharField(max_length = 128, default="", blank = True,

Re: all data of all manyToMany relations lost!

2011-05-13 Thread ?manu*
> Dear experts, > > today I was inspecting the ManyToMany relations in the _meta subclass > of a Model class of my database. At some time I realized that all data > associated to such relations was lost in the database! The > corresponding tables are empty. Other fields and relat

all data of all manyToMany relations lost!

2011-05-13 Thread ?manu*
Dear experts, today I was inspecting the ManyToMany relations in the _meta subclass of a Model class of my database. At some time I realized that all data associated to such relations was lost in the database! The corresponding tables are empty. Other fields and relations are ok. I suspect I

Re: Unidirectional relations

2011-04-20 Thread Ian Clelland
On Tue, Apr 19, 2011 at 7:28 PM, Jacob Kaplan-Moss wrote: > 2011/4/19 Juan Pablo Romero Méndez : > > Is it possible to create unidirectional relations within django's orm? > > > > What I mean is a situation where a parent has a children_set of > > references to

Re: Unidirectional relations

2011-04-19 Thread Mike Dewhirst
I think you would need an intermediate table 1:n with the parent containing the child ids. Otherwise the children need a foreign key reference to the parent. On 20/04/2011, at 10:06 AM, Juan Pablo Romero Méndez wrote: > Hello, > > Is it possible to create unidirectional relatio

Re: Unidirectional relations

2011-04-19 Thread Jacob Kaplan-Moss
2011/4/19 Juan Pablo Romero Méndez : > Is it possible to create unidirectional relations within django's orm? > > What I mean is a situation where a parent has a children_set of > references to children, but the children don't have any reference to > the father.

Unidirectional relations

2011-04-19 Thread Juan Pablo Romero Méndez
Hello, Is it possible to create unidirectional relations within django's orm? What I mean is a situation where a parent has a children_set of references to children, but the children don't have any reference to the father. Regards, Juan Pablo -- You received this message becau

Re: Follow relations on three tables

2011-01-12 Thread gia...@gmail.com
On Tue, Jan 11, 2011 at 2:30 PM, Matias Aguirre wrote: > So, basically you want this: > > C.objects.filter(Bref__Dref__id=D_id).values_list('Aref') > Thanks! it was exactly what I needed -- Gianluca Sforna http://morefedora.blogspot.com http://identi.ca/giallu - http://twitter.com/giallu --

Re: Follow relations on three tables

2011-01-11 Thread Matias Aguirre
So, basically you want this: C.objects.filter(Bref__Dref__id=D_id).values_list('Aref') Matías Excerpts from gia...@gmail.com's message of Tue Jan 11 07:58:05 -0200 2011: > Let's say I have a model like: > > class A: > > class B: > Dref = ForeignKey('D') > > class C: > Aref = ForeignKey('A'

Follow relations on three tables

2011-01-11 Thread gia...@gmail.com
Let's say I have a model like: class A: class B: Dref = ForeignKey('D') class C: Aref = ForeignKey('A') Bref = ForeignKey('B') class D: I also have a view taking a D_id parameter and in this view I would like to create and show the list of A objects that are related to D through the B a

Re: Getting started with generic relations

2010-12-06 Thread mack the finger
fields will be handled by the generic relation API. On Dec 6, 4:34 am, bruno desthuilliers wrote: > On 5 déc, 20:30, mack the finger wrote: > > > I can't quite wrap my brain around how to do generic relations. I have > > a `Receipt` model which is a receipt of a purchase.

Re: Getting started with generic relations

2010-12-06 Thread bruno desthuilliers
On 5 déc, 20:30, mack the finger wrote: > I can't quite wrap my brain around how to do generic relations. I have > a `Receipt` model which is a receipt of a purchase. One of the fields > is `item` which is a foreign key to a product model. I want to be able > to not only have pr

Getting started with generic relations

2010-12-05 Thread mack the finger
I can't quite wrap my brain around how to do generic relations. I have a `Receipt` model which is a receipt of a purchase. One of the fields is `item` which is a foreign key to a product model. I want to be able to not only have products, but other things that the user can buy. What do I ne

Re: Generic relations

2010-11-18 Thread Jonas Geiregat
That was it! After running: ./manage.py sqlclear foo | ./manage.py dbshell && ./manage.py syncdb it works! So something in my db was inconsistent! Thanks! Op 18-nov-2010, om 09:57 heeft Marc Aymerich het volgende geschreven: > On Thu, Nov 18, 2010 at 12:00 AM, Jonas Geiregat wrote: >> >> Op

Re: Generic relations

2010-11-18 Thread Marc Aymerich
On Thu, Nov 18, 2010 at 12:00 AM, Jonas Geiregat wrote: > > Op 17-nov-2010, om 23:46 heeft Marc Aymerich het volgende geschreven: > > GenericPost.objects.get(pk=1).content_object.content > > > That's the strange thing. It just doesn't work: > > Some code: > > > In [3]: GenericPost.objects.get(

Re: Generic relations

2010-11-17 Thread Jonas Geiregat
Op 17-nov-2010, om 23:46 heeft Marc Aymerich het volgende geschreven: GenericPost.objects.get(pk=1).content_object.content That's the strange thing. It just doesn't work: Some code: In [3]: GenericPost.objects.get(pk=1).content_object In [4]: GenericPost.objects.get(pk=1).content_objec

Re: Generic relations

2010-11-17 Thread Marc Aymerich
On Wed, Nov 17, 2010 at 11:46 PM, Marc Aymerich wrote: > On Wed, Nov 17, 2010 at 11:36 PM, Jonas Geiregat wrote: >> Hello, >> >>  Can I use django's generic relations to create a model (GenericPost) that >> can point to other model (APost) or model (Rev

Re: Generic relations

2010-11-17 Thread Marc Aymerich
On Wed, Nov 17, 2010 at 11:36 PM, Jonas Geiregat wrote: > Hello, > >  Can I use django's generic relations to create a model (GenericPost) that > can point to other model (APost) or model (ReviewPost) ? >  And then use this GenericPost model to get a list of al

Generic relations

2010-11-17 Thread Jonas Geiregat
Hello, Can I use django's generic relations to create a model (GenericPost) that can point to other model (APost) or model (ReviewPost) ? And then use this GenericPost model to get a list of all latest APost's and ReviewPost's ? I've been trying this all day long but I

Re: Efficient updates on ManyToMany Relations

2010-10-18 Thread brix
With update I also meant adding a new author to the publications in the queryset. This (http://docs.djangoproject.com/en/dev/topics/db/ queries/#updating-multiple-objects-at-once) shows only how to update usual fields, but no m2m Relations as I understand it. I want to add objects. For

Re: Efficient updates on ManyToMany Relations

2010-10-18 Thread Marc Aymerich
On Mon, Oct 18, 2010 at 8:49 PM, Marc Aymerich wrote: > > > On Mon, Oct 18, 2010 at 6:31 PM, brix wrote: > >> Hello. >> >> Assume I have publications and authors. Like here: >> http://www.djangoproject.com/documentation/models/many_to_many/ >> >> Now I want to add authors to more than just one p

Re: Efficient updates on ManyToMany Relations

2010-10-18 Thread Marc Aymerich
On Mon, Oct 18, 2010 at 6:31 PM, brix wrote: > Hello. > > Assume I have publications and authors. Like here: > http://www.djangoproject.com/documentation/models/many_to_many/ > > Now I want to add authors to more than just one publication. Lets say > 1000 or more publications. > > Is there a more

Efficient updates on ManyToMany Relations

2010-10-18 Thread brix
Hello. Assume I have publications and authors. Like here: http://www.djangoproject.com/documentation/models/many_to_many/ Now I want to add authors to more than just one publication. Lets say 1000 or more publications. Is there a more efficient way of adding the authors once for each publication

  1   2   3   4   5   >