Re: Global filtering of the querystes

2013-01-22 Thread akaariai
On 22 tammi, 08:32, Jani Tiainen  wrote:
> Hi,
>
> I've several models that share same attribute and form doing ajax
> queries to/from form in a browser window.
>
> For example owner:
>
> class MyClass(models.Model):
>      title = models.TextField(max_length=100)
>      owner = models.TextField(max_length=100)
>
> class MyOtherClass(models.Model):
>      title = models.TextField(max_length=100)
>      value = models.IntegerField()
>      owner = models.TextField(max_length=100)
>
> And so on.
>
> Now I would like to user have option in browser to filter any query
> based on model that has "owner" property to be filtered by owner.
>
> What is the best way to doit?
>
> I only could come up with threadlocals and special manager that can be
> fed with global filtering rules.

I think your solution is fine (even if it is uqly).

You could also try to avoid threadlocals and pass the data in
parameters. Sill, if you want you can likely play with DB views and do
the filtering in there using some session parameters and views. Other
than that I can't think of any obvious way to achieve what you want.

 - Anssi

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



Global filtering of the querystes

2013-01-21 Thread Jani Tiainen

Hi,

I've several models that share same attribute and form doing ajax 
queries to/from form in a browser window.


For example owner:

class MyClass(models.Model):
title = models.TextField(max_length=100)
owner = models.TextField(max_length=100)

class MyOtherClass(models.Model):
title = models.TextField(max_length=100)
value = models.IntegerField()
owner = models.TextField(max_length=100)

And so on.

Now I would like to user have option in browser to filter any query 
based on model that has "owner" property to be filtered by owner.


What is the best way to doit?

I only could come up with threadlocals and special manager that can be 
fed with global filtering rules.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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