When following the tutorial I get the below error when attempting a
save from the admin console. I'm new to Django and certainly not a
guru of any sort so I thought I would ask about it here first before
posting a bug report. I am using the latest SVN release as of 4/21.
Any ideas what might be going on?
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/
decorators.py" in _checklogin
55. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
39. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/
main.py" in change_stage
329. new_object = manipulator.save(new_data)
File "/usr/lib/python2.5/site-packages/django/db/models/
manipulators.py" in save
191. param = f.get_manipulator_new_data(rel_new_data, rel=True)
File "/usr/lib/python2.5/site-packages/django/db/models/fields/
__init__.py" in get_manipulator_new_data
289. return new_data.get(self.name, [self.get_default()])[0]
TypeError at /admin/polls/poll/1/
'int' object is unsubscriptable
What stage of the tutorial, exactly, did this error occur at? Could
you also please copy and paste the contents of your models.py file
with your response?
Jay P.
I am on part 2, 'Custominze the Admin Change List'. (http://
www.djangoproject.com/documentation/tutorial02/#customize-the-admin-change-list)
Here is my copy of models.
thanks, mateo
from django.db import models
import datetime
class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Published today?'
class Admin:
list_display = ('question', 'pub_date', 'was_published_today')
list_filter = ['pub_date']
search_fields = ['question']
date_hierarchy = 'pub_date'
fields = (
(None, {'fields': ('question',)}),
('Date information', {'fields': ('pub_date',), 'classes':
'collapse'}),
)
class Choice(models.Model):
poll = models.ForeignKey(Poll, edit_inline=models.TABULAR,
num_in_admin=3)
choice = models.CharField(maxlength=200, core=True)
votes = models.IntegerField(core=True)
Sorry, I meant, what stage exactly did it break? ie., did you go
through tutorial 2 step by step, checking that the Admin looks like it
does in the tutorial, after each change, or did you just put in all
the code and try it? It'd be helpful to know what the last part was
that still worked, and what change caused it to break.
Jay P.
On Apr 21, 2:46 pm, "Jay Parlar" <par...@gmail.com> wrote:
> On 4/21/07, mateo <Matthew.Skir...@gmail.com> wrote:
>
> > I am on part 2, 'Custominze the Admin Change List'. (http://
> >www.djangoproject.com/documentation/tutorial02/#customize-the-admin-c...)
Well that's certainly less than desirable. If you have the time (and
know-how with Python), maybe download the 0.96 release, and try with
that, just to make sure that something didn't get screwed up recently
in SVN. I'd try myself, but I've run out of time for the evening.
Also, in the code you posted, the indents seem to be quite strange.
Maybe it's just the way Gmail formats it, but it looks like you're
using indent levels of 5 and 3 in different places. Try to stay
consistent and just use 4.
Jay P.
Thanks for all your help. I found this ticket (http://
code.djangoproject.com/ticket/3708) and switched from python 2.5 back
to 2.4 and now everythings working fine. Since it's a known issue,
I'll just leave it alone and continue on with 2.4. As for the
indents, I think it's just the formating here, everythings at 4 in
scribes.
Thanks again,
mateo
On Apr 21, 4:09 pm, "Jay Parlar" <par...@gmail.com> wrote: