i have existing table created by FDW (Foreign data wrappers 
<https://wiki.postgresql.org/wiki/Foreign_data_wrappers>)  named 
'stateagency_stateagency'.

two models

class StateAgency(models.Model): 
    id = models.AutoField(primary_key=True) 
    name = models.CharField(max_length=100) 
        class Meta: 
                managed = False



class Document(models.Model): 
    id = models.UUIDField(primary_key=True, editable=False, default=uuid.
uuid1)  
    stagcy = models.ForeignKey(StateAgency, to_field='id')


ti set managed = False
if i run command: *python manage.py sqlall*, i give that DDL:

CREATE TABLE "statements_document" (
    "id" uuid NOT NULL PRIMARY KEY,
    "stagcy_id" integer NOT NULL);

*"stagcy_id" integer* this not foreign key *it very important*
but when i run python manage.py sqlmigrate statements 0001

CREATE TABLE "statements_document" (
    "id" UUID NOT NULL PRIMARY KEY);
-- omitted other sql --ALTER TABLE "statements_document" ADD CONSTRAINT 
"statem_stagcy_id_fk_stateagency_stateagency_id" FOREIGN KEY ("stagcy_id") 
REFERENCES "stateagency_stateagency" ("id") DEFERRABLE INITIALLY DEFERRED;

*NOTE:*
django use *FOREIGN KEY* and when i run *python manage.py migrate* i catch 
exception, but table already exists

django.db.utils.ProgrammingError: referenced relation "stateagency_stateagency" 
is not a table


why it have this behavior?
how i can create migration without giving a reference, or by indicating '
stateagency_stateagency' table.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c0ce62e0-9de2-43aa-8e80-cb18c34d2b3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to