Hello,
I have used legacy database docs to use django with database produced by
gnuenterprise http://www.gnuenterprise.org application server.
As gnue-appserver requires to use gnue_id field as primary key (32-char
long UUID) I then manually modified the model to something like this:
from django.core import meta
class Gnue(meta.Model):
gnue_id = meta.CharField(maxlength=32, primary_key=True)
gnue_createdate = meta.DateTimeField()
gnue_createuser = meta.CharField(maxlength=8)
gnue_modifydate = meta.DateTimeField()
gnue_modifyuser = meta.CharField(maxlength=8)
def _pre_save(self):
#Check if gnue_id is set and provide custom one if needed
#Provide user and timestamp
import datetime
if not self.gnue_id:
from gnue.common.utils.uuid import UUID
self.gnue_id = "'%s'" % UUID.generateTimeBased()
if not self.gnue_createdate:
self.gnue_createdate = datetime.datetime.now()
self.gnue_createuser = 'ds'
self.gnue_modifydate = datetime.datetime.now()
self.gnue_modifyuser = 'ds'
And then real classes like this:
class Person(Gnue):
person_first = meta.CharField(maxlength=35)
person_middle = meta.CharField(maxlength=35)
...
All this works fine.
Now I want to extend this model with django many-to-many model. For
example that would be web_link and web_tag classes ( class names are
prefixed here). For that django will do db table like this:
CREATE TABLE "web_link_web_tags" (
"id" serial NOT NULL PRIMARY KEY,
"weblink_id" varchar(32) NOT NULL REFERENCES "web_link" ("gnue_id"),
"tag_id" integer NOT NULL REFERENCES "tagging_tags" ("gnue_id"),
UNIQUE ("weblink_id", "tag_id")
);
The question is this:
How and where "id" primary key is used in django internals for this
many-to-many model?
Is it worth to try (and possible) get "gnue_id" (properly generated as
gnue asks) as primary key in this table instead of integer "id" if i
would like to keep 2-way compatibility?
Probably what I want is some mapping engine instead of one-way inspectdb
tool but anyway I'm glad as it works already, so thanks to django
developers.
Using gnue-appserver as external object store via api or xmlrpc is
another story...
Thanks in advance,
Dmitry Sorokin aka dimas
P.S. Sorry for previous message - hit a wrong button.