On 03/01/11 03:53, Kyle wrote:
When I try to access my Object, I get an error "invalid literal for
int() with base 10". I know it has something to do with ForeignKeys,
but cannot find how to fix it.
It helps if you post the full stack of the error - we can tell which
line of code it came from then. However,
def artist(request, myartist):
myArgs = Song.objects.all().filter(artist=myartist)
return render_to_response('music/index.html', {'artist': myArgs})
I think this is your problem. What are you passing in on the url for
myartist? Is it a slug?
Song.objects.all().filter(artist=myartist)
is expecting myartist to be an Artist instance. Try
Song.objects.all().filter(artist__slug=myartist)
(that's two underscores between artist and slug.)
This says "Select me all the songs where the related Artist's slug is
whatever was passed in on the url"
Hope that helps,
Tim.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@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.