views:

45

answers:

2

Hi all!

I have a page with some years. I want to click over the year, for instance 2000, to see all the information.
What I have in urls is this:

url(r'^browse/time/(\d{4})/$', 'TBDBsite.tb.views.data_time', name="yr"),  

In models:

@permalink  
def get_absolute_url(self):  
return('year', [str(self.date.year)])  

And in the template:

{% for y in yr %}
   <li><a href="{{ y.get_absolute_url }}"><p> {{ y }}</p></a></li>
{% endfor %}  

When I print {{ yr }} I see a list with the years but the url doesn't work.

Anyone has any idea how to solve this?
Thanks :)

A: 

In the urlconf you've used the name yr, but in the permalink you've used year. Use the same name in both places.

Daniel Roseman
sorry, I've been playing around trying to figure out..it's changed but doesn't work..
Pat
More information needed, then. What does 'doesn't work' mean? Do you get an error? What is actually output in the HTML source in the href? What are `y` and `yr` in the context?
Daniel Roseman
Sorry..I don't get any error but when I try to click on 2000(example) nothing happen, so something is wrong.yr is a list with all the years. I have the years displayed but not the link..I'm still new in django, so sorry if it is something silly..
Pat
I've another permalink in the same model, used in different views and with different names. I went to check the other and now it doesn't work, I mean before the link was correct and now in the other view I get what I wanted in this.. Is there another way to distinguish between these two? So that it work
Pat
A: 

So instead of using the get_absolute_url I put the path in the href, like this:

<a href="/path/{{ y }}"> 

where y is the year.

Pat