I'm building a form dynamically in a web app where I'm using product_id to keep track which product I'm reading and then product_<id>_property to grab the value of it. Then in my view I end up with this:for product_id in request.POST.getlist('product_id'):    ProductPlacement.objects.create(        product = Product.objects.get(id=product_id),        board = board,        x = request.POST.get('product_{0}_x'.format(product_id)),        y = request.POST.get('product_{0}_y'.format(product_id)),        width = request.POST.get('product_{0}_width'.format(product_id)),        height = request.POST.get('product_{0}_height'.format(product_id)),        rotation = request.POST.get('product_{0}_rotation'.format(product_id)),        z = 0    )It's not very pretty, is there a nicer more readable way of doing it?
Building and getting a form of objects that have multiple properties
python;html;django
Your code is quite ok and I have no idea how to improve this particular piece. You have used several identical forms and processed it manually. Django have formsets for this purpose. Why don't you use them?Then I don't see validation in your code. What happens when product_0_width contains not-numeric or empty value? Formsets would solve this problem.