> Hi!,
> I have a model class like this one:
>
> class Domain(models.Model):
> active = models.BooleanField()
> root = models.CharField(max_length=6)
>
> now given a Domain instance I need to know if it meets with an
> expresion like this one:
>
> active=True and (root='com' or root='net')
>
> one way to do that is get all domains that meets the expresion
> (formated as queryset) and check if the object is one of them.
> But maybe there is a more direct way to check it?
You can use filter's with get so:
Try:
myDomain = Domain.objects.get(active=True, etc...)
except myDomain.DoesNotExist:
myDomain = None
Kinda like that ish.
HTH
Dan
>
> Thanks!
> --
> Marc
>
> --
> 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.
>
>
--
Dan Hilton
============================
www.twitter.com/danhilton
www.DanHilton.co.uk
============================
--
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