{
"info": {
"author": "Thorgate",
"author_email": "info@thorgate.eu",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3"
],
"description": "django-upthor\n=============\n\n``django-upthor`` provides a django application for simple ajax file\nuploads. We use https://github.com/blueimp/jQuery-File-Upload for the\nupload functionality.\n\n**Warning:** This isn't close to being a complete app, but it's getting\nthere.\n\nUsage\n=====\n\nStep 1. Install\n---------------\n\n- ``pip install django-upthor``\n\nNow you have two options:\n\n- If you want to encrypt FQ values, install pycrypto.\n ``pip install pycrypto==2.6.1``\n- Or you can, disable FQ encryption by adding\n ``THOR_DISABLE_FQ_ENCRYPT = True`` to your settings file.\n\nStep 2. (Django 1.6+)\n---------------------\n\nAdd 'upthor' to your installed apps in settings.py:\n\n::\n\n INSTALLED_APPS = (\n ...\n \"upthor\",\n )\n\nThen:\n\n::\n\n python manage.py migrate\n\nStep 3. Use it in your app's models.\n------------------------------------\n\n::\n\n\n import os\n import uuid\n\n from django.db import models\n from upthor import fields as thor_fields\n\n\n def random_upload_path(instance, filename):\n # Split the uuid into two parts so that we won't run into subdirectory count limits. First part has 3 hex chars,\n # thus 4k possible values.\n uuid_hex = uuid.uuid4().hex\n return os.path.join(uuid_hex[:3], uuid_hex[3:], filename)\n\n\n def post_example_file_link(real_instance, temporary_instance, raw_file):\n \"\"\"\n A callback called after linking the temporary file with the model.\n\n **Warning**: Don't call instances save method from here, cause it will cause an recursion error.\n\n @:param real_instance An instance of the model the file is attached to\n @:param temporary_instance An instance of TemporaryFileWrapper that the form links to.\n @:param raw_file The raw file that is being uploaded.\n\n @:return bool If True, the uploaded temporary file is removed once the linking is complete.\n \"\"\"\n return True\n\n\n def get_file_image(file_path):\n \"\"\" An optional function that returns the display image html for files after uploading is complete\"\"\"\n\n return ''\n\n\n class ExampleModelWithFile(models.Model):\n name = models.CharField(max_length=50)\n file = thor_fields.ThorFileField(upload_to=random_upload_path,\n allowed_types=['*'], widget=thor_fields.ThorSingleUploadWidget,\n post_link=post_product_file_link,\n get_upload_image=get_file_image)\n\nStep 4. Make sure to include form media.\n----------------------------------------\n\nMake sure you include the media files for the form in your templates:\n\nE.g. Add the following codes where form is the context object of your\nmodelform that uses the uploader fields.\n\n::\n\n {{ form.media.css }}\n\n {{ form.media.js }}\n\nStep 5. Add the upload url to your project urls.\n------------------------------------------------\n\n::\n\n url(r'', include('upthor.urls')),\n\nStep 6. Optional stuff\n----------------------\n\nTemporary file cleanup\n^^^^^^^^^^^^^^^^^^^^^^\n\nIf you want to clean up temporary files automatically, you'll need to\ninstall `django-cron `__ and add\n``upthor.cron.CleanTemporaryFiles`` to your cron classes in settings.\n\nAlternatively to clean up manually you can use the management command\n``clean_temporary_files``.\n\nCustom upload widget template\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou can override ``ThorSingleUploadWidget.render_template`` to return\nyour own widget template instead of the `hardcoded one defined in\nwidgets.py `__. Although the structure (including\nmost classes) has to remain the same, there are a few data attributes on\n``.file-upload`` that you can use to customize behavior:\n\n+----------------------+----------+-------------------------------------------+\n| Data Attribute Name | Type | Description |\n+======================+==========+===========================================+\n| upload-url | string | **Required:** URL to POST temporary files |\n| | | to, defaults to reverse of |\n| | | ``thor-file-upload``. |\n+----------------------+----------+-------------------------------------------+\n| max-size | number | **Required:** Maximum allowed file size |\n| | | in bytes, defaults to |\n| | | ``THOR_MAX_FILE_SIZE``. |\n+----------------------+----------+-------------------------------------------+\n| size-error | string | **Required:** Text to display if the file |\n| | | doesn't meet the size requirements, |\n| | | defaults to |\n| | | ``\"Uploaded file too large\"``. |\n+----------------------+----------+-------------------------------------------+\n| use-background | boolean | Whether or not to use |\n| | | ``background-image`` instead of ``img`` |\n| | | elements, defaults to false. |\n+----------------------+----------+-------------------------------------------+\n\nBackends\n========\n\nCurrently it only supports local file backend, but we plan to add other\nbackends when we reach a stable state.\n\nSettings\n========\n\nThe following settings are customizable using your django project\nsettings file.\n\n**THOR\\_UPLOAD\\_TO**\n\nPath where the upload files will be stored. Defaults to \"temp-files\".\n\n**THOR\\_EXPIRE\\_TIME**\n\nHow long to keep temporary files in the database and on disk. Defaults\nto \"60*60*\\ 24\", e.g. 24 hours.\n\n**THOR\\_LINKED\\_EXPIRE\\_TIME**\n\nHow long to keep linked temporary files in the database and on disk.\nDefaults to \"60*60*\\ 6\", e.g. 6 hours.\n\n**THOR\\_MAX\\_FILE\\_SIZE**\n\nThe max file size of uploaded files. Defaults to \"2*1024*\\ 1024\", e.g. 2\nMB.\n\n**THOR\\_DISABLE\\_FQ\\_ENCRYPT**\n\nDisable the FQ Encryption, if this is False you need to install pycrypto\nsince that is used for encryption. Defaults to \"False\".\n\n**THOR\\_ENABLE\\_ADMIN**\n\nShould TemporaryFileWrapper model be shown in the admin interface.\nDefaults to \"True\".\n\n\n",
"description_content_type": null,
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/thorgate/django-upthor",
"keywords": "",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "django-upthor",
"package_url": "https://pypi.org/project/django-upthor/",
"platform": "",
"project_url": "https://pypi.org/project/django-upthor/",
"project_urls": {
"Homepage": "https://github.com/thorgate/django-upthor"
},
"release_url": "https://pypi.org/project/django-upthor/0.9.1/",
"requires_dist": [
"Django",
"Pillow"
],
"requires_python": "",
"summary": "django-upthor provides a django application for simple ajax file uploads.",
"version": "0.9.1"
},
"last_serial": 2397017,
"releases": {
"0.9": [],
"0.9.1": [
{
"comment_text": "",
"digests": {
"md5": "e3e1d2a7948427c490ec6c60f362c97a",
"sha256": "4af412edf5366ac96942cbf8a3be16016c5ed637d82f1c9e3c77fa0f215d7d29"
},
"downloads": -1,
"filename": "django_upthor-0.9.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3e1d2a7948427c490ec6c60f362c97a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 424023,
"upload_time": "2016-10-13T11:38:02",
"url": "https://files.pythonhosted.org/packages/63/41/9f88c779b7c80a19a959b962d5670cce4392d2883c452dc3ba6a2901685c/django_upthor-0.9.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "a786ab26be1ae9574cba33ef20bb52b3",
"sha256": "4e0201fada52e086377392fc6b441072370fcce830de3566c31d523793d8580a"
},
"downloads": -1,
"filename": "django-upthor-0.9.1.tar.gz",
"has_sig": false,
"md5_digest": "a786ab26be1ae9574cba33ef20bb52b3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14700,
"upload_time": "2016-10-13T11:38:06",
"url": "https://files.pythonhosted.org/packages/1e/39/59ab3a3374379054666c4cdc7dc7dba129395c33fff3f7a536abf49bb547/django-upthor-0.9.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "e3e1d2a7948427c490ec6c60f362c97a",
"sha256": "4af412edf5366ac96942cbf8a3be16016c5ed637d82f1c9e3c77fa0f215d7d29"
},
"downloads": -1,
"filename": "django_upthor-0.9.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3e1d2a7948427c490ec6c60f362c97a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 424023,
"upload_time": "2016-10-13T11:38:02",
"url": "https://files.pythonhosted.org/packages/63/41/9f88c779b7c80a19a959b962d5670cce4392d2883c452dc3ba6a2901685c/django_upthor-0.9.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "a786ab26be1ae9574cba33ef20bb52b3",
"sha256": "4e0201fada52e086377392fc6b441072370fcce830de3566c31d523793d8580a"
},
"downloads": -1,
"filename": "django-upthor-0.9.1.tar.gz",
"has_sig": false,
"md5_digest": "a786ab26be1ae9574cba33ef20bb52b3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14700,
"upload_time": "2016-10-13T11:38:06",
"url": "https://files.pythonhosted.org/packages/1e/39/59ab3a3374379054666c4cdc7dc7dba129395c33fff3f7a536abf49bb547/django-upthor-0.9.1.tar.gz"
}
]
}