On Sat, May 17, 2008 at 5:46 PM, Brian <[EMAIL PROTECTED]> wrote: > > I've searched for this, but people think it is either fixed or very > hard to reproduce. In my case it is 100% reproducible, and I wonder if > it is my own fault. > > I have a model for a mp3 set (a set of mp3s). Individual mp3's are > associated with the set via a Foreign key. > > I recently added a slug field to the mp3 after the fact, and I think I > have manually added it to the MySQL database to match what Django > thinks should be there. Now, when I try to edit a mp3 set in the admin > page and hit save, I always get: > > TypeError at /django/admin/band/mp3_set/3/ > Cannot resolve keyword 'slug' into field. Choices are: mp3, id, date, > title, text > > Here are the models: > > class Mp3_Set(models.Model): > date = models.DateField(auto_now_add = True, editable = False) > title = models.CharField(max_length = 64) > text = models.TextField() > > def __unicode__(self): > return self.title > > class Admin: > list_filter = ('date', ) > list_display = ('title', 'date') > > class Meta: > ordering = ('date', ) > verbose_name = "MP3 Set" > > class Mp3(models.Model): > mp3_set = models.ForeignKey(Mp3_Set, edit_inline = models.TABULAR, > num_in_admin = 5, num_extra_on_change = 5) > title = models.CharField(max_length = 64, core = True) > desc = models.CharField(max_length = 128, blank = True) > file = models.FileField(upload_to = 'mp3s/%Y/%m/%d/') > slug = models.SlugField(unique = True, prepopulate_from = ('title', > 'desc')) > > def __unicode__(self): > return self.title > > class Admin: > pass > > class Meta: > ordering = ('title', ) > verbose_name = "MP3" > > And here is the export SQL for the two tables: > > CREATE TABLE `band_mp3_set` ( > `id` int(11) NOT NULL auto_increment, > `date` date NOT NULL, > `title` varchar(64) collate latin1_general_ci NOT NULL, > `text` longtext collate latin1_general_ci NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci > AUTO_INCREMENT=4 ; > > CREATE TABLE `band_mp3` ( > `id` int(11) NOT NULL auto_increment, > `mp3_set_id` int(11) NOT NULL, > `title` varchar(64) collate latin1_general_ci NOT NULL, > `desc` varchar(128) collate latin1_general_ci NOT NULL, > `file` varchar(100) collate latin1_general_ci NOT NULL, > `slug` varchar(50) collate latin1_general_ci NOT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `band_mp3_slug` (`slug`), > KEY `band_mp3_mp3_set_id` (`mp3_set_id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci > AUTO_INCREMENT=11 ; > > > Here is a trace back: > Traceback: > File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in > get_response > 82. response = callback(request, *callback_args, > **callback_kwargs) > File "C:\Python25\Lib\site-packages\django\contrib\admin\views > \decorators.py" in _checklogin > 62. return view_func(request, *args, **kwargs) > File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py" > in _wrapped_view_func > 44. response = view_func(request, *args, **kwargs) > File "C:\Python25\Lib\site-packages\django\contrib\admin\views > \main.py" in change_stage > 334. errors = manipulator.get_validation_errors(new_data) > File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in > get_validation_errors > 62. errors.update(field.get_validation_errors(new_data)) > File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in > get_validation_errors > 379. self.run_validator(new_data, validator) > File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in > run_validator > 369. validator(new_data.get(self.field_name, ''), > new_data) > File "C:\Python25\Lib\site-packages\django\utils\functional.py" in > _curried > 55. return _curried_func(*(args+moreargs), **dict(kwargs, > **morekwargs)) > File "C:\Python25\Lib\site-packages\django\db\models\fields > \__init__.py" in manipulator_validator_unique > 47. old_obj = self.manager.get(**{lookup_type: field_data}) > File "C:\Python25\Lib\site-packages\django\db\models\manager.py" in > get > 69. return self.get_query_set().get(*args, **kwargs) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in get > 261. obj_list = list(clone) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > __iter__ > 114. return iter(self._get_data()) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > _get_data > 486. self._result_cache = list(self.iterator()) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > iterator > 180. select, sql, params = self._get_sql_clause() > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > _get_sql_clause > 501. joins2, where2, params2 = self._filters.get_sql(opts) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > get_sql > 723. joins2, where2, params2 = val.get_sql(opts) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > get_sql > 774. return parse_lookup(self.kwargs.items(), opts) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > parse_lookup > 929. joins2, where2, params2 = lookup_inner(path, > lookup_type, value, opts, opts.db_table, None) > File "C:\Python25\Lib\site-packages\django\db\models\query.py" in > lookup_inner > 1047. raise TypeError, "Cannot resolve keyword '%s' into > field. Choices are: %s" % (name, ", ".join(choices)) > > Exception Type: TypeError at /django/admin/band/mp3_set/3/ > Exception Value: Cannot resolve keyword 'slug' into field. Choices > are: mp3, id, date, title, text > > > Thanks for any hints. >
Based on the choices the error message lists, it appears you have added code that tries to access the slug field in an Mp3_Set model instance. However, you have added the slug field to the other model, Mp3. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---