Hi there!

I am thinking about the best way of presenting some data from a proxy
model.

I have some model classes let's say: http://bpaste.net/show/3338/
and a view:
def proxy_view(request, year, month, day):
     qs = ExModel.objects.all()
     # maybe some stuff here with `some_logic` method
     # some extending qs maybe??? (but how?)
     return render(request, ...)

what i'm struggling is when i want to display my objects in a template
I don't know how to nicely gain access to proxy model data
(`some_logic` value with appropriate `date` param build with `year`,
`month` and `day`):
<table>
{% for object in qs %}
    <tr>
       <td>{{ object.name }}</td>
       <td>{{ object.some_attr }}</td>
       <td>{#{ what now? how to display some_logic value? }#} </td>
    </tr>
{% endfor %}
</table>

My first solutions are:
1) build a template tag which will take object, date and method_string
(`some_logic) as a param and then invoke the some_logic method with
date param and return appropriate value.
2) somehow (i dont know how) extend each object of qs in a view (like
an annotate method maybe?) and then just pass modified qs to the
template and then simply display values

Any suggestions ?

Thanks in advance.

SÅ‚awek

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to