django admin - adding fields on the fly
Basically I am writing a simple shopping cart. Each item can have multiple pric开发者_如何学Pythones. (i.e. shirts where each size is priced differently). I would like to have a single price field in my admin panel, where when the first price is entered, an additional price field pops up. However I am kind of at a loss as to how to do this. What would be the best way to do this?
Sounds like you want two related models - Item and Option. Item would contain the name of the item, and Option would contain the option - eg size - and the price of that option. You would then set up your admin to use an inline form for Option.
You probably want inlines and some javascript.
You might try checking out the Satchmo codebase. It has something similar that may provide some inspiration. http://satchmoproject.com
精彩评论