Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created October 20, 2021 07:35
Show Gist options
  • Save skolo-online/9d2989bdf6753ace1501c34d83b946f0 to your computer and use it in GitHub Desktop.
Save skolo-online/9d2989bdf6753ace1501c34d83b946f0 to your computer and use it in GitHub Desktop.
Image Category View
def categoryPage(request, slug):
category = Category.objects.get(slug=slug)
images = Image.objects.filter(category=category).order_by('-date_created')[:6]
for x in images:
x.shortDescription = x.description[:130]
context = {}
context['images'] = images
context['category'] = category
return render(request, 'main/category.html', context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment