python - CharField being shown as IntegerField in Database -
we're making film database application , using django 1.7 , postgresql.
here's our models.py
file looks like:
class movies(models.model): name = models.charfield(max_length=50) lang = models.foreignkey(language, null=true) genre = models.foreignkey(genre, null=true) cast = arrayfield(models.charfield(max_length=50))
to accommodate arrayfield
used
from djorm_pgarray.fields import arrayfield djorm_expressions.models import expressionmanager
in out models.
and next generated sql cast
:
alter table movies_movies add together column "cast" integer[];
any thought why cast
column turned out integer though specified charfield
?
according djorm_pgarray docs, can create array of text follows:
from djorm_pgarray.fields import textarrayfield class movies(models.model): # ... cast = textarrayfield(dimension=1)
or, according this article:
from djorm_pgarray.fields import arrayfield class movies(models.model): # ... cast = arrayfield(dbtype="text", dimension=1)
about max_length
of text field (varchar , text same in fact postgres): not sure, possible define within array in postgres.
python django postgresql
No comments:
Post a Comment