Custom ForeignKey which does not require referential integrity?

148 views
Skip to first unread message

diabeteman

unread,
May 27, 2012, 6:51:26 PM5/27/12
to django-d...@googlegroups.com
Hello everyone,


I have a Django project that has multiple django "apps". One of them has models to represent data coming from an external source (I do not control this data).
I want my other apps to be able to have references to this "external app" but I want to avoid all the fuzz of the database integrity checks. I don't want the db to have any constraints on these "soft foreign keys".
Do you know how I can code a custom field that will emulate a real Django ForeignKey without creating a hard constraint on the database?
Maybe this already exists, but I didn't have any luck on Google.
Thanks in advance for the help :-)
NB: I'm aware of the generic relations system with the content_types. But I don't want generic relations. I want specific relations to identified models only without hard integrity constraints.
EDIT:
I found related links:
But I didn't find a proper answer to my question. :(

But I didn't get any luck. 

I've looked deep into django's code to find what needs to be done, but I think that simply subclassing ForeignKey will not be enough. Could you give me some directions on how to do this?

NB: I use South for managing my database schema, so I figure I'll need to do something about that too. But it may be out of the subject here :)

Thanks in advance for the help!

Robin

Karen Tracey

unread,
May 27, 2012, 8:00:47 PM5/27/12
to django-d...@googlegroups.com
Please do not crosspost to both django-users and django-developers. Pick the right list and post there. This seems to be more appropriate for discussion on django-users than here.

Karen

diabeteman

unread,
May 29, 2012, 9:21:09 AM5/29/12
to django-d...@googlegroups.com
Sorry about that, 

I posted first on django-users and then I thought that it was a bit too low level for such a question.

I hope I'll get some help :-)

Javier Guerra Giraldez

unread,
May 29, 2012, 10:07:27 AM5/29/12
to django-d...@googlegroups.com
On Tue, May 29, 2012 at 8:21 AM, diabeteman <diabe...@gmail.com> wrote:
> I posted first on django-users and then I thought that it was a bit too low
> level for such a question.

Django-devs is _not_ a "Django support, level 2" list. :-)

--
Javier
Reply all
Reply to author
Forward
0 new messages