django model inheritance & FK, could not create unique index -


i want able have foreign key parent class, thereby allowing queries of children classes well. other solutions nightmarish. have tried make (destination parent class has # of children classes want relate to):

class destination(polymorphicmodel)  class account(destination)  class organization(destination)  class person(destination)  class transaction(models.model)     destination = models.foreignkey(destination, verbose_name="destination", null=true, blank=true,                                 related_name="completedtransaction_destination_fk") 

i referencing destination in other places well. error message when try migrate:

psycopg2.integrityerror: not create unique index "baseapp_organization_organization_destination_ptr_id_key" detail: key (organization_destination_ptr_id)=(1) duplicated.

i love if make destination class

abstract = true 

but can't have foreign key. need able choose of destinations, , need remain distinct, real models in database.

i have tried genericrelations, proved nightmare said earlier.

it feels around error somehow though, help?

the solution, , i'm guessing apply other errors index not created, wipe database delete migrations. pain sure, can do:

destinations = destination.objects.all() 

and give me objects, according django polymorphic


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -