Re: two similar ways to show data, but only one working

2011-04-21 Thread Michael
2011/4/22 W Craig Trader  only matches upper and lower case letters.
>
> - Craig -
>

Hi Craig,
Sorry for this confusion, my hostnames only contains letters,
i should have copy/pasted my url instead writing this example...
-> so the problem still exists.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: two similar ways to show data, but only one working

2011-04-21 Thread W Craig Trader

On 04/21/2011 05:08 PM, Michael wrote:

I try to do the same with
http://127.0.0.1:8000/host/hostname1
to print every package that is installed on hostname1


urls.py
---
[...]
 (r'^host/(?P[a-zA-Z]+)$', 'packages.views.host'),
[]



For starters, the pattern you've registered won't match 'hostname1' since it only matches upper and 
lower case letters.


- Craig -

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



two similar ways to show data, but only one working

2011-04-21 Thread Michael
Hi,

I`m new to Django and I`m trying to write an application "packages" that reads 
data
from a mysql-database and prints the installed software for any hostname.

For example:
http://127.0.0.1:8000/package/mutt
prints every host on which the package "mutt" is installed. 
This works without errors.

I try to do the same with 
http://127.0.0.1:8000/host/hostname1
to print every package that is installed on hostname1

However, the only thing i see is the empty template -> the object_list seems to
contain no entries.

I don`t understand this because the two ways to call the functions seems so 
similar.
(see my application below).

What I`m missing here?



models.py
-
class Prog(models.Model):
hostname = models.CharField(max_length=20)
status = models.CharField(max_length=2)
name = models.CharField(max_length=50)
version = models.CharField(max_length=50)
description = models.TextField()
def __unicode__(self):
return self.name

urls.py
---
[...]
(r'^host/(?P[a-zA-Z]+)$', 'packages.views.host'),
(r'^packages/(?P[a-zA-Z0-9_.-]+)$', 'packages.views.package'),
[]

views.py

def host(request, host):
package_list = Dpkg.objects.filter(hostname=host)
return render_to_response('host/detail.html', { 'package_list ' : 
package_list})

def package(request, package):   
package_list = Dpkg.objects.filter(name=package).order_by('-version')
return render_to_response('packages/detail.html', {'package_list': 
package_list})


In both templates is the same code:

{% for package in package_list %}
{{ package.hostname }} {{ package.name }} {{ package.version }}
{% endfor %}


Thanks  :)

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.