0

I would like to put NEXT & PREV links to my detail page to get easily to Previous or Next item. I dont want to do it with DATE or ID, because it is totally impractical.

I dont want to use:

Model.get_next_by_FOO(**kwargs)
Model.get_previous_by_FOO(**kwargs)

How can I setup a column with for example numbers and sort by that. If I do integers it will sort like:

1 12 13 14 2 21 24 3 etc....doesnt work either.

What would be the simplest way for the user in CMS specify order and it will sort it and then I can use the NEXT and PREV.

models.py

class Art(models.Model):
    pub_date = models.DateTimeField('date published')
    title = models.CharField(max_length=200)
    title_url = models.SlugField(max_length=200)
    image = models.ImageField(blank=True, null=True, upload_to='uploaded_images')
    graphics = models.ImageField(upload_to='images/art/',blank=True)
    def image_thumbnail(self):
        return '<a href="/media/%s" target="_blank"><img width="160px" src="/media/%s"/></a>' % (self.graphics, self.graphics)
    image_thumbnail.allow_tags = True
    image_thumbnail.short_description = 'graphics'
    description = models.TextField(blank=True)

    def __unicode__(self):
        return self.title

views.py

def artdetail(request, art_title_url):
    art = Art.objects.all().filter(title_url=art_title_url)

    return render_to_response('nart-detail.html', {'art':art)

How can I on this example make next & prev buttons in the template to get next ot previous object and if I got to the end it will hide the next button etc....

My major concern is to make it proper way maybe by sort (number column) I am thinking wrong, I would like to know the best way how to achieve this that user is happy with easy customization.

karthikr
  • 97,368
  • 26
  • 197
  • 188
Radek
  • 1,149
  • 2
  • 19
  • 40

1 Answers1

0

I hope this will be of some help: http://www.dajaxproject.com/pagination/

Wei Xu
  • 1,629
  • 2
  • 19
  • 31