not sure I'm understanding how get_absolute_url to work.
in my model I created this
class State(models.Model):
name = models.CharField(max_length=80)
slug = models.CharField(max_length=80)
def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/state/%s/" % self.slug
and my template looks like this:
{%block content %}
<ul>
{% for state in state_list %}
<li><a href ="{{state.get_absolute_url }}">{{ state.name }}</a></li>
{% endfor %}
</ul>
{% endblock %}
seems like this would work. But I get an empty page with nothing
unless I drop the "state.name" and just go with state. Then I get an
empty string for the url. I'm not understanding the docs on how to do
this. Can anyone point me to a good example of how this should work.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---