Re: Generic Foreign Key

2016-07-21 Thread 'David Turner' via Django users
dels can link to notes or counties and > > not both, simple foreign key are fine." > > > > > > On 21 July 2016 at 11:13, ludovic coues wrote: > >> > >> Generic Foreign Key solve a very specific problem. Foreign key to > >> arbitrary models. Li

Re: Generic Foreign Key

2016-07-21 Thread ludovic coues
ally if I am using the county Foreign key in a few different models > I am fine. I am not sure what you meant by this > "as long as no models can link to notes or counties and > not both, simple foreign key are fine." > > > On 21 July 2016 at 11:13, ludovic coues wrot

Re: Generic Foreign Key

2016-07-21 Thread 'David Turner' via Django users
ues wrote: > Generic Foreign Key solve a very specific problem. Foreign key to > arbitrary models. Like a tagging system, with the ability to set a tag > to user, article, comment, media in a blog. > > For your use, as long as no models can link to notes or counties and > not both, simple

Re: Generic Foreign Key

2016-07-21 Thread ludovic coues
Generic Foreign Key solve a very specific problem. Foreign key to arbitrary models. Like a tagging system, with the ability to set a tag to user, article, comment, media in a blog. For your use, as long as no models can link to notes or counties and not both, simple foreign key are fine. And even

Generic Foreign Key

2016-07-21 Thread 'dtdave' via Django users
I have two models notes and counties which are used across multiple models. At the moment the realtionship is done using a foreign key. I am getting conflicting advice on whether to use a Generic Foreign Key. Could someone please enlighen me as to the best practice? Many thanks in advance

Re: Should I use generic foreign key, and how?

2014-08-17 Thread Amirouche Boubekki
2014-08-17 11:24 GMT+02:00 Vladimir Chukharev : > > > On Saturday, August 16, 2014 10:46:33 PM UTC+3, Aaron Law wrote: >> >> >> Hi all, >> >> I have php web programming background, and new to Django. I am helping my >> brother to build an online system to manage inventory, and I've got a >> datab

Re: Should I use generic foreign key, and how?

2014-08-17 Thread Vladimir Chukharev
On Saturday, August 16, 2014 10:46:33 PM UTC+3, Aaron Law wrote: > > > Hi all, > > I have php web programming background, and new to Django. I am helping my > brother to build an online system to manage inventory, and I've got a > database design & coding problem recently. Needing help! > > Tha

Re: Should I use generic foreign key, and how?

2014-08-17 Thread Amirouche Boubekki
2014-08-16 21:45 GMT+02:00 Aaron Law : > > Hi all, > > I have php web programming background, and new to Django. I am helping my > brother to build an online system to manage inventory, and I've got a > database design & coding problem recently. Needing help! > > That is, I have a set of tables of

Re: Should I use generic foreign key, and how?

2014-08-17 Thread Davide Scatto
another way is not to use fk but generic field, where patent_id is a normal integer field. In a custom manager you have to manage the data content in this field with data content in table field to retrieve yr linked record. Il giorno sabato 16 agosto 2014 21:46:33 UTC+2, Aaron Law ha scritto: >

Re: Should I use generic foreign key, and how?

2014-08-16 Thread Collin Anderson
I think there really are two ways to do it, as you say. Either use a GenericForeignKey(), or have multiple ForeignKey(null=True, blank=True), each one pointing to a different model. I personally use the multiple foreign keys approach, but this is the case that GenericForeignKey was designed for

Should I use generic foreign key, and how?

2014-08-16 Thread Aaron Law
Hi all, I have php web programming background, and new to Django. I am helping my brother to build an online system to manage inventory, and I've got a database design & coding problem recently. Needing help! That is, I have a set of tables of "possible products", "inventory", "suppiler", etc. I

Re: ordering by generic foreign key

2012-10-19 Thread Bastian
to' object and so the 'filter(likes__user=user)' part must iterate through them in a way. Anyway it works. Cheers, Bastian On Thursday, October 18, 2012 6:46:14 PM UTC+2, Bastian wrote: > > Hi, I'm not sure to understand what I'm doing here :) I have a model of a > ph

ordering by generic foreign key

2012-10-18 Thread Bastian
Hi, I'm not sure to understand what I'm doing here :) I have a model of a photo with name, description, image field... and a generic foreign key called 'likes' to store the photo in users' favorites: likes = generic.GenericRelation(Like) and in the Like model I have:

Re: Custom Validation on Inline Generic Foreign Key

2011-08-31 Thread John
I went ahead and hardcoded checks for fields that as of today I know will only be in one of the models. I would still love to hear any cleaner solutions if anyone has them. On Aug 26, 10:12 am, John wrote: > Any ideas? > > In the inline model's validation I could hardcode checks for data that > I

Re: Custom Validation on Inline Generic Foreign Key

2011-08-26 Thread John
Any ideas? In the inline model's validation I could hardcode checks for data that I expect will only be in one of the models, but that does not seem like the best option. I am still hoping for a simpler alternative to this. Thanks. -- You received this message because you are subscribed to the

Custom Validation on Inline Generic Foreign Key

2011-08-23 Thread John
Hi there, I am writing an app with Django where I have a model with a generic foreign key. I am looking to do some validation on this model based on the content_type of the generic foreign key. When I am modifying this model on its admin page, I am able to easily determine the content_type

Legacy database, many-to-many field, custom column name and generic foreign key

2008-05-31 Thread MiloZ
Hi, Here's the problem: class AssociationClass(models.Model): fk_model1 = models.IntegerField() fk_model2 = models.IntegerField() model2_type = models.IntegerField() after an inspectdb, I would like to tell django that this is an association class, with a generic foreign key.