In models.py:
class Business(models.Model):
business = models.CharField(max_length=100)
class Service(models.Model):
service = models.CharField(max_length=100)
providers = models.ManyToManyField(Business, through =
"BusinessService")
class BusinessService(models.Model):
business = models.ForeignKey(Business)
service = models.ForeignKey(Service)
In urls.py:
def get_service():
return Service.objects.all()
businessservice_list = {
#'queryset' : BusinessService.objects.all(),
'queryset' : Business.objects.all(),
'extra_context': {'service_list': get_service}
...skip some detail...
(r'^showservice/(?P<object_id>\d+)/$', list_detail.object_detail,
businessservice_list),
In business_detail.html:
{% block content %}
<h2>Business Services</h2>
{% if object %}
<h3>{{ object.business }}</h3>
{{ service_list }}
{% endif %}
{% endblock content%}
def businessshowservice_view(request, business_id):
business = Business.objects.get(pk=business_id)
services = Business.objects.get(pk=business_id).service_set.all()
return object_list(request, queryset=services,
extra_context={'business' : business}
)
(now just have to figure out a way to get my stress back!)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.