Repository: evennia/evennia

Issue:
Error 500 when trying to Add Object from Admin Panel (Fresh Install)
(Full Pastebin)
http://pastebin.com/v1FbmBhq

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/objects/objectdb/add/

Django Version: 1.7.4
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
 'django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.flatpages',
 'django.contrib.staticfiles',
 'src.server',
 'src.typeclasses',
 'src.players',
 'src.objects',
 'src.comms',
 'src.help',
 'src.scripts',
 'src.web.webclient')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.admindocs.middleware.XViewMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
1.                     response = wrapped_callback(request, _callback_args, *_callback_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in wrapper
2.                 return self.admin_site.admin_view(view)(_args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
3.                     response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
4.         response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in inner
5.             return view(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in add_view
6.         return self.changeform_view(request, None, form_url, extra_context)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapper
7.             return bound_func(_args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
8.                     response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in bound_func
9.                 return func.**get**(self, type(self))(_args2, *_kwargs2)
   File "C:\Python27\lib\site-packages\django\db\transaction.py" in inner
10.                 return func(_args, *_kwargs)
    File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in changeform_view
11.         ModelForm = self.get_form(request, obj)
    File "C:\Users\codyp.PIPECOSRV0\Desktop\evennia-master\evennia\src\objects\admin.py" in get_form
12.                     'fields': admin.util.flatten_fieldsets(self.add_fieldsets),

Exception Type: AttributeError at /admin/objects/objectdb/add/
Exception Value: 'module' object has no attribute 'util'



Discussion:

Resolving patch:
diff --git a/src/objects/admin.py b/src/objects/admin.py
--- a/src/objects/admin.py
+++ b/src/objects/admin.py
@@ -6,6 +6,7 @@
 from django import forms
 from django.conf import settings
 from django.contrib import admin
+from django.contrib.admin.utils import flatten_fieldsets
 from src.typeclasses.admin import AttributeInline, TagInline
 from src.objects.models import ObjectDB
 
@@ -62,7 +63,6 @@ class ObjectDBAdmin(admin.ModelAdmin):
     save_on_top = True
     list_select_related = True
     list_filter = ('db_typeclass_path',)
-    #list_filter = ('db_permissions', 'db_typeclass_path')
 
     # editing fields setup
 
@@ -73,16 +73,7 @@ class ObjectDBAdmin(admin.ModelAdmin):
                            ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
                            )}),
         )
-    #fieldsets = (
-    #    (None, {
-    #            'fields': (('db_key','db_typeclass_path'), ('db_permissions', 'db_lock_storage'),
-    #                       ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
-    #                       )}),
-    #    )
 
-    #deactivated temporarily, they cause empty objects to be created in admin
-
-    # Custom modification to give two different forms wether adding or not.
     add_form = ObjectCreateForm
     add_fieldsets = (
         (None, {
@@ -91,12 +82,6 @@ class ObjectDBAdmin(admin.ModelAdmin):
                            )}),
         )
 
-    #add_fieldsets = (
-    #    (None, {
-    #            'fields': (('db_key','db_typeclass_path'), 'db_permissions',
-    #                       ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'
-    #                       )}),
-    #    )
     def get_fieldsets(self, request, obj=None):
         if not obj:
             return self.add_fieldsets
@@ -109,9 +94,9 @@ def get_form(self, request, obj=None, **kwargs):
         defaults = {}
         if obj is None:
             defaults.update({
-                    'form': self.add_form,
-                    'fields': admin.util.flatten_fieldsets(self.add_fieldsets),
-                    })
+                'form': self.add_form,
+                'fields': flatten_fieldsets(self.add_fieldsets),
+            })
             defaults.update(kwargs)
         return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)
 


Test patch: