oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
425 stars 81 forks source link

TypeError: metaclass conflict #102

Closed em1le closed 5 years ago

em1le commented 5 years ago

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Trace

 File "/Volumes/project/global/new_project/coffee/urls.py", line 96, in <module>
    urlpatterns += crud_for_app('staff')
  File "/Users/em1le/.virtualenvs/global/lib/python3.7/site-packages/cruds_adminlte/urls.py", line 100, in crud_for_app
    mixin=mixin)
  File "/Users/em1le/.virtualenvs/global/lib/python3.7/site-packages/cruds_adminlte/urls.py", line 50, in crud_for_model
    nc = NOCLASS()
  File "/Users/em1le/.virtualenvs/global/lib/python3.7/site-packages/cruds_adminlte/crud.py", line 675, in __init__
    self.initialize_create(basename + '/create.html')
  File "/Users/em1le/.virtualenvs/global/lib/python3.7/site-packages/cruds_adminlte/crud.py", line 550, in initialize_create
    OCreateView = self.get_create_view()
  File "/Users/em1le/.virtualenvs/global/lib/python3.7/site-packages/cruds_adminlte/crud.py", line 356, in get_create_view
    class OCreateView(self.mixin, CreateViewClass):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

python version : 3.7.1

python environment

appdirs==1.4.3
beautifulsoup4==4.7.1
certifi==2019.3.9
chardet==3.0.4
Django==2.2
django-appconf==1.0.3
django-braces==1.13.0
django-ckeditor==5.6.1
django-cleanup==3.2.0
django-colorfield==0.1.15
django-compressor==2.2
django-crispy-forms==1.7.2
django-cruds-adminlte==0.0.16
django-debug-toolbar==1.11
django-extensions==2.1.6
django-filter==2.1.0
django-formtools==2.1
django-grappelli==2.12.2
django-htmlmin==0.11.0
django-image-cropping==1.2.0
django-js-asset==1.2.2
django-maintenance-mode==0.13.1
django-material-admin==0.0.4
django-robots==3.1.0
django-select2==7.0.2
django-unused-media==0.1.13
djangoajax==3.1
djangorestframework==3.9.2
easy-thumbnails==2.6
html5lib==1.0.1
idna==2.8
olefile==0.46
packaging==19.0
Pillow==6.0.0
pyparsing==2.4.0
pytz==2019.1
rcssmin==1.0.6
reportlab==3.5.18
requests==2.21.0
rjsmin==1.1.0
six==1.12.0
soupsieve==1.9
sqlparse==0.3.0
Unidecode==1.0.23
urllib3==1.24.1
webencodings==0.5.1

settings.py

from easy_thumbnails.conf import Settings as thumbnail_settings

ALLOWED_HOSTS = ['*']

INSTALLED_APPS = (
     'staff',
    'crispy_forms',
    'django_select2',
    'easy_thumbnails',
    'image_cropping',
    'django_ajax',
    'cruds_adminlte'
)

CRISPY_TEMPLATE_PACK = 'bootstrap3'
INTERNAL_IPS = ('127.0.0.1',)
THUMBNAIL_PROCESSORS = (
    'image_cropping.thumbnail_processors.crop_corners',
) + thumbnail_settings.THUMBNAIL_PROCESSORS

TIME_FORMAT= 'h:i A'
DATETIME_FORMAT='d/m/Y H:i:s'
DATE_FORMAT="d/m/Y"

TIME_INPUT_FORMATS = ['%I:%M %p']

urls.py

from django.conf.urls import include, url
from django.contrib import admin

from cruds_adminlte.urls import crud_for_app

urlpatterns = [url('^admin/', admin.site.urls),]
urlpatterns += crud_for_app('staff')

Comments

I followed the installation from the documentation and BAM.

oscarmlage commented 5 years ago

Tested with a new environment (python-3.6.5 and django-2.2) and it happens here too. It seems that there is a problem in crud.py with the generic classes that inherits from a function:

def get_create_view_class(self):
    return CreateView

def get_create_view(self):
    CreateViewClass = self.get_create_view_class()

    class OCreateView(self.mixin, CreateViewClass):
        namespace = self.namespace

I've created a python-3 branch to take a look to this issue (and start migrating to django2 too). Hope @luisza can help here.

oscarmlage commented 5 years ago

It's due last @rtubio PR #99 so I'll revert the changes and ask him for more information. Thanks for the issue @em1le

rtubio commented 5 years ago

It looks like it works whenever you use it with overriden mixin - I am using it like that and I have no problems... definitely worth checking out the reason behind it.

odbalogun commented 5 years ago

Hello guys, Great work with this module. Is there any update on this issue?

rtubio commented 5 years ago

I haven't had a long of time lately to work on this issue, but I will try to commit some time along this month. Please feel free to contribute if you have some time for it.

oscarmlage commented 5 years ago

Release is planned for next days, stay tuned!

mhihasan commented 5 years ago

Is there any updated for this issue?

oscarmlage commented 5 years ago

@hasan151623 sorry for the delay, the planned release had to be postponed... I'll try to release new version as soon as posible.

oscarmlage commented 5 years ago

@hasan151623 and... new release is done! 😎

Jiangshan00001 commented 5 years ago

metaclass conflict still happen:

urlpatterns += crud_for_app('alarm_admin')

File "C:\Python36-32\lib\site-packages\cruds_adminlte\urls.py", line 100, in crud_for_app mixin=mixin) File "C:\Python36-32\lib\site-packages\cruds_adminlte\urls.py", line 50, in crud_for_model nc = NOCLASS() File "C:\Python36-32\lib\site-packages\cruds_adminlte\crud.py", line 675, in init self.initialize_create(basename + '/create.html') File "C:\Python36-32\lib\site-packages\cruds_adminlte\crud.py", line 550, in initialize_create OCreateView = self.get_create_view() File "C:\Python36-32\lib\site-packages\cruds_adminlte\crud.py", line 356, in get_create_view class OCreateView(self.mixin, CreateViewClass): TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Django==2.1.3 django-appconf==1.0.3 django-cors-headers==2.4.0 django-crispy-forms==1.7.2 django-cruds-adminlte==0.0.16 django-filter==2.0.0 django-formtools==2.1 django-image-cropping==1.2.0 django-import-export==1.1.0 django-mama-cas==2.4.0 django-rest-swagger==2.2.0 django-reversion==3.0.1 django-select2==7.1.0 django-sphinx==2.2.4 djangoajax==3.1 djangorestframework==3.9.0 djangorestframework-jwt==1.11.0

clint74 commented 5 years ago

@Jiangshan00001

metaclass conflict still happen:

seems to be working but you will need to install v 0.17 I guess

pip install -e git+git://github.com/oscarmlage/django-cruds-adminlte/@0.0.17+git.081101d#egg=django-cruds-adminlte
full-stack-dev-mex commented 5 years ago

This issue is still happening.. any solutions?

albertumus commented 4 years ago

I installed v0.17 to avoid the errors...

ashis08h commented 4 years ago

@clint74 when i try to install from docker through requirements.txt it is saying ModuleNotFoundError: No module named 'cruds_adminlte'

norrsken-jagare commented 3 years ago

@Jiangshan00001

metaclass conflict still happen:

seems to be working but you will need to install v 0.17 I guess

pip install -e git+git://github.com/oscarmlage/django-cruds-adminlte/@0.0.17+git.081101d#egg=django-cruds-adminlte

This worked for me.