Thursday, December 1, 2011

models.Q raising exception

Hello,

why this is not working?

from django.db import models

...
GameProfile.objects.get(
models.Q(nick=nick) | models.Q(user=self.user),
world=self.world,
)

but this is working?

from django.db.models import Q

...
GameProfile.objects.get(
Q(nick=nick) | Q(user=self.user),
world=self.world,
)

I get "'module' object has no attribute 'Q'" exception. But in another
file I have:

from django.db import transaction, models
...
context['incoming_armies'] = MovingArmy.objects.filter(
models.Q(
target_base=active_base,
returning=False
) | models.Q(
game_base=active_base
)
).order_by('end_time')

and here is everything ok.

Thanks,
Martin

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment