generic-relations

Help with understanding generic relations in Django (and usage in Admin)

I'm building a CMS for my company's website (I've looked at the existing Django solutions and want something that's much slimmer/simpler, and that handles our situation specifically.. Plus, I'd like to learn this stuff better). I'm having trouble wrapping my head around generic relations. I have a Page model, a SoftwareModule model, an...

Why can't I save my model with a generic relation twice in Django?

I got a model TrackedItem with a generic relation linking to any model it is supposed to track. If I do that: t = TrackedItem(content_object=MyModel) t.save() t.save() I get : IntegrityError: (1062, "Duplicate entry '1' for key 'PRIMARY'") Indeed, the first save has created an entry with "1" as a PK. But the second save should not...

Django model attribute to refer to arbitrary model instance

I'm working on a logging app in Django to record when models in other apps are created, changed, or deleted. All I really need to record is the user who did it, a timestamp, a type of action, and the item that was changed. The user, timestamp, and action type are all easy, but I'm not sure what a good way to store the affected item is be...

[Fun riddle] Any clue on this error with generic relation using Django Orm?

This is a fun one :-) Working on an EAV, we inject a generic relationship handler at runtime in a model. model_cls is any class, and a EavValue class have a generic relation pointing to it. It works fine from EavValues to a model_cls, but on the other way we need to inject an accessor to ease things: generic_relation = generic.Generic...

In Django how to create references to different models & being agnostic about what model it is?

I am relatively new to Django/Pinax & I am faced with this peculiar situation. Say I have a model "Vehicle". Now each instance of "Vehicle" has some attributes pertaining to the "vehicle" but it also has a reference to instance of one of automobiles class, where "automobiles" can be one of the many models like "car", "boat", "plane" etc...