On Jun 5, 8:42 am, Wim Feijen <wimfei...@gmail.com> wrote:
> Hello,
>
> python manage.py syncdb failed for me, saying: there is no such table
> auth_group. On closer examination, the error stack mentioned one of my
> models: timewriting.
>
> After commenting 5 lines of code: tada... syncdb worked!
>
> However, I do not understand, and I am interested in: why ?
>
> Wim
>
> -----
> My code (problematic lines are commented):
>
> from datetime import datetime, date
>
> from django.db import models
> from django.db.models import Q
> from django.contrib.auth.models import User, Group
> from django.conf import settings
>
> if hasattr(settings, 'TIMEWRITING_MINUTES_LIST'):
>     MINUTES_LIST = settings.TIMEWRITING_MINUTES_LIST
> else:
>     MINUTES_LIST = (
>         (0, '0'),
>         (15, '15'),
>         (30, '30'),
>         (45, '45'),
>     )
>
> HOURS_LIST = [(item, unicode(item)) for item in xrange(0, 24)]
>
> PROJECT_TYPE_LIST = (
>     ('project', 'Project'),
>     ('leave', 'Verlof'),
>     ('illness', 'Ziekte'),
> )
>
> # TIMEWRITING_GROUP_ID = 5
> # TIMEWRITING_GROUP = Group.objects.get(id=TIMEWRITING_GROUP_ID)
>
> def format_hours(hours, minutes):
>     return '%d:%02d' % (hours, minutes)
>
> def format_minutes(minutes):
>     hours = minutes // 60
>     minutes = minutes % 60
>     return format_hours(hours, minutes)
>
> # def get_timewriting_users():
> #    return User.objects.filter(is_active=True,
> groups__id=TIMEWRITING_GROUP_ID).exclude(username='estrate')

This looks like a circular dependency error. The call to
Group.objects.get is at module level, so it is executed when the
module is first imported. Since you haven't run syncdb successfully
yet, at the point when that line is executed, the group table doesn't
exist.

I would suggest moving that call into a function, but it looks like
you're not using it at all, so I would leave it out.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to