On Fri, Apr 4, 2008 at 1:19 PM, AJ <[EMAIL PROTECTED]> wrote:

>
> What would be the proper way to make sure the code is run each time
> the manager is called?  Here's a example of how I have my code
> currently setup:
>
> //models.py
> from django.db import connection, models
>
> class ColorManager(models.Manager):
>  def custom_query(self):
>    cursor = connection.cursor()
>    query = """SOME QUERY HERE""
>    cursor.execute(query)
>    return [row[0] for row in cursor.fetchall()]
>
> class Color(models.Model):
>  color=models.CharField()
>  objects=ColorManager()
>
> //vews.py
> from app.models import Color
>
> def some_view(request):
>  colors = Color.objects.custom_query()
>  return render_to_response('page.html', {'colors' : colors})
>
>
> Is this not the proper way to setup the code so that the manager's
> custom_query get's run every time it is called?
>

No, it's correct, the way it is written here the query will get executed
each time the view calls custom_query().  So, is the view being called?
Perhaps caching is interfering with the view returning current information?

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to