python - Foreign key needs a value from the key's table to match a column in another table -


Forget the excessive amount of code, but I'm not sure I can explain my question otherwise. >

I have a Django project on which I do the following:

  class projects (models.model): name = models.CharField (max_length = 100, unique = True) Dir = model.carfield (max_long = 300, empty = true, exclusive = true) def __unicode __ (self): back self Name; Class ASCLASS (model.model): name = model.carfield (max_length = 100) project = model. Phoenis (project, default = 1) def __unicode __ (self): return self. Name; Class entry (models.Model): project = model. Fourhenki (project, default = 1) esclasses = model. There is a question here:  

There is no such way, to save the saved function of the model without override, so that the entries are only for those Allow classes that have the same project ID?

************ **************************************************************************** **************************************************************************************************** ***** Edit it ** ***************************************** ********** ******
To be clear, I do not oppose overriding service. I really do not already listed above for an override property in this case, I already know how to override the answer to this question, therefore simply saying, "You can override to save Are "will not be helpful.

I am thinking that if there is no better way to complete it, if any of the denganos are the basic implementation, and if the key type is already present.

********************************************************************************** ******************* ********************************************************************************* **************************************************************************************************** ********************** Edit it ************************** ******************** Is this a way to do this in postgrascape?

(For the best solution, here is the code to create tables in PostGrace). This has created the following tables:

  create table blogsas (id serial not neil , "Name" character is separated (100) No tap, project_id is not an integer, correct blog_asclass_pkey primary key (id), contract blog_asclass_project_id_fkey foreign key (project_id) Reference blog_project (id) delete any action simple on the update Do not do any work on the go. Blog_entry (not ID serial, not project_id integer, build_date timestamp with time zone, constant blog_entry_pkey primary key (id), contract blog_entry_project_id_fkey foreign key (project_id) reference blog_project No action on randomization (id) mailup update, no action randomly defined) Tablet blog_entry_asclasses (ID stream Constructant blog_entry_asclasses_pkey Primary key (contract), contract blog_entry_asclasses_asclass_id_fkey foreign key (eslace_id) reference blog_example (id) Define randomly irregular actions, contract blog_entry_asclasses_entry_id_fkey foreign key (not defined), non-public, zero, entry_id integer, zero, asclass_id No action taken when the blog_antry (id) match update removal on references Action random randomly, contract blog_entry_asclasses_entry_id_key unique (Entry_ID, eslace_id) Make Blog tab (blog), id serial not null, "name" character is different (100) No tap, det of dir character (300), tap, contract Blog_project_pkey Primary key (id), contract blog_project_dir_key unique (dir), concert blog_project_name_key unique (name))    

You can pre_save The signal can be used and can increase error if they do not match ... to save the effect will be like override (it is said before saving)

The problem is causing / To avoid updating many / many-to-many relationships will not trigger (or, consequently, pre_save or post_save )

Update

This helps you manually with M2A Define the intermediary table for the relation, which will give you access to the signals along with the tasks.

Then you can select the signal or overloading as you please


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -