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_
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,
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
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
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
;
#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
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
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
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
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
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
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
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
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
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;
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
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
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 "
= 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_
> 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
>
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.
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 =
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 =
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
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 !-)
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
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
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
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
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
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
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
--~--~-~--~~---
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 =
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
&
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
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,
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
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(
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
'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
-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
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 =
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
> 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
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
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!
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
, 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
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
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
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
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
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
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
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
55 matches
Mail list logo