I didn't think to check the shell! It is definitely issue 2. I was able to output:
>>> for tag in post.posttag_set.all(): tag.get_absolute_url() ... '/blog/footag/' which is exactly what I expect. (I have one post with the tag "footag") post = get_object_or_404(Post, tag='footag') returns the error: FieldError: Cannot resolve keyword 'tag' into field. Choices are: html, id, posttag, pub_date, slug, title So I tried: post = get_object_or_404(Post, posttag='footag') which returned: ValueError: invalid literal for int() with base 10: 'zzz' I think a lot of my issues are being caused by my ignorance of how I would refer to a Post objects tag since they are only related via foreign key. btw, my templates print the tags perfectly with {% for tag in post.posttag_set.all %} so seeing >>> for tag in post.posttag_set.all(): tag.get_absolute_url() print the tag url exactly came as a surprise to me. On Sunday, June 24, 2012 8:40:25 PM UTC-4, Matthew Meyer wrote: > > 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/ > views.py: http://dpaste.org/Hoku3/ > template: http://dpaste.org/eIXCY/ > -- 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/-/_1ufinwp-TgJ. 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.