SHOW:
|
|
- or go back to the newest paste.
1 | """ | |
2 | Error | |
3 | Django Version: 1.6 | |
4 | Exception Type: TypeError | |
5 | Exception Value: | |
6 | cannot concatenate 'str' and 'QuerySet' objects | |
7 | """ | |
8 | #models.py | |
9 | class Service(models.Model): | |
10 | service_name = models.CharField(max_length="250") | |
11 | service_port = models.IntegerField(max_length="200") | |
12 | box = models.ForeignKey(Box) | |
13 | ||
14 | class Meta: | |
15 | verbose_name_plural="services" | |
16 | ||
17 | def __unicode__(self): | |
18 | return self.service_name | |
19 | ||
20 | #views.py | |
21 | ||
22 | def get_box_services(request): | |
23 | box_id = request.GET.get("box_id", "") | |
24 | box_services = Service.objects.filter(box_id=box_id) | |
25 | render_to_response("box_services.html", | |
26 | {"box_services":box_services}) | |
27 | ||
28 | ||
29 | #template | |
30 | <table border="0" cellspacing="5" cellpadding="5"> | |
31 | <tr> | |
32 | <th>Service Name</th><th>Port</th><th>Options</th> | |
33 | </tr> | |
34 | {% for box_service in box_services %} | |
35 | <tr> | |
36 | <td>{{box_service.service_name}}</td> | |
37 | <td>{{box_service.service_port}}</td> | |
38 | <td>Start|Stop|Restart</td> | |
39 | </tr> | |
40 | {% endfor %} | |
41 | </table> |