I'm writing a simple django app using django 1.6 and python 2.7.2 and I wanted to create a Post object quickly so I could test something else I was writing. Used the built in django Admin page to add the object, and it threw an error saying 'int' object is not subscriptable. I'm sure I could create the object in another way if necessary, but I am wondering if this is something I am doing incorrectly that I should fix or if it is a bug I shouldn't worry about.
Models.py:
from django.db import models
from django.contrib.auth.models import User
class Forum(models.Model):
name = models.CharField(max_length = 100)
club = models.ForeignKey(Club, blank = True)
public = models.BooleanField()
def __unicode__(self):
return self.name
class Thread(models.Model):
name = models.CharField(max_length = 100)
forum = models.ForeignKey(Forum)
can_post = models.BooleanField()
def __unicode__(self):
return self.name
class Like(models.Model):
user = models.ForeignKey(User)
def __unicode__(self):
return self.id
class Post(models.Model):
body = models.TextField()
poster = models.ForeignKey(User)
thread = models.ForeignKey(Thread)
forum = models.ForeignKey(Forum)
likes = models.ManyToManyField(Like, blank = True)
date_posted = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return self.id
Traceback:
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/contrib/admin/options.py" in wrapper
430. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/contrib/admin/sites.py" in inner
198. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/utils/decorators.py" in bound_func
25. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/db/transaction.py" in inner
339. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/contrib/admin/options.py" in add_view
1131. self.log_addition(request, new_object)
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/contrib/admin/options.py" in log_addition
598. action_flag=ADDITION
File "/usr/local/lib/python2.7/dist-packages/Django-1.6-py2.7.egg/django/contrib/admin/models.py" in log_action
19. e = self.model(None, None, user_id, content_type_id, smart_text(object_id), object_repr[:200], action_flag, change_message)
Exception Type: TypeError at /admin/forums/post/add/
Exception Value: 'int' object is not subscriptable