Just starting out with Django here...

In an existing database whose existing table-structure must remain
unchanged by django, I have several cases of what looks like a
OneToOne, for instance:

The table/class org has a field region which points to the id on the
table/class region (dump from postgres):

CREATE TABLE org (
  ..
  region integer,
  ..
);

CREATE TABLE region (
  id integer NOT NULL,
  region character varying(32) NOT NULL,    -- county, state
  location character varying(32) NOT NULL  -- location within region
);

ALTER TABLE ONLY org
  ADD CONSTRAINT "$5" FOREIGN KEY (region) REFERENCES region(id);

Each org only has a single region, and in the old web-interface the
region-data is shown as a drop-down-list (<select>) where you can
choose one and only one. So: org.region == region.id, there can be
many orgs in a region but only one region per org.

Basically, tables like "region" act as helpers for the "real" tables
like "org", by limiting what region can be filled out for the org. The
"region"-table is basically readonly, as the only way to change
anything in it is to do so manually, with the right privileges,
directly with sql-commands.

This looks like a OneToOne to me, but OneToOnes are not to be used, so
what to do instead?

(Oh, and having a way to make a model inherit from another (single
inheritance is fine) would be swell. The obvious way didn't work.)


HM

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to