I'm trying to create a database for multiple choice questions, but I
keep getting an error when I try to add answers, both when there are 5
blanks available when I first create a question or when there's only one
after I hit save and the error has already reared its ugly head.
Basically, I can't get answers into the database at all.
(Perhaps I shouldn't mention that I was using this for a final I'm
giving tomorrow morning....)
Error, traceback, and models below:
Here's a paste of the error:
OperationalError at /admin/questions/question/8/
(1093, "You can't specify target table 'questions_answer' for update in
FROM clause")
Request Method:
POST
Request URL:
http://localhost:8000/admin/questions/question/8/
Exception Type:
OperationalError
Exception Value:
(1093, "You can't specify target
table 'questions_answer' for update
in FROM clause")
Exception Location:
/usr/lib/python2.4/site-packages/MySQLdb/connections.py in defaulterrorhandler,
line 35
and the traceback:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in
get_response
74. response = callback(request, *callback_args, **callback_kwargs)
File
"/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in
_checklogin
55. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/views/decorators/cache.py"
in _wrapped_view_func
39. response = view_func(request, *args, **kwargs)
File
"/usr/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in
change_stage
329. new_object = manipulator.save(new_data)
File "/usr/lib/python2.4/site-packages/django/db/models/manipulators.py"
in save
198. new_rel_obj.save()
File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in save
204. ','.join(placeholders)), db_values)
File "/usr/lib/python2.4/site-packages/django/db/backends/util.py" in
execute
12. return self.cursor.execute(sql, params)
File "/usr/lib/python2.4/site-packages/django/db/backends/mysql/base.py"
in execute
42. return self.cursor.execute(sql, params)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py" in execute
163. self.errorhandler(self, exc, value)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py" in
defaulterrorhandler
35. raise errorclass, errorvalue
OperationalError at /admin/questions/question/8/
(1093, "You can't specify target table 'questions_answer' for update
in FROM clause")
from django.db import models
class Source(models.Model):
name = models.CharField(maxlength=40)
def __str__(self):
return self.name
class Admin:
pass
class Category(models.Model):
source = models.ForeignKey(Source)
name = models.CharField(maxlength=40)
def __str__(self):
return self.source.name + "-" + self.name
class Admin:
pass
class Question(models.Model):
category = models.ForeignKey(Category)
number = models.PositiveSmallIntegerField()
text = models.TextField()
correct_answer = models.PositiveSmallIntegerField()
def __str__(self):
return str(self.category) + ', #' + str(self.number)
class Admin:
pass
class Meta:
unique_together = (('category', 'number'), )
class Answer(models.Model):
question = models.ForeignKey(Question,
edit_inline=models.STACKED,
num_in_admin=5,
core=True)
number = models.PositiveSmallIntegerField()
text = models.TextField()
def __str__(self):
return str(self.question) + '-' + 'ABCDE'[self.number]
class Meta:
unique_together = (('question', 'number'), )
order_with_respect_to = 'question'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---