I am working on migrating an Django app to 1.0.

I am running into problems getting my models registered with the
admin. I am following the info here:

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Mergednewforms-adminintotrunk

I have updated my main urls.py:

---------
from django.conf.urls.defaults import *
from django.contrib import admin

from books.settings import URL_MATCH_BASE, ABS_BASE_PATH, DEVELOPMENT
from django.views.generic.simple import direct_to_template

admin.autodiscover()

handler404 = 'books.data.views.handle_404'
handler500 = 'books.data.views.handle_500'

urlpatterns = patterns('',
    # Example:
    # (r'^books/', include('books.foo.urls')),

    # Uncomment this for admin:
    #(r'^about/$', direct_to_template, {'template': 'books/about.html'}),
    (r'^about/$',"books.data.views.about"),
    (r'^translating/$',"books.data.views.translating"),
        (r'^'+URL_MATCH_BASE+'admin/(.*)', admin.site.root),
        (r'^'+URL_MATCH_BASE+'$', include('books.data.urls')),
        (r'^'+URL_MATCH_BASE+'books/', include('books.data.urls')),
)

if DEVELOPMENT:
        urlpatterns += patterns('',
        (r'^dmedia/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': ABS_BASE_PATH + "/dmedia"}),
    )
---------

and have removed Admin classes from models.py into admins.py, and
registered the classes:

----------models.py--------------
from django.db import models
from django.template.defaultfilters import slugify
from django.contrib.markup.templatetags.markup import markdown

class URL(models.Model):
        name = models.CharField(max_length=75)
        description = models.TextField(blank=True)
        url = models.URLField(verify_exists=False)
        
        def __unicode__(self):
                return self.name
        #end __unicode__
                
        class Meta:
                unique_together = (("name", "url"),)
        #end Meta               
#end URL
--------------------------------------

----------admin.py---------------
from django.contrib import admin
from books.data.models import URL

class URLAdmin(admin.ModelAdmin):
        list_display = ('name','url','description',)
        search_fields = ['name', 'description', 'url']
#end Admin
admin.site.register(URL, URLAdmin)
-------------------------------------

However, when I try to go to the admin I get either one of two errors
(if I keep refreshing, the errors change between the two randomly.

Either
-------
TypeError at /admin/

dict objects are unhashable
------

or

--------
AlreadyRegistered at /admin/

The model URL is already registered
--------

The full errors are included below. Anyone have any idea what is going
on? This is current stopped my migration.

mike


-----------------------------------------
TypeError at /admin/

dict objects are unhashable

Request Method:         GET
Request URL:    http://127.0.0.1:8000/admin/
Exception Type:         TypeError
Exception Value:        

dict objects are unhashable

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.0-final-SVN-7534
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'books.data',
 'books.comments']
Installed Middleware:
('django.middleware.cache.CacheMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  77.                     request.path_info)
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py" in resolve
  178.             for pattern in self.urlconf_module.urlpatterns:
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"
in _get_urlconf_module
  197.             self._urlconf_module =
__import__(self.urlconf_name, {}, {}, [''])
File "/Users/mesh/Sites/books/../books/urls.py" in <module>
  31. admin.autodiscover()
File "/Library/Python/2.5/site-packages/django/contrib/admin/__init__.py"
in autodiscover
  40.         __import__("%s.admin" % app)
File "/Users/mesh/Sites/books/../books/data/admin.py" in <module>
  68. admin.site.register(BookVersion, BookVersionAdmin)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in register
  76.             validate(admin_class, model)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in validate
  25.     validate_base(cls, model)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in validate_base
  157.             check_formfield(cls, model, opts, 'fields', field)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in check_formfield
  263.             fields[field]

Exception Type: TypeError at /admin/
Exception Value: dict objects are unhashable


-------------------------------------
AlreadyRegistered at /admin/

The model URL is already registered

Request Method:         GET
Request URL:    http://127.0.0.1:8000/admin/
Exception Type:         AlreadyRegistered
Exception Value:        

The model URL is already registered

Exception Location:
        /Library/Python/2.5/site-packages/django/contrib/admin/sites.py in
register, line 64
Python Executable:
        
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
Python Version:         2.5.1

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.0-final-SVN-7534
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'books.data',
 'books.comments']
Installed Middleware:
('django.middleware.cache.CacheMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  77.                     request.path_info)
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py" in resolve
  178.             for pattern in self.urlconf_module.urlpatterns:
File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py"
in _get_urlconf_module
  197.             self._urlconf_module =
__import__(self.urlconf_name, {}, {}, [''])
File "/Users/mesh/Sites/books/../books/urls.py" in <module>
  31. admin.autodiscover()
File "/Library/Python/2.5/site-packages/django/contrib/admin/__init__.py"
in autodiscover
  40.         __import__("%s.admin" % app)
File "/Users/mesh/Sites/books/../books/data/admin.py" in <module>
  68. admin.site.register(BookVersion, BookVersionAdmin)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in register
  76.             validate(admin_class, model)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in validate
  25.     validate_base(cls, model)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in validate_base
  157.             check_formfield(cls, model, opts, 'fields', field)
File "/Library/Python/2.5/site-packages/django/contrib/admin/validation.py"
in check_formfield
  263.             fields[field]

Exception Type: TypeError at /admin/
Exception Value: dict objects are unhashable

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to