For the following models:
class Price:
cad = models.DecimalField(max_digits=8, decimal_places=2)
usd = models.DecimalField(max_digits=8, decimal_places=2)
class Product:
name = models.CharField(max_length=255)
price = models.ForeignKey(Price)
For each product, it's related to one and only one Price object which will contain either a Canadian or US dollar value. Is the above the proper way of doing setting that relationship? Here are some sample data:
Shirt, $100 US, $120 CAD
Book, $20 US, $25 CAD
I also want to input the above information from the admin so that interface will be similar to the following:
Add a Product:
- name:
- CAD:
- USD:
I can more or less do the above with the following code:
class ProductInline(admin.StackedInline):
model = Product
class PriceAdmin(admin.ModelAdmin):
inlines = [
ProductInline,
]
Am I doing it the proper way?