I am trying to create an application to help some classmates and myself team
up on journal article reviewing. I have everything working nicely except
being able to create a slug from the title of the journal article and then
using it in urls.py and creating links in templates. The application is
called journal_review. Journal_review.models has a class called Review and
in it I have...

class Review(models.Model):
     ....
     slug = models.CharField(max_length=60)
     .....


and then in journal_review.admin I have ...

class ReviewAdmin(admin.ModelAdmin):
    ...
    prepopulated_fields = {'slug': ('title',) }
admin.site.register(Review, ReviewAdmin)

Then in a template I want to do something like...
   {% for review in latest_review_list %}
    <li> {{review.pub_date.ctime}}|
         <a href={{review.link}} > {{ review.title }} </a>|
      {{ review.review }} |
          {{ review.username}} |
         * {{ review.slug }} *|
      {% if review.tags %}
         {% for tag in review.tags %}
            {{tag}}
         {% endfor %}
      {% endif %}
    </li>
    {% endfor %}

In the above, review.link is a method of journal_review.models.Review and it
looks like this ...

    def link(self,obj):
        return self.get_absolute_url()+self.slug

I don't think that any slugs are being generated because {{ review.slug }}
renders as a blank line and {{ review.link }} renders as the current page.

My urls.py for this is....
    (r'^journal_review/$','testproject.journal_review.views.index'),
    (r'^journal_review/(?P<review_slug>[a-zA-Z0-9_.-]+)/$',
'testproject.journal_review.views.detail'),

Excuse my ignorance as I am fairly new to django and I appreciate any help
or direction.
Thanks,
Bill

P.S. I am using Django 1.0

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to