mods to django admin

This commit is contained in:
Sam
2021-03-08 11:10:03 +00:00
parent 44294223ed
commit c25d23548d
3 changed files with 10 additions and 9 deletions

View File

@@ -5,18 +5,19 @@ from . import forms
# Register your models here.
def model_admin_callable(co):
return co.company_name
class ProductAdmin(admin.ModelAdmin):
form = forms.ProductTagForm
list_display = ('name', 'category', 'sourcing_date', 'company')
list_display = ('name', 'category', 'sourcing_date', 'company_name', 'active' )
list_filter = ('company', 'tags', 'category', 'attributes')
search_fields = ('name', 'sku', 'description')
def company_name(self, product):
return product.company.company_name
'''
class ProductInline(admin.TabularInline):
model = models.Product
form = forms.ProductTagForm
'''
admin.site.register(models.Product, ProductAdmin)
admin.site.register(models.TreeTag)

View File

@@ -64,7 +64,7 @@ class Product(models.Model):
category = SingleTagField(to=CategoryTag, null=True, blank=True, on_delete=models.SET_NULL) # main tag category
attributes = TagField(to=AttributeTag, blank=True, related_name='product_attributes')
identifiers = models.TextField('Identificador único de producto', null=True, blank=True)
active = models.BooleanField('Mostrar producto', default=False)
active = models.BooleanField('Activo', default=False)
# internal
created = models.DateTimeField('date of creation', auto_now_add=True)