I am using MySQL. Thanks for clearing that up! charles
On Jun 25, 3:02 pm, Brian Rosner <[EMAIL PROTECTED]> wrote: > On 2007-06-25 14:10:30 -0600, Charles Wesley <[EMAIL PROTECTED]> said: > > > > > > > Hello, > > > I'm a Django newbie, and I'm trying to set up a model that includes > > the following table: > > > class Team(models.Model): > > school = models.ForeignKey(School, > > unique_for_year="season_start_date") > > season_start_date = models.DateField() > > division = models.ForeignKey(Division) > > coach_first = models.CharField("coach's first name", maxlength=50, > > blank=True) > > coach_last = models.CharField("coach's last name", maxlength=50, > > blank=True) > > coach_email = models.EmailField("coach's email address", > > blank=True) > > coach_phone = models.PhoneNumberField("coach's phone", blank=True) > > team_picture = models.ImageField(upload_to="team", blank=True) > > players = models.ManyToManyField(Player, blank=True) > > > class Admin: > > pass > > > class Meta: > > order_with_respect_to = 'school' > > > When trying to add a team in the Django admin interface, I get this > > error: > > > Traceback (most recent call last): > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in > > get_response > > 77. response = callback(request, *callback_args, **callback_kwargs) > > File "C:\Python25\lib\site-packages\django\contrib\admin\views > > \decorators.py" in _checklogin > > 55. return view_func(request, *args, **kwargs) > > File "C:\Python25\lib\site-packages\django\views\decorators\cache.py" > > in _wrapped_view_func > > 39. response = view_func(request, *args, **kwargs) > > File "C:\Python25\lib\site-packages\django\contrib\admin\views > > \main.py" in add_stage > > 254. new_object = manipulator.save(new_data) > > File "C:\Python25\lib\site-packages\django\db\models\manipulators.py" > > in save > > 108. new_object.save() > > File "C:\Python25\lib\site-packages\django\db\models\base.py" in save > > 238. ','.join(placeholders)), db_values) > > File "C:\Python25\lib\site-packages\django\db\backends\util.py" in > > execute > > 12. return self.cursor.execute(sql, params) > > File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute > > 166. self.errorhandler(self, exc, value) > > File "C:\Python25\lib\site-packages\MySQLdb\connections.py" in > > defaulterrorhandler > > 35. raise errorclass, errorvalue > > > OperationalError at /admin/football/team/add/ > > (1093, "You can't specify target table 'football_team' for update in > > FROM clause") > > > which appears to stem from this SELECT statement: > > > "INSERT INTO `football_team` > > (`school_id`,`season_start_date`,`division_id`,`coach_first`,`coach_last`,`coach_email`,`coach_phone`,`team_picture`,`_order`) > VALUES > > > ('2','2005-09-10','2','','','','','',(SELECT COUNT(*) FROM > > `football_team` WHERE `school_id` = '2'))" > > > This error disappears if I remove the Meta class. So what am I doing > > wrong when I include it? > > > Thanks, > > charles > > You are probably using MySQL. It is a known problem and even if that > did work, there currently isn't any admin interface to work it yet. > That will be a fix of the newforms-admin branch. > > Tickets: > > http://code.djangoproject.com/ticket/1760 > andhttp://code.djangoproject.com/ticket/2137 > > -- > Brian Rosnerhttp://www.brosner.com/blog --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---