If you're using Django 1.2 or higher you can take advantage of the
multi-database support by adding the 'using' kwarg to your model.save().
This will allow you to ensure that the model saves successfully (is
valid) in the 'holding' database, and move it to your 'live' database later.
You could add a field to the model indicating whether it's 'live' or
'pending,' load all the temp models as pending, then just flip the flag
as each one is "approved." That would front-load all the processing.
You can use a ModelForm to accept the CSV data (preferably in dict form,
from csv.DictReader) to validate the data, then just check for
is_valid() without saving anything to the database. You could then store
those dictionaries somewhere (such as MongoDB) for retrieval when you
actually want to save them to the database.
Each of these options has different advantages. I don't know about
performance. In any case, you may have to use asynchronous processing
(via ZeroMQ or django-celery) so the page can refresh before you Web
server's timeout.
Use whichever seems best for your needs, and maybe someone else has
another option. I'd prefer option #3, because it keeps all the temporary
data out of your production database and makes good use of the
validation properties of the ModelForm class.
--
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.