just updated to latest newforms-admin (r7947) and....
This is the admin for one of my (rather large) models:
class Sound(SocialModel): # SocialModel is a model that defines some
GenericRelation
user = models.ForeignKey(User)
# snip
license = models.ForeignKey(License)
geotag = models.ForeignKey(GeoTag, null=True, blank=True, default=None)
#snip
sources = models.ManyToManyField('self', symmetrical=False,
related_name='remixes', blank=True)
pack = models.ForeignKey('Pack', null=True, blank=True, default=None)
#snip
type = models.CharField(db_index=True, max_length=4,
choices=SOUND_TYPE_CHOICES)
#....
class SoundAdmin(admin.ModelAdmin):
raw_id_fields = ('user', 'pack', 'sources', 'geotag')
list_display = ('id', 'user', 'original_filename', 'license')
list_filter = ('processing_state', 'moderation_state', 'license')
fieldsets = (
(None, {'fields': ('user', 'created', 'modified')}),
('Filenames', {'fields': ('original_path', 'base_filename_slug')}),
('User defined fields', {'fields': ('description', 'license',
'geotag', 'original_filename', 'sources', 'pack')}),
('File properties', {'fields': ('md5', 'type', 'duration',
'bitrate', 'bitdepth', 'samplerate', 'filesize', 'channels')}),
('Moderation', {'fields': ('moderation_state',
'moderation_date', 'moderation_bad_description')}),
('Processing', {'fields': ('processing_state',
'processing_date', 'processing_log')}),
)
admin.site.register(Sound, SoundAdmin)
And this is the error I get when validating:
Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
85. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/decorators.py"
in __call__
66. if self.test_func(request.user):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/middleware.py"
in __get__
5. request._cached_user = get_user(request)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/auth/__init__.py"
in get_user
80. user_id = request.session[SESSION_KEY]
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py"
in __getitem__
33. return self._session[key]
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py"
in _get_session
147. self._session_cache = self.load()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/sessions/backends/db.py"
in load
20. expire_date__gt=datetime.datetime.now()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py"
in get
82. return self.get_query_set().get(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in get
296. clone = self.filter(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in filter
479. return self._filter_or_exclude(False, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py"
in _filter_or_exclude
497. clone.query.add_q(Q(*args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in add_q
1159. can_reuse=used_aliases)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in add_filter
1037. alias, True, allow_many, can_reuse=can_reuse)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py"
in setup_joins
1197. field, model, direct, m2m = opts.get_field_by_name(name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in get_field_by_name
274. cache = self.init_name_map()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in init_name_map
300. for f, model in self.get_all_related_m2m_objects_with_model():
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in get_all_related_m2m_objects_with_model
377. cache = self._fill_related_many_to_many_cache()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/options.py"
in _fill_related_many_to_many_cache
391. for klass in get_models():
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py"
in get_models
136. self._populate()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py"
in _populate
57. self.load_app(app_name, True)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py"
in load_app
72. mod = __import__(app_name, {}, {}, ['models'])
File "/Users/bram/Development/nightingale/freesound/sounds/models.py"
in <module>
102. admin.site.register(Sound, SoundAdmin)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in register
81. validate(admin_class, model)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/validation.py"
in validate
15. _validate_base(cls, model)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/validation.py"
in _validate_base
183.
_check_form_field_existsw("fieldsets[%d][1]['fields']" % idx, field)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/validation.py"
in _check_form_field_existsw
149. return _check_form_field_exists(cls, model, opts, label, field)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/validation.py"
in _check_form_field_exists
264. fields = fields_for_model(model)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/newforms/models.py"
in fields_for_model
205. formfield = formfield_callback(f)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/newforms/models.py"
in <lambda>
184. def fields_for_model(model, fields=None, exclude=None,
formfield_callback=lambda f: f.formfield()):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/fields/related.py"
in formfield
685. defaults = {'form_class': forms.ModelChoiceField,
'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)}
Exception Type: AttributeError at /account/upload/
Exception Value: 'str' object has no attribute '_default_manager'
The error goes away when I remove the fieldsets definition.
Just thought I'd ask here ;)
- Bram
Hello all,
just updated to latest newforms-admin (r7947) and....
[snip Traceback start]
184. def fields_for_model(model, fields=None, exclude=None,
formfield_callback=lambda f: f.formfield()):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/fields/related.py"
in formfield
685. defaults = {'form_class': forms.ModelChoiceField,
'queryset': self.rel.to._default_manager.complex_filter(self.rel.limit_choices_to)}
Exception Type: AttributeError at /account/upload/
Exception Value: 'str' object has no attribute '_default_manager'
The error goes away when I remove the fieldsets definition.
Sorry for not replying this earlier.
Splitting my admin settings into admin.py modules, and updating to the
latest trunk fixed this problem.
- Bram