Alir3z4/django-cuser

Django 1.9

Closed this issue · 4 comments

Hello, I have a project in Django 1.9 and I am trying to use your application but gives me an error when importing the CurrentUserField.

from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.db import models

from cuser.fields import CurrentUserField

from myapps.utils.models import Audit


class Project(models.Model):
    name = models.CharField(max_length=150, verbose_name=_(u'Nombre del proyecto'), unique=True)
    creator = CurrentUserField(add_only=True, related_name='created_projects')

    class Meta:
      verbose_name = _(u'Proyecto')
      verbose_name_plural = _(u'Proyectos')
      ordering = ['name', ]

    def __unicode__(self):
      return "%s" % self.name`

The error is as follows:

File "/virtualenv/baenet/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/webapps/baenet/baenet/myapps/projects/models.py", line 14, in <module>
    class Project(models.Model):
  File "/webapps/baenet/baenet/myapps/projects/models.py", line 16, in Project
    creator = CurrentUserField(add_only=True, related_name='created_projects')
  File "/virtualenv/baenet/local/lib/python2.7/site-packages/cuser/fields.py", line 27, in __init__
    super(CurrentUserField, self).__init__(**kwargs)
  File "/virtualenv/baenet/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 799, in __init__
    to, on_delete, from_fields=['self'], to_fields=[to_field], **kwargs)
  File "/virtualenv/baenet/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 456, in __init__
    super(ForeignObject, self).__init__(rel=rel, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'rel_class'`

@bienvenidosaez Thanks for the report.
I made the pull request #16 which is a work by @vst

You can checkout that branch before it get merged and let us know your opinion.

I ran into the same error message while upgrading to 1.9, @vst's fix resolved the problem

I have the same problem with django 1.9

Latest version is there and it's compatible with Django +1.8