Sunday, June 24, 2012

Creating permalink for blog tags that have the Post class as foreign key

Hi all, Django newbie here,

I have a simple blog app I am working on and am trying to figure out the best way to create a permalink for tags that I have added for blog posts. Basically, my models.py consists of two classes: Post and Tag, which has Post as a foreign key: http://dpaste.org/Ojhh5/

I am then trying to access the permalink to the tag using: {{ tag.get_absolute_url }} 

This doesn't seem to print anything however. I am basically just replicating the method I used to generate the permalink for the slug field in my Post class. I guess it isn't working since Tag is using post as a foreign key though or something? Being a beginner though, I really have no clue. 

Can explain what I am doing wrong as well as point me in the direction of the correct way to achieve the goal here?

Other relevant code: 
blogapp urls.py: http://dpaste.org/D69gw/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/T_vuAExo9zEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment