Tuesday, March 1, 2011

Re: eval if an object meets with a queryset.

On Tue, Mar 1, 2011 at 1:46 PM, Masklinn <masklinn@masklinn.net> wrote:
> On 2011-03-01, at 13:18 , Marc Aymerich wrote:
>>
>> Hi Masklinn, I never use jquey's :(
> Not a problem. The .is method simply takes a CSS selector and returns a boolean flag indicating whether the selected object(s) match the selector: $('a').is('a') is trivially going to return `true` for instance.
>
>> My idea is that the end user can define their own arbitrary expression
>> in order to match a subset of objects from a particular class. For
>> example this is the class that handle the expression.
>>
>> class Service(models.Model):
>>    content_type = models.ForeignKey(ContentType)
>>    expression = models.CharField(max_length=255)
>>    price = models.PositiveIntegerField()
>>
>> So, with this class the admin of my application can say: Active .ORG
>> domains costs 10€ , active .ES and .NET domains costs 25€ …
> But for that you should be able to use regular filters no? Build the right filtering kwargs (or a series of Q objects if you need arbitrary complexity, probably) from the stuff provided by the user and then call `filter` with that, and you should get the correct result shouldn't you?
>

Hi,
what I want is a method for Service class that, given an object,
return their price. As far as I know I can't evaluate a queryset
against an object. Isn't it?

--
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.

No comments:

Post a Comment