-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan Sagalaev schrieb:
> Paul Rauch wrote:
>> Template:
>> {% url cvh.view.login %}
> 
> Here you have "view".
> 
>> urlpatterns = patterns('mysite.cvh.views',
>>  (r'^$','index'),
>>  (r'^login/$','login'),
>> )
> 
> And here you have "views". {% url %} doesn't find your pattern and 
> returns '' (empty string) that browser translates to a current URL.
> 
> {% url cvh.views.login %} should do.
> 

ok, this works.

but now I try to make it dynamic and stored the linkinfo to the database..

models.py:

class navigation(models.Model):
 name = models.CharField(maxlength=30)
 link = models.CharField(maxlength=30)
 def __str__(self):
  return self.name

views.py:

# Create your views here.
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response,get_object_or_404
from django.conf import settings

from mysite.cvh.models import group,navigation

media_root = settings.MEDIA_URL
navi_list = navigation.objects.all()


def index(request):
 return render_to_response('cvh/index.html',
 {
  'media_root' : media_root,
  'navi_list'  : navi_list,
 })

def login(request):
 return render_to_response('cvh/login.html',
 {
  'media_root' : media_root,
  'navi_list'  : navi_list,
 })

template:
<div class="navi">
  {% block navi %}
  <ul>
  {% if navi_list %}
  {% for elem in navi_list %}
   <li><a href="{% url {{elem.link}} %}">{{elem.name}}</a></li>
   <!--{{elem.link}}-->
  {% endfor %}
  {% else %}
   <li><a href="{% url cvh.views.index %}">Index</a></li>
   <li><a href="{% url cvh.views.login %}">Login</a></li>
  {% endif %}
  </ul>
  {% endblock%}
 </div>


The static ELSE statement works. But the database ones don't..
They contain exactly the same content.
the html-output:
 <div class="navi">
  <ul>
   <li><a href="">Index</a></li>
   <!--cvh.views.index-->
   <li><a href="">Login</a></li>
   <!--cvh.views.login-->
  </ul>
 </div>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iQIVAwUBRf/wehG67lyyQrltAQK57w//Th1K/16zXWT1htMwfdNSmISfCNGN8zYT
NrcsU71ZH5cFBIaRLLICcHggFk9DkafZ2O/hnU9wfQzxd2O7/MKeJxGLGCtnytxm
gCj9KKtx3ia0wu6GTV1+oXb/ebrU+u27gT205yZzHh5PIPkuhkyLx309/eVqhQgt
oLSRito+nszyQi3VKUxiKqRfJvhkNEeyH+Vc4BRFZGHOmVdSezoSoPzdwP99kVGh
IFSR+NlZrrqJPuBrApiXo/ervXkocVXR51yDgnnnovuC2J6rF0ErQ3lHo0C5Wz0X
Gug1R0G4crrkVIsNsI7UZ/YoHhuIUTgl21pg0b2SmfAbMBaxPT0qn+iTRKaw7oM/
/IDHrd2Q0aVLdtrSa5CqwMEUKHxXhRq0ixtylNLD96oizt+dNCUN4aagHAII1gUQ
AwNt4mwBlUMsj1yUCkLqpuca13wXW8PnVHYIFSakNL0AjTZM1lf/EREGyMNzz0CS
TKADQ8g8J54V7cPrfDtIWeQDX+myHT0eWXxM9DTBFC+6jXwxgE4xyRWVpO4VWyIq
EVebzgXvPeXqeK2fJT8wiQ/jbUBoIVHW67886edJ6cDAEAal6g9OvdXxYT7zcOFV
1YAXqoZJ3vzQ7KRxp66d4xA8mwsAlIKNz2mF1qyIC4ADKM5VKmoTVk4lRuzmRNs7
QI8NQFe8Lrw=
=YWXD
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to