How to handle the URL
I want to build a gallery which connects to different photo sets.
I have been completed the gallery main page, however, I meet two
problems:
1) Use title name of cover image as the URL of photo page, but if the
name include blank, then The URL is not complete. For example: the
cover image named summer days, however ,only shows summer on the URL.
2)How to build the dynamic URL connecting to each photo sets?
the models as below:
class Item(models.Model):
name = models.CharField(max_length=250)
description = models.TextField()
class Meta:
ordering = ["name"]
def __unicode__(self):
return self.name
def get_cover_photo(self):
if self.photo_set.all().count() > 0:
return self.photo_set.all()[0].image
else:
return None
class Photo(models.Model):
item = models.ForeignKey(Item)
title = models.CharField(max_length=100)
image = models.ImageField(uplo
Thanks!!
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home