Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用South创建Django缓存表?_Python_Django_Caching_Django South - Fatal编程技术网

Python 使用South创建Django缓存表?

Python 使用South创建Django缓存表?,python,django,caching,django-south,Python,Django,Caching,Django South,我们使用South进行模式迁移和数据迁移。现在我需要在Django中启用缓存,这非常简单。这迫使我在终端中使用manage.py createcachetable cache\u table。虽然我想用South自动化这个过程。有没有一种方法可以使用South创建缓存表 创建一个新的南方数据迁移(只是一个空白迁移): python manage.py数据迁移 谢谢看起来正是我想要的:) import datetime from south.db import db from south.v2 i

我们使用South进行模式迁移和数据迁移。现在我需要在Django中启用缓存,这非常简单。这迫使我在终端中使用
manage.py createcachetable cache\u table
。虽然我想用South自动化这个过程。有没有一种方法可以使用South创建缓存表

创建一个新的南方数据迁移(只是一个空白迁移):
python manage.py数据迁移


谢谢看起来正是我想要的:)
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.core.management import call_command # Add this import

class Migration(DataMigration):
    def forwards(self, orm):
        call_command('createcachetable', 'cache')

    def backwards(self, orm):
        db.delete_table('cache')

    ...
import datetime
from south.db import dbs # Import dbs instead of db
from south.v2 import DataMigration
from django.db import models
from django.core.management import call_command # Add this import

class Migration(DataMigration):
    def forwards(self, orm):
        call_command('createcachetable', 'cache', database='other_database')

    def backwards(self, orm):
        dbs['other_database'].delete_table('cache')

    ...