Your problem is here:

def category_entry(request, category):
        entries_in_cat = Entry.objects.filter(entry_cat=category)
        return render_to_response('blog/index.html', locals())

Remember, the value of "category" is a string.  One way or another you
need adjust the filter.  Something like this should do the trick.

entries_in_cat = Entry.objects.filter(entry_cat__name=category)

-or-

thecat = Category.objects.get(cat_name=category)
entries_in_cat = Entry.objects.filter(entry_cat=thecat)

I prefer the first...

HTH

Keith

On Aug 27, 7:45 pm, djandrow <[EMAIL PROTECTED]> wrote:
> I'm trying to create a situation where you can bring up all the blog
> entries in a category through the URL. I've got this in my urls.py:
>
> from django.conf.urls.defaults import *
> from akonline.views import current_datetime
>
> urlpatterns = patterns('',
>
>     (r'^test/$', 'address.blog.views.blog'),
>     (r'^blog/(?P<category>\w+)/$',
> 'address.blog.views.category_entry'),
> )
>
> -------------------------------------------------------------------------------------------------------------
>
> then this is the category_entry in my views:
>
> def category_entry(request, category):
>         entries_in_cat = Entry.objects.filter(entry_cat=category)
>         return render_to_response('blog/index.html', locals())
>
> -------------------------------------------------------------------------------------------------------------
>
> then this is my pretty simple template:
>
> <html><body>
> {% for object in entries_in_cat %}
> {{ object.entry_title }}<br /
> {% endfor %}
> </body></html>
>
> -------------------------------------------------------------------------------------------------------------
>
> then these models:
>
> from django.db import models
>
> class Category(models.Model):
>         cat_id = models.AutoField(primary_key=True)
>         cat_name = models.CharField(max_length=20)
>         cat_desc = models.CharField(max_length=200)
>
>         def __unicode__(self):
>                 return self.cat_name
>
> class Entry(models.Model):
>
>         entry_id = models.AutoField(primary_key=True)
>         entry_date = models.DateField(auto_now_add=True)
>         entry_title = models.CharField(max_length=70)
>         entry_content = models.TextField(max_length=5000)
>         entry_cat = models.ManyToManyField(Category)
>
>         def __unicode__(self):
>                 return self.entry_title
>
> -------------------------------------------------------------------------------------------------------------
>
> I don't get an error, its just it returns a blank page, so i'd guess
> either category isn't being read in correctly or the filter statement
> is incorrect. I'd appericiate any help
>
> Thanks,
>
> Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to