我的项目使用南方,我想在我的某些应用中使用django-private-files字段。 private_files不提供内省规则,所以我在我的应用程序的fields.py文件中写了一些。通常这些论文非常简单,但我从来没有必要为自定义字段编写规则,该字段具有属性,其值可以通过参数调用。这就是我得到的:
# myapp/models.py
from django.db import models
import fields # to add south introspection rules
from private_files import PrivateFileField
class Image(models.Model):
description = models.CharField("description", max_length = 200)
image = PrivateFileField("image file", upload_to = 'uploads')
-
# myapp/fields.py
from private_files import PrivateFileField
"""
South introspection rules
"""
from south.modelsinspector import add_introspection_rules
rules = [
(
(PrivateFileField,),
[],
{
"condition": ["condition", {}],
"attachment" : ["attachment", {"default": True}],
},
)]
add_introspection_rules(
rules,
["^private_files\.models\.fields\.PrivateFileField"])
这些规则适用于PrivateFileField
当我运行./manage.py schemamigration --initial myapp
时,我得到TypeError: is_user_authenticated() takes exactly 2 arguments (0 given)
提前感谢您的帮助。
答案 0 :(得分:1)
根据Andrew Godwin的说法:“南方的内省系统并不是为第二级别的通话能力而设计的。”(reference)这意味着此时解决这个问题的唯一方法是省略规则对于condition
参数,只需告诉南该字段即可。所以:
# myapp/fields.py
from private_files import PrivateFileField
"""
South introspection rules
"""
from south.modelsinspector import add_introspection_rules
rules = [
(
(PrivateFileField,),
[],
{
"attachment" : ["attachment", {"default": True}],
},
)]
add_introspection_rules(
rules,
["^private_files\.models\.fields\.PrivateFileField"])