I want to display all the services for a particular business using the
generic view "object_detail". What I would like to do is pass the
value of an id from the url to the queryset (into object_id) in
urls.py - or a better way to do this using the "object_detail" generic
view.

models.py:
class BusinessService(models.Model):
  business = models.ForeignKey(Business)
  service = models.ForeignKey(Service)

urls.py:
businessservice_list = {
    'queryset' : BusinessService.objects.filter(
                     business=object_id),
}
...skip some detail...
(r'^showservice/(?P<object_id>\d+)/$', list_detail.object_detail,
businessservice_list),

businessservice_detail.html:
{% extends "portal/base.html" %}
{% block pagename %}Business Services{% endblock pagename %}
{% block content %}
    <h2>Business Services</h2>
                <h3>{{ businessservice.business }}</h3>
                <ul>
                        {% for business in object_list %}
                <li>{{ businessservice.service }}</li>
                        {% endfor %}
                </ul>
{% endblock content%}

--

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