If you think this is going to take a LONG time to process, risking the browser timing out, then a far more complex but reliable route is:
- DO create a model for your file uploads. All the process does is accept the upload and stick it in a file.
- Create a background process (cron job, etc) that reads in any uploaded files and does the processing, then deletes or marks the file as "processed"
- On error, you can stick a error message in a "processing_errors" TextField, for example.
Downside is that the uploader will not immediately be notified of a successful processsing
YOu could decide to process "in the background" if the file exceeds a certain size.
You could also decide to record who uploaded the file, then on completion or error, email the user with the appropriate message.
On Monday, December 3, 2012 7:32:18 PM UTC-8, MNG1138 wrote:
Say I've got a model like this:class Product(models.Model):class ProductItem(models.Model):name = models.CharField(max_length=200) product = models.ForeignKey(Product)serialnumber = models.charField()sold = models.BooleanField(default=False) ProductItem represents physical products in the store. I have a file with thousands of serial #'s for the product. In the product form in the admin, I'd like to upload this file, parse the serial #'s and create rows in ProductItem. I could add a FileField to Product and create a custom storage that parses the file and creates ProductITems. Or I could override save for the Product model. Both of these solutions are non-optimal, as I will have a FileField in Product and db that I don't need.Is there any way to add a 'dummy' FileField just for the form that doesn't result in a DB row? Or is the answer to create a custom admin form? Any good tutorials or examples for doing creating a custom admin form?Thanks,Mark
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sTYlMiJ0OaYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment