Consider the following situation. An Order and OrderLine model, one Order can have multiple OrderLines against it. An order line contains a part number and quantity. This data can enter the system in two ways - by a normal model admin form and also through a batch process importing order data from edi files.
For the sake of this example I shall say there is one rule - which is that all the quantities on order lines must add up to 5. If the user is entering the data through the admin, we do not allow for an order to be saved unless the total quantity is five. For data coming in through EDI we allow for the data to be saved and a status field is marked to show the order is not valid. If I code this validation rule on the form then my model has no access to that rule and I can't use it for edi processing. If I code this rule into the model, my model only knows about what is written already to the database. If I change my order lines in admin to add up to 6 my model won't know about those lines until they're written to the database. So I am left with the idea that I have to put my validation rules in a third place - where both my admin forms and models can access them. My solution is to have this code expecting to be passed an instance of a model so I have written code for the admin side that constructs temporary model instances from submitted forms for this purpose. This (so far) seems to work but the whole solution feels a little clunky Does anybody else have to deal with this issue or have any suggestions for alternative ways of dealing with it? Ian -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.