DatabaseError "нет такого столбца" - PullRequest
1 голос
/ 02 февраля 2012

по какой-то причине я получаю DatabaseError "no such column: myapp_customer.redirect_link_id". Тот, кто имеет такой же точный код, что и я, на другом компьютере, не имеет этой проблемы. Мы используем Django-South для миграции, и в соответствии с этим я полностью ознакомлен с моделью:

$ python manage.py schemamigration myapp --auto
Nothing seems to have changed.

$ python manage.py migrate myapp
Running migrations for myapp:
- Nothing to migrate.
 - Loading initial data for myapp.
No fixtures found.

Вот полная трассировка стека:

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/me/sources/django_myapp/../django_myapp/myapp/views.py" in main_page
  66.         customer = Customer.objects.select_related().get(user = request.user)
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in get
  344.         num = len(clone)
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in __len__
  82.                 self._result_cache = list(self.iterator())
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in iterator
  273.         for row in compiler.results_iter():
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  680.         for rows in self.execute_sql(MULTI):
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  735.         cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py" in execute
  34.             return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  234.             return Database.Cursor.execute(self, query, params)

Exception Type: DatabaseError at /
Exception Value: no such column: myapp_customer.redirect_link_id

Я запустил manage.py sqlall myapp и в соответствии с этим, redirect_link_id присутствует в БД:

CREATE TABLE "myapp_customer" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"),
    "client_key" varchar(9) NOT NULL UNIQUE,
    "api_key" varchar(30) NOT NULL UNIQUE,
    "redirect_link_id" integer REFERENCES "myapp_full_link" ("id"),
    "message_title" varchar(200),
    "message_body" text,
    "customer_group_id" integer NOT NULL REFERENCES "myapp_customer_group" ("id")
)
;

1 Ответ

0 голосов
/ 02 февраля 2012

Вы уверены, что у вас также есть самые последние файлы миграции из каталога myapp / migrations?

...