lehins / django-smartfields

Django Model Fields that are smart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected keyword argument 'dependencies' on ManyToMany field

odragora opened this issue · comments

Hi!

I've got this error when trying to use dependencies:

TypeError: __init__() got an unexpected keyword argument 'dependencies'

My code:

class UsersAllowedProcessor(processors.BaseProcessor):

    def process(self, value, stashed_value=None, **kwargs):
        if value != stashed_value:
            print 'Document users allowed changed!'
            print 'Before:', stashed_value
            print 'Now:', value
        return value

class DocModel(models.Model):
    name = models.CharField(verbose_name=u'Название', max_length=64, unique=True)
    users_allowed = models.ManyToManyField(User, verbose_name=u'Доступ', dependencies=[
        Dependency(processor=UsersAllowedProcessor())
    ])
    timestamp = models.DateTimeField(verbose_name=u'Обновлено', auto_now=True)

I'm using Django 1.8 and django-smartfields from pip

Unfortunately it is not yet possible to use smartfields with related fields like ForeignKey or ManyToManyField. Moreover, in order for dependencies to work you need to import a field from smartfields.fields instead of django.db.models.

Thank you. It's an interesting package anyway.