I have a model:
class Inventory(models.Model):
title = models.CharField(max_length=100, db_index=True)
product_code = models.CharField(max_length=100, db_index=True)
slug = models.SlugField(max_length=100, db_index=True)
description = models.TextField()
cost_ea = models.DecimalField(max_digits=6, decimal_places=2)
cost_ws = models.DecimalField(max_digits=6, decimal_places=2)
quantity = models.IntegerField()
main_image = models.ImageField(upload_to = 'inventory/images/main/', null = True, blank = True)
thumb_image = models.ImageField(upload_to = 'inventory/images/thumbs/', null = True, blank = True)
product_category = models.ForeignKey('inventory.Product_Type')
card_category = models.ForeignKey('inventory.Card_Type')
last_modified = models.DateTimeField(auto_now = True, auto_now_add = True, null = True, blank = True, editable = True)
created = models.DateTimeField(auto_now_add = True, null = True, blank = True, editable = True, default = datetime.datetime.now())
in_stock = models.BooleanField(default = False)
I’d like create a form field something like this (it will be on an intermediate page of an admin action):
form.ChoiceField(choices=Inventory.get_all_verbose_names)
Is there a function that exists to get all verbose names from a model? and if not, how can I go about doing this?
You could try something like