My project uses South and I want to use django-private-files fields for some of my apps. private_files does not provide introspection rules, so I wrote some in my app's fields.py file. Usually theses are pretty straight forward, but I never had to write rules for a custom field that has an attribute who's value is a callable with arguments. This is what I got:
# 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"])
These rules are for the PrivateFileField
When I run ./manage.py schemamigration --initial myapp
I get TypeError: is_user_authenticated() takes exactly 2 arguments (0 given), which makes sense as South calls all callable values without args.
Can anyone help me write these introspection rules? Maybe I can tell South can ignore this argument?
Thanks in advance for your help.
P.S: This question was also asked on stackoverflow.