Croppic is a jquery plugin which handles uploading and manipulating images via AJAX.
This simple tutorial demonstrates the basics of using Croppic to upload and crop images with Django running on the backend.
The project code can be found on my bitbucket account. It's simple, and between it and the Croppic documentation it should be fairly obvious to see how it's implemented.Two comment's on this that should be made are: There's an issue when using local host (perhaps sqlite3?). After an uploaded image is successfully cropped, the image loaded is the original one at full size. Despite this, the image saved to the database is correct and upon refreshing the page the picture will appear correct. This was not an issue when I moved to production and had Amazon S3 handling the media files. When using S3, a few adjustments needed to be made to app.views.crop_pic . Namely, I had to hard code in the amazon s3 media url 'https://<bucket_name>.s3.amazonaws.com/' because default_storage.base_url didn't work. My solution for this was:
# get the base_url for test database or s3 try: media_url = default_storage.base_url except AttributeError: media_url = 'https://<bucket_name>.s3.amazonaws.com/'
本文开发（python）相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程