March 2020
Intermediate to advanced
608 pages
17h 17m
English
To set up sortable product photos, we'll need to modify the model administration for the products app. Let's get started:
# myproject/apps/products/admin.pyfrom django.contrib import adminfrom django.template.loader import render_to_stringfrom django.utils.html import mark_safefrom django.utils.translation import ugettext_lazy as _from ordered_model.admin import OrderedTabularInline, OrderedInlineModelAdminMixinfrom .models import Product, ProductPhotoclass ProductPhotoInline(OrderedTabularInline): model = ProductPhoto extra = 0 fields = ("photo_preview", "photo", "order", "move_up_down_links") readonly_fields = ("photo_preview", "order", "move_up_down_links")
Read now
Unlock full access