I'm attempting to implement django-progressbarupload.
https://github.com/ouhouhsami/django-progressbarupload
I'm getting the following error:
for model in model_or_iterable: TypeError: 'MediaDefiningClass' object is not iterable
admin.py
from django.contrib import admin
from accounts.models import UserProfile
class UserProfile(admin.ModelAdmin):
change_form_template = 'progressbarupload/change_form.html'
add_form_template = 'progressbarupload/change_form.html'
admin.site.register(UserProfile)
This is the traceback
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\__init__.py", line 347, in execute
django.setup()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\apps\registry.py", line 120, in populate
app_config.ready()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\apps.py", line 23, in ready
self.module.autodiscover()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\jason\Desktop\jason3\accounts\admin.py", line 18, in <module>
admin.site.register(UserProfile)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\sites.py", line 102, in register
for model in model_or_iterable:
TypeError: 'MediaDefiningClass' object is not iterable
Thanks for the help!
The first parameter to register
is the model class itself. You have used the same name for your model class as your admin class. Give them separate names and pass them both to register
.
class UserProfileAdmin(admin.ModelAdmin):
change_form_template = 'progressbarupload/change_form.html'
add_form_template = 'progressbarupload/change_form.html'
admin.site.register(UserProfile, UserProfileAdmin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With