2016-11-10 3 views
0

を有する第一は、私がmigrating..Iについてtroulble havnigいMySQLの移行とのトラブル(非整数タイプの「タプル」によってシーケンスを乗算することはできません)

Pythonは

をqablog移行manage.pyの試してみました

と動作しませんでした。私はので、私はfalseにUSE_TZを変更するようにいくつかのことを変更するので、私は再びGoogleで検索し、一部の人々はsettings.pyの変更を話していた。..

python manage.py migrate qablog --fake-initial 

を試してみましたが、あまりうまくいきませんでした。..

python manage.py makemigrations qablog

...これは誰でも助けてくれますか? .. Pythonバージョン:3.4.4 MySQLサーバのバージョン:5.7 Djangoのバージョン:1.10.3

エラーログは以下のようである:

C:\inetpub\wwwroot\test>python manage.py migrate qablog --fake-initial 
Operations to perform: 
    Apply all migrations: qablog 
Running migrations: 
    Applying contenttypes.0001_initial... FAKED 
    Applying auth.0001_initial... OK 
    Applying qablog.0001_initial... OK 
Traceback (most recent call last): 
    File "manage.py", line 22, in <module> 
    execute_from_command_line(sys.argv) 
    File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 
367, in execute_from_command_line 
    utility.execute() 
    File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 
359, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "C:\Python34\lib\site-packages\django\core\management\base.py", line 294, 
in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "C:\Python34\lib\site-packages\django\core\management\base.py", line 345, 
in execute 
    output = self.handle(*args, **options) 
    File "C:\Python34\lib\site-packages\django\core\management\commands\migrate.py 
", line 224, in handle 
    self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, 
plan=plan, 
    File "C:\Python34\lib\site-packages\django\core\management\sql.py", line 53, i 
n emit_post_migrate_signal 
    **kwargs 
    File "C:\Python34\lib\site-packages\django\dispatch\dispatcher.py", line 191, 
in send 
    response = receiver(signal=self, sender=sender, **named) 
    File "C:\Python34\lib\site-packages\django\contrib\auth\management\__init__.py 
", line 83, in create_permissions 
    Permission.objects.using(using).bulk_create(perms) 
    File "C:\Python34\lib\site-packages\django\db\models\query.py", line 452, in b 
ulk_create 
    ids = self._batched_insert(objs_without_pk, fields, batch_size) 
    File "C:\Python34\lib\site-packages\django\db\models\query.py", line 1068, in 
_batched_insert 
    self._insert(item, fields=fields, using=self.db) 
    File "C:\Python34\lib\site-packages\django\db\models\query.py", line 1045, in 
_insert 
    return query.get_compiler(using=using).execute_sql(return_id) 
    File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 10 
53, in execute_sql 
    for sql, params in self.as_sql(): 
    File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 10 
38, in as_sql 
    result.append(self.connection.ops.bulk_insert_sql(fields, placeholder_rows)) 

    File "C:\Python34\lib\site-packages\mysql\connector\django\operations.py", lin 
e 223, in bulk_insert_sql 
    return "VALUES " + ", ".join([items_sql] * num_values) 
TypeError: can't multiply sequence by non-int of type 'tuple' 

[manage.py]

#!/usr/bin/env python 
import os 
import sys 

if __name__ == "__main__": 
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "swingqa.settings") 
    try: 
     from django.core.management import execute_from_command_line 
    except ImportError: 
     # The above import may fail for some other reason. Ensure that the 
     # issue is really that Django is missing to avoid masking other 
     # exceptions on Python 2. 
     try: 
      import django 
     except ImportError: 
      raise ImportError(
       "Couldn't import Django. Are you sure it's installed and " 
       "available on your PYTHONPATH environment variable? Did you " 
       "forget to activate a virtual environment?" 
      ) 
     raise 
    execute_from_command_line(sys.argv) 

[models.py]

from django.db import models 
from django.utils import timezone 


class Post(models.Model): 
    author = models.ForeignKey('auth.User') 
    title = models.CharField(max_length=200) 
    text = models.TextField() 
    created_date = models.DateTimeField(
      default=timezone.now) 
    published_date = models.DateTimeField(
      blank=True, null=True) 

def publish(self): 
    self.published_date = timezone.now() 
    self.save() 

def __str__(self): 
    return self.title 

とするため 移行ファイル..私は> qablogの内側に見えた移行フォルダとのinitと0001_initialファイルがあります。.. のinitファイルが空である(それは内部だけで空白だ)と0001_初期ファイルが

以下のようなものです[0001_initial.py ]

# -*- coding: utf-8 -*- 
# Generated by Django 1.10.3 on 2016-11-10 07:56 
from __future__ import unicode_literals 

from django.conf import settings 
from django.db import migrations, models 
import django.db.models.deletion 
import django.utils.timezone 


class Migration(migrations.Migration): 

    initial = True 

    dependencies = [ 
     migrations.swappable_dependency(settings.AUTH_USER_MODEL), 
    ] 

    operations = [ 
     migrations.CreateModel(
      name='Post', 
      fields=[ 
       ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 
       ('title', models.CharField(max_length=200)), 
       ('text', models.TextField()), 
       ('created_date', models.DateTimeField(default=django.utils.timezone.now)), 
       ('published_date', models.DateTimeField(blank=True, null=True)), 
       ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 
      ], 
     ), 
    ] 

は、私は本当に

+0

関連する移行ファイル – e4c5

+0

を投稿する質問にモデルと移行ファイルを追加できますか? –

+0

私は投稿を編集しました。 – cherrylatte

答えて

4

:-)いくつかの助けをいただければと思いますが

:-)自分でこの質問への解決策を見つけた私は本当にしないでくださいあなたは Cの下に、このパスにoperations.pyファイルを変更した場合の理由が、

を知っています。def関数であるbulk_insert_sql \ mysqlの\コネクタ\ジャンゴ

特に一部が\ Python34 \ Libの\のsite-packages ,,

def bulk_insert_sql(self, fields, num_values): 
     items_sql = "({0})".format(", ".join(["%s"] * len(fields))) 
     return "VALUES " + ", ".join([items_sql] * num_values) 

に...

def bulk_insert_sql(self, fields, placeholder_rows): 
    """ 
    Format the SQL for bulk insert 
    """ 
    placeholder_rows_sql = (", ".join(row) for row in placeholder_rows) 
    values_sql = ", ".join("(%s)" % sql for sql in placeholder_rows_sql) 
    return "VALUES " + values_sql 

からのpython manage.pyの移行qablogコマンドを実行中にエラーは発生しません。

関連する問題