I have attached my model files and template files. Please tell how can i 
find avg of rating for a particular college. In current format it is 
displaying rating of all colleges correctly.
Along with this I also want to add avg ratings for college.
I have used foriegn key in this.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f44b185-b1f1-4e94-8382-f9f81f62de02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import datetime
from django.db import models
from django.utils import timezone
# Create your models here.
class College(models.Model):
	college_text=models.CharField(max_length=200)
	pub_date = models.DateTimeField('date published')
	def __unicode__(self):
		return self.college_text

class Rating(models.Model):
	college=models.ForeignKey(College)
	rating=models.BigIntegerField()
	views=models.CharField(max_length=200)
	def __unicode__(self):
		return self.views

{{college.college_text}}

    {% for rating in college.rating_set.all %}
  • {{rating.rating}}
  • {% endfor %}
{% if latest_college_list %} {% else %}

No polls are available.

{% endif %}

Reply via email to