Django Import-Export: Admin interface "TypeError at /"

django, python

Solution

Although I'm not familiar with this particular app, what you should do is replace

admin.site.register(Regional_Units)
admin.site.register(Regional_Units_Resource_Admin)

with

admin.site.register(Regional_Units, Regional_Units_Resource_Admin)

and if everything else is ok it should work. The admin `register()` method expects the Model as first argument and (optionally) a ModelAdmin class (or subclass) as second argument.

Sidenote: since you're just starting with python/django try to comply with the conventions. This means do not use `_` between words in class Names (i.e. RegionalUnits is a suitable name) and try to place `ModelAdmin` declarations right inside the admin.py module (i.e. `RegionalUnitsResourceAdmin` should be declared in admin.py rather than being imported).

Problem

I am trying to figure out how to use Django Import-Export, https://pypi.python.org/pypi/django-import-export by reading the docs https://django-import-export.readthedocs.org/en/latest/getting_started.html#admin-integration Admin Integration: The gap between the example code and its resulting photo that follows, seems to be vast for my elementary python knowledge. I have managed to code the following: geographical_system/models.py: ``` from django.db import models from django.utils.translation import ugettext_lazy as _ class Regional_Units(models.Model): regional_unit = models.CharField( max_length=64, verbose_name=_(u'Regional Units')) def __unicode__(self): return u'%s' % (self.regional_unit) ``` geographical_system/resources.py: ``` from import_export import resources from geographical_system.models import Regional_Units from import_export.admin import ImportExportModelAdmin class Regional_Units_Resource(resources.ModelResource): class Meta(object): model = Regional_Units class Regional_Units_Resource_Admin(ImportExportModelAdmin): resouce_class = Regional_Units_Resource # Why originally commented out? #pass #Why pass? ``` geographical_system/admin.py: ``` from django.contrib import admin from geographical_system.models import Regional_Units from geographical_system.resources import Regional_Units_Resource_Admin admin.site.register(Regional_Units) admin.site.register(Regional_Units_Resource_Admin) # **Improvising here**, otherwise nothing would happen ``` Resulting Error Of course, my improvisation `admin.site.register(Regional_Units_Resource_Admin)` resulted in the following message when visiting `http://127.0.0.1:8000/admin/geographical_system/regional_units/` ``` TypeError at /admin/geographical_system/regional_units/ 'RenameBaseModelAdminMethods' object is not iterable Request Method: GET Request URL: http://127.0.0.1:8000/admin/geographical_system/regional_units/ Django Version: 1.6 Exception Type: TypeError Exception Value: 'RenameBaseModelAdminMethods' object is not iterable Exception Location: /home/flyer/.virtualenvs/rara/lib/python2.7/site-packages/django/contrib/admin/sites.py in register, line 71 Python Executable: /home/flyer/.virtualenvs/rara/bin/python Python Version: 2.7.5 Python Path: ['/home/flyer/02/rara', '/home/flyer/.virtualenvs/rara/lib64/python27.zip', '/home/flyer/.virtualenvs/rara/lib64/python2.7', '/home/flyer/.virtualenvs/rara/lib64/python2.7/plat-linux2', '/home/flyer/.virtualenvs/rara/lib64/python2.7/lib-tk', '/home/flyer/.virtualenvs/rara/lib64/python2.7/lib-old', '/home/flyer/.virtualenvs/rara/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7', '/usr/lib/python2.7', '/usr/lib64/python2.7/lib-tk', '/home/flyer/.virtualenvs/rara/lib/python2.7/site-packages'] ``` Questions - Why is this error appearing? - How could I end - up into this beautiful admin interface where Import and Export options are enabled?

Original source