Django: Difference between revisions
Line 1: | Line 1: | ||
==Models== | ==Models== | ||
=== | ===Migrations=== | ||
Example 1 | Example 1 | ||
*change model type e.g. Char to Integer : psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type integer: "" | *change model type e.g. Char to Integer : psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type integer: "" | ||
Line 8: | Line 8: | ||
Example 2 | Example 2 | ||
*change of field to unique can result in "DETAIL: Key (id....)=() is duplicated." | *change of field to unique can result in "DETAIL: Key (id....)=() is duplicated." | ||
Example 3 | |||
*if changing CharField to Unique the migration maybe does not covert the emty values to None?NULL and then one gets problems like: https://stackoverflow.com/questions/17257031/django-unique-null-and-blank-charfield-giving-already-exists-error-on-admin-p |
Revision as of 2022-04-28T21:43:22
Models
Migrations
Example 1
- change model type e.g. Char to Integer : psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type integer: ""
- alter field name in model ...try to delete field ...errors...
- to fix, try to rename, remove ... delete col by hand using psql, delete migrations, recreate migration ...
- problems: stuck in errors psycopg2.errors.DuplicateColumn: column "ccc" of relation "rrr" already exists
Example 2
- change of field to unique can result in "DETAIL: Key (id....)=() is duplicated."
Example 3
- if changing CharField to Unique the migration maybe does not covert the emty values to None?NULL and then one gets problems like: https://stackoverflow.com/questions/17257031/django-unique-null-and-blank-charfield-giving-already-exists-error-on-admin-p