You should make the view function calculate the sorted list and pass it to the template or create a template tag that accepts your call
2011/4/29 Krish <krishna.sunuwar@gmail.com>
This code works perfectly,
{% for talk_child in talk.child.all %}
{{talk_child.text}} {{talk_child.created_dt}}
{% endfor %}
Now, I want to sort all child based on created_dt ASC (something like
below), but it doesn't work. How can I get this right?
{% for talk_child in talk.child.order_by 'created_dt' %}
{{talk_child.text}} {{talk_child.created_dt}}
{% endfor %}
Below is my class
class Talk(models.Model):
user = models.ForeignKey(User)
destination = models.ForeignKey(Destination)
text = models.TextField()
type = models.CharField(max_length=30)
sup = models.ForeignKey('self', blank=True, null=True,
related_name='child')
created_dt = models.DateTimeField(auto_now_add=True)
thumb_up = models.IntegerField()
thumb_down = models.IntegerField()
class Meta:
ordering = ["-created_dt"]
--
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.
--
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