I'm getting the following error message (see below) when trying to list my products in the Django admin. However I have defined qr_code as you can see.
ImproperlyConfigured at /admin/products/product/ 'ProductAdmin.fieldsets[4][1]['fields']' refers to field 'qr_code' that is missing from the form.
models.py
class Product(models.Model):
title = models.CharField(max_length=60)
qr_url = models.URLField(blank=True)
qr_image = models.ImageField(
upload_to="public/uploads/",
height_field="qr_image_height",
width_field="qr_image_width",
null=True,
blank=True,
editable=False
)
qr_image_height = models.PositiveIntegerField(null=True, blank=True, editable=False)
qr_image_width = models.PositiveIntegerField(null=True, blank=True, editable=False)
def __unicode__(self):
return self.title
def qr_code(self):
return '' % self.qr_url
qr_code.allow_tags = True
admin.py
from django.contrib import admin
from models import Product
class ProductAdmin(admin.ModelAdmin):
list_display = ['title']
fieldsets = (
(None, {
'fields': ('title', 'description', 'active')
}),
('QR Code', {
'classes': ('collapse',),
'fields': ('qr_url', 'qr_code')
}),
)
admin.site.register(Product, ProductAdmin)