Filter GenericForeignKey by list of different model objects

2021-08-23 Thread Msw Tm
targetActor can be a User or a model Object""" actor_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, related_name="actor_type")actor_object_id = models.PositiveIntegerField()actor = GenericForeignKey('actor_content_

Re: I hope to increase OneToOne mode GenericForeignKey

2018-02-06 Thread Matemática A3K
On Mon, Feb 5, 2018 at 6:57 PM, Ma Mars <mars.jinx...@gmail.com> wrote: > I hope to increase OneToOne mode GenericForeignKey, > For example, a passport (one user has only one passport, but there are > many user roles, such as staff, drivers, customers, but they are one to on

I hope to increase OneToOne mode GenericForeignKey

2018-02-05 Thread Ma Mars
I hope to increase OneToOne mode GenericForeignKey, For example, a passport (one user has only one passport, but there are many user roles, such as staff, drivers, customers, but they are one to one) -- You received this message because you are subscribed to the Google Groups "Django

Re: Basic GenericForeignKey Question

2016-09-21 Thread TheBeardedTemplar
gt; > follows: > > > > class Permission(models.Model): > > """ > > This stores permissions for a single object. > > """ > > #These 3 fields are used to implement a generic foreign key > > co

Re: Basic GenericForeignKey Question

2016-09-21 Thread ludovic coues
y > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > model = GenericForeignKey() > > user = models.ForeignKey(User) > > #Permissions > read = models.BooleanField(default=False) > write = models.BooleanField(default

Basic GenericForeignKey Question

2016-09-21 Thread TheBeardedTemplar
; #These 3 fields are used to implement a generic foreign key content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() model = GenericForeignKey() user = models.ForeignKey(User) #Permissions read = models.BooleanField(default=False) write

Re: Possible Bug when using exclude on a GenericForeignKey / GenericRelation query.

2016-02-22 Thread Tim Graham
n error which I think might be a bug. I've yet > to try and replicate it as I thought posting here would be the better first > step, as I might just be doing something incorrectly. > > When I try a query with .exclude() on a table with a GenericForeignKey and > a reverse Generic

GenericForeignKey and Proxy Models

2015-10-13 Thread Fermin Arellano
I am using proxy models (Student, Teacher, Parent) from a base class Person. I also have a class called BoardMember which uses the content type framework. In Boardmember I declared a GenericForeignKey(content_type, object_id, for_concrete_model=False). In my proxy model (Teacher) I declared

Possible Bug when using exclude on a GenericForeignKey / GenericRelation query.

2015-08-14 Thread Daniel H
incorrectly. When I try a query with .exclude() on a table with a GenericForeignKey and a reverse Generic Relation on a different table, I get this: AttributeError at /list 'GenericRelation' object has no attribute 'field' Here is a mock up of my database structure: class InternalOffer(models.Model

Re: Allow the Prefetch queryset to be used with GenericForeignKey

2014-03-30 Thread Luis Matoso
That would be awesome, somebody has a solution for this? On Sunday, February 16, 2014 2:53:55 PM UTC-3, Robert Kajic wrote: > > I would love it if the Prefetch object allowed me to pass in custom > querysets when prefetching related generic foreign fields. Specifically I > want this in order to

Allow the Prefetch queryset to be used with GenericForeignKey

2014-02-16 Thread Robert Kajic
I would love it if the Prefetch object allowed me to pass in custom querysets when prefetching related generic foreign fields. Specifically I want this in order to call select_related on each subgroup. For now I've subclassed the GenericForiengKey class, overriding get_prefetch_queryset, to

Setting a GenericForeignKey results to a FieldNotFoundError

2012-06-10 Thread Salvatore Iovene
suppose there's some magic to the GenericForeignKey that I didn't understand. This is the code for the ReviewedItem model: https://github.com/danawoodman/django-reviews/blob/master/reviews/models.py#L63 Can anyone tell me how to properly update an instance so it refers to a different

Re: Why on_delete attribute is not available on GenericForeignKey?

2012-03-07 Thread akaariai
On Mar 7, 11:40 pm, Marc Aymerich wrote: > On Wed, Mar 7, 2012 at 9:13 PM, akaariai wrote: > > I believe the reason is efficiency. If there were an on_delete > > argument for GFKs every object deletion of any class would need to do > > a query to check if

Re: Why on_delete attribute is not available on GenericForeignKey?

2012-03-07 Thread Marc Aymerich
On Wed, Mar 7, 2012 at 9:13 PM, akaariai wrote: > I believe the reason is efficiency. If there were an on_delete > argument for GFKs every object deletion of any class would need to do > a query to check if there happens to be any GFK related objects. In > addition, Django

Re: Why on_delete attribute is not available on GenericForeignKey?

2012-03-07 Thread akaariai
it is possible an insert could be made which is not visible to the deletion code. - Anssi On Mar 7, 3:50 pm, Marc Aymerich <glicer...@gmail.com> wrote: > The django docs says: > Unlike ForeignKey, GenericForeignKey does not accept an on_delete > argument to customize this behavior;

Why on_delete attribute is not available on GenericForeignKey?

2012-03-07 Thread Marc Aymerich
The django docs says: Unlike ForeignKey, GenericForeignKey does not accept an on_delete argument to customize this behavior; if desired, you can avoid the cascade-deletion simply by not using GenericRelation, and alternate behavior can be provided via the pre_delete signal. Does anyone knows why

Re: django 1.4 orm standalone - GenericForeignKey

2012-01-27 Thread Vaal
think I found a solution, but need to check[code]settings.configure(    DATABASES={        'default': {            'ENGINE': 'django.db.backends.sqlite3',            'NAME': 'db.sqlite',        }    },    INSTALLED_APPS=(    'django.contrib.contenttypes',))[/ code] -- You received this message

django 1.4 orm standalone - GenericForeignKey

2012-01-27 Thread Vaal
Hi! In version 1.3 I have no problem using GenericForeignKey in standalone scripts with Django ORm and GenericForeignKey. And in 1.4 there is a problem. http://dpaste.com/694017/ (virtualenv) C:\Users\user\Desktop\django-test>python django14.py Traceback (most recent call last): File "

django GenericForeignkey does not work with object.create() but work fine with save()

2011-11-14 Thread Avni Mahajan
= generic.GenericForeignKey('reference_type', 'reference_id') When I am creating an entry by using below snippet I face a problem that GenericForeignKey field "reference" does not get updated. Rest every value is perfectly fine. >> c = Customdata.objects.create(call_uuid=session_

Re: admin search - lookup following GenericForeignKey

2011-06-28 Thread Michal Petrucha
> I have a model X with Y field which is GenericForeignKey field. In the > model admin for model X I want to have something like: > search_fields('Y__fieldname'). I get the error 'Cannot resolve keyword > "X" into field' which makes sense since it's a virtual field and >

admin search - lookup following GenericForeignKey

2011-06-28 Thread virtuallight
I have a model X with Y field which is GenericForeignKey field. In the model admin for model X I want to have something like: search_fields('Y__fieldname'). I get the error 'Cannot resolve keyword "X" into field' which makes sense since it's a virtual field and doesn't go to fields in X.

Re: order_with_respect_to fails for GenericForeignKey

2010-05-17 Thread Russell Keith-Magee
2010/5/17 Alper Çuğun : > Hello, > > A quick Google search reveals a ton of confusion about: > Meta: order_with_respect_to > > I have an abbreviated Model: > > class NewsItem(models.Model): >    # newsitems will be linked to blogs and projects >    content_type =

order_with_respect_to fails for GenericForeignKey

2010-05-17 Thread Alper Çuğun
Hello, A quick Google search reveals a ton of confusion about: Meta: order_with_respect_to I have an abbreviated Model: class NewsItem(models.Model): # newsitems will be linked to blogs and projects content_type = models.ForeignKey(ContentType) object_id =

Re: GenericForeignKey with content_type in a related model ???

2009-11-06 Thread bruno desthuilliers
On 6 nov, 03:49, Jesse Legg <jesse.l...@gmail.com> wrote: > You won't be able to use a GenericForeignKey in this situation, Yeps, I know - I even explained why > but > you could write a helper method and define a property to affect > something similar. Which is mostly

Re: GenericForeignKey with content_type in a related model ???

2009-11-06 Thread bruno desthuilliers
On 5 nov, 23:46, Brian McKeever wrote: > Why do you want to split it across two models? I don't *want* to - the first model comes from an existing app, and duplicating the content_type in my own model would be, well, a duplication !-)

Re: GenericForeignKey with content_type in a related model ???

2009-11-05 Thread Jesse Legg
You won't be able to use a GenericForeignKey in this situation, but you could write a helper method and define a property to affect something similar. For example: class ModelTwo(models): model_one = models.ForeignKey(ModelOne) object_id = models.PositiveIntegerField() def

Re: GenericForeignKey with content_type in a related model ???

2009-11-05 Thread Brian McKeever
elTwo(models): >     model_one = models.ForeignKey(ModelOne) >     object_id = models.PositiveIntegerField() > > And I'd like to have a 'content_object' GenericForeignKey (or anything > with a close enough behaviour) in ModelTwo. From a quick glance at the > implementation of GenericForeig

Nullable GenericForeignKey?

2009-10-07 Thread ringemup
When I try to set null=True on a GenericForeignKey field, I get a TypeError: __init__() got an unexpected keyword argument 'null'. Does this mean that GenericForeignKeys can't be null, or does it mean that their nullability is automatically determined by the nullability of their content_type

GenericForeignKey and unique

2009-10-05 Thread Emiliano Heyns
Hi, I have a model class Document that I want to tie to several other model classes (Issue, Task, Project, ...) in a way that a document ties to exactly zero or one instance of the other model classes. Easiest would be to add a GenericForeignKey with a unique constraint, but the Document model

Re: GenericForeignKey and GenericRelation problems

2009-09-17 Thread Dennis Schmidt
Just to close this: the problem were the fixtures. The contract fixtures are defining the generic relations by the actual IDs of the ContentType, so they had to adopted after adding new models. On 16 Sep., 17:00, Dennis Schmidt wrote: > Hi there, > > I've got a

GenericForeignKey and GenericRelation problems

2009-09-16 Thread Dennis Schmidt
Hi there, I've got a very strange problem and I hope somebody can help me somehow. I think I can reduce the problem to basically these aspects: I've got an abstract base class called Account. It has got several (nonabstract) subclasses, eg MailAccount. Then I have a class called Contract. Each

Show related inlines in the admin on form of model with GenericForeignKey

2009-07-21 Thread ramu...@gmail.com
f/contrib/admin/#using-generic-relations-as-an-inline. Can anyone suggest how have related Products inline on the admin form of an Image model? Copy from here: http://stackoverflow.com/questions/1160174/show-related-inlines-in-the-admin-on-form-of-model-with-genericforeignkey --~--~-~--~~---

ForeignKey within GenericForeignKey

2009-07-01 Thread PiGGeH
I'm pretty sure its not necessarily meant to work like this, however one way it does, the other it doesnt. I have the following (cut down slightly, but the important stuff is here) # image/models.py class Image(models.Model): type = models.ForeignKey('image.Type') object_id =

Re: Object filtering with a GenericForeignKey field

2009-04-10 Thread Malcolm Tredinnick
On Fri, 2009-04-10 at 16:04 -0700, M Godshall wrote: > I have two models, Comment and Project. Comments are connected to a > Project through a GenericForeignKey, and each Project is assigned to a > particular user. I'd like to retrieve the latest comments for all the &

Object filtering with a GenericForeignKey field

2009-04-10 Thread M Godshall
I have two models, Comment and Project. Comments are connected to a Project through a GenericForeignKey, and each Project is assigned to a particular user. I'd like to retrieve the latest comments for all the projects that a particular user is assigned to, but according to the Django

Re: I'm having some trouble with GenericForeignKey

2009-03-20 Thread Brian McKeever
Thank you. I appreciate the quick response. --~--~-~--~~~---~--~~ 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 unsubscribe from this group,

Re: I'm having some trouble with GenericForeignKey

2009-03-20 Thread Alex Gaynor
On Fri, Mar 20, 2009 at 6:28 PM, Brian McKeever wrote: > > What am I doing wrong? > Is there any other way to do what I want? > I'm basically trying to implement the GOF's strategy design pattern > (the real code is more complicated than this example). > > ## my models > class

I'm having some trouble with GenericForeignKey

2009-03-20 Thread Brian McKeever
What am I doing wrong? Is there any other way to do what I want? I'm basically trying to implement the GOF's strategy design pattern (the real code is more complicated than this example). ## my models class Donkey(models.Model): name = models.CharField(max_length=11) class Barn(

Re: zyons GenericForeignKey

2007-06-26 Thread Jay Parlar
On 6/26/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > didn't grep enough: > > django/contrib/contenttypes/generic.py: > class GenericForeignKey() > > How do I 'use' generic.py ? Just change the import. There was a backwards incompatible change made to Generic keys r

zyons GenericForeignKey

2007-06-26 Thread Carl Karsten
'GenericForeignKey' zilbo.common.event: 'module' object has no attribute 'GenericForeignKey' zilbo.common.counter: 'module' object has no attribute 'GenericForeignKey' zilbo.common.forum: 'module' object has no attribute 'GenericForeignKey' zilbo.common.tag: 'module' object has no attribute 'GenericForeignKey

ordering and GenericForeignKey

2007-04-17 Thread xav4django
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I use the ordering in admin interface. My sample class with GenericForeignKey class MyClass(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object

Problems with GenericForeignKey and ForeignKey

2007-03-18 Thread mrstone
I have sticky bug I can not figure out how to solve. On the dev server it works fine, but moving to mod_python... I'm running a query and it throws an exception, but if I reload the page it works fine. the model has this structure: class InfoProxy(models.Model): info_type =

Re: GenericForeignKey

2006-12-18 Thread zenx
Now it is!! http://net-x.org/media/GenericRelation-0.1.zip Rob Slotboom ha escrito: > > paulh, take a look at > > thishttp://net-x.org/weblog/2006/nov/29/django-generic-relations-made-eas... > > Hi Antoni, > > Seems interesting but the code isn't yet available I suppose... > > Rob

Re: GenericForeignKey

2006-12-15 Thread Rob Slotboom
> paulh, take a look at > thishttp://net-x.org/weblog/2006/nov/29/django-generic-relations-made-eas... Hi Antoni, Seems interesting but the code isn't yet available I suppose... Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: GenericForeignKey

2006-12-15 Thread zenx
paulh, take a look at this http://net-x.org/weblog/2006/nov/29/django-generic-relations-made-easier/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: GenericForeignKey

2006-12-06 Thread Jacob Kaplan-Moss
On 12/6/06 6:32 AM, paulh wrote: > Using a GenericForeignKey everything seems to work until you try to use > fields in an Admin class. That's right - generic relations don't (yet) have the necessary code for admin interfaces. It'll happen eventually, but for now, sorry!

GenericForeignKey

2006-12-06 Thread paulh
Using a GenericForeignKey everything seems to work until you try to use fields in an Admin class. The you get an error like this: FieldDoesNotExist at /modp/admin/tst2/comnam/add/ Comnam has no field named 'com_obj' and a python dump. Just updated by copy of django with the latest dev version

How to preload all object fields for a QuerySet? (GenericForeignKey and select_related())

2006-11-29 Thread Ed
, but not GenericForeignKey. Another problem is that I find if I create a OneToOneField link to the default django.contrib.auth.User model (from my Account model), everytime I access request.user.account it is hitting the db to select the account record. How to avoid this/cache this. Thanks for any input

Re: usage of GenericForeignKey ?

2006-08-07 Thread Ian Holsman
hi Dirk.you still need to put in the content-type & object-idregardsIan.On 08/08/2006, at 6:40 AM, [EMAIL PROTECTED] wrote:Hi,I have the following model defined:from django.db import modelsclass MyTest(models.Model):        obj = models.GenericForeignKey()if I let print the SQL-Create-Statements

usage of GenericForeignKey ?

2006-08-07 Thread dummy
Hi, I have the following model defined: from django.db import models class MyTest(models.Model): obj = models.GenericForeignKey() if I let print the SQL-Create-Statements for mysql-DB I get this: BEGIN; CREATE TABLE `test_mytest` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY

Re: GenericForeignKey in admin

2006-06-23 Thread Jacob Kaplan-Moss
On Jun 22, 2006, at 2:00 PM, Jay Parlar wrote: > I noticed you just checked the patch in, thanks very much. I do have > the question though: Was the patch actually doing the overall right > thing? My patch modified the admin itself, instead of any of your > generic stuff. > > Maybe because of the

Re: GenericForeignKey in admin

2006-06-22 Thread Jay Parlar
On 6/22/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > Yeah, that's right -- there's currently no admin support. It'll get > there eventually; I just wanted the core code to get some eyeballs > before trying to write it into the admin. > > (Thanks for the pointer to the bug, Jay, I'd

Re: GenericForeignKey in admin

2006-06-22 Thread Jacob Kaplan-Moss
On Jun 22, 2006, at 10:24 AM, Jay Parlar wrote: > On 6/22/06, arthur debert <[EMAIL PROTECTED]> wrote: >> I've been playig with GenericForeignKey and they are great. > > I don't think any explicit work has been done yet to support the new > generic stuff in the Admin. T

Re: GenericForeignKey in admin

2006-06-22 Thread Jay Parlar
On 6/22/06, arthur debert <[EMAIL PROTECTED]> wrote: > > I've been playig with GenericForeignKey and they are great. > > One question though, they do not show up on the admin app. > > For example on the object that should be 'tagged', I would like to edit > tags inlin

GenericForeignKey in admin

2006-06-22 Thread arthur debert
I've been playig with GenericForeignKey and they are great. One question though, they do not show up on the admin app. For example on the object that should be 'tagged', I would like to edit tags inline. Is thart possible at all? thanks, arthur