Package: django-ewiz
Version:1.5.4Dependencies:Python 3.4+, Django>=1.5, djangotoolbox>=1.6.2, requests>=2.2.0Home page:https://github.com/kavdev/django-ewizAuthor:Alex Kavanaugh <kavanaugh.development@outlook.com>License:GNU LGPL (http://www.gnu.org/licenses/lgpl.html)NOTE:Versions 1.3+ will work with the EnterpriseWizard anti-sql block. In order to achieve this, regular expression and case-insensitive query operations were removed.InstallationRunpip installdjango-ewizAdddjango_ewiztoINSTALLED_APPSINSTALLED_APPS=(...'django_ewiz',...)UsageBasic UsageIn theDATABASESsettings dictionary, simply usedjango_ewizas the ENGINE key.'default':{'ENGINE':'django_ewiz','NAME':'',# The name of the knowlegebase'USER':'',# The name of the user'PASSWORD':'',# The user's password'HOST':'',# EnterpriseWizard's REST base url, generally 'www.example.com/ewws/'. Don't include the protocol string (e.g. 'http://').'PORT':'',# Either 80 or 443 (HTTP or HTTPS requests only)'NUM_CONNECTIONS':'',# Default: 1, Allows multiple concurrent connections to be used when retrieving multiple tickets in a query.},That’s it! All database operations performed will be abstracted and should function as the usual engines do (unless what you wish to do conflicts with the options below).The following query operations are supported:iexacticontainsingtgteltlteistartswithiendswithrangeyearisnullThe following query operations will be converted to their respective case-insensitive forms:(version 1.3+)exactcontainsstartswithendswithThe following query operations are no longer supported:(version 1.3+)regexiregexNOTE:Not all ticket fields can be changed via REST. Addeditable=Falseas a model option to remove DatabaseErrors.Related FieldsEnterpriseWizard supports foreign table relationships in it’s REST API. To mark a field as related, simply addhelp_text=':'as a model field option.requestor_username=CharField(help_text=':',db_column='submitter_username')Surprisingly many fields are related fields. If a DatabaseError is raised and you aren’t sure why, try making the field related.File Uploadsdjango-ewiz does support file uploads - just not in a direct manner (binary uploads to the file field won’t work [more research on abstracting that will be done later])To mark a field as a file field, addhelp_text='file'as a model field option. Since trying to modify the field directly won’t work, addingeditable=Falseis recommended to avoid confusion.file_field=CharField(help_text='file',editable=False,db_column='attached_files')To upload a file, use the provided EwizAttacher class (from django_ewiz import EwizAttacher) with the following parameters:settingsDict- the DATABASES dictionary that contains ewiz connection settings. e.g. settings.DATABASES[‘default’]model- the model instance  to which a file should be uploaded (the model must include one and only one file field). e.g. models.AccountRequest.objects.get(ticket_id = 1)file_reference- a Python file object. If the file is coming from a django form, grab it via request.FILES[‘form_field_name’].filefile_name- the desired file name. If the file is coming from a django form, you can grab its name via request.FILES[‘form_field_name’].nameFile Upload Exampleforms.pyfromdjango.formsimportForm,FileFieldclassEwizUploadForm(Form):uploaded_file=FileField(required=True)models.pyfromdjango.db.modelsimportModel,AutoField,CharFieldclassAccountRequest(Model):ticket_id=AutoField(primary_key=True,db_column='id')subject_username=CharField(help_text=':')# Use this field only in conjunction with EwizAttacher - do not attempt to directly populate itfile_field=CharField(help_text='file',editable=False,db_column='attached_files')classMeta:db_table=u'account_request'managed=Falseverbose_name=u'Account Request'views.pyfromdjango.confimportsettingsfromdjango.views.generic.editimportFormViewfromdjango_ewizimportEwizAttacherfrom.formsimportEwizUploadFormfrom.modelsimportAccountRequestclassUploadDemoView(FormView):template_name="ewizdemo.html"form_class=EwizUploadFormdefform_valid(self,form):# Create a new account requestticket=AccountRequest(subject_username=self.request.user.username)ticket.save()# Grab the filefile_reference=self.request.FILES['uploaded_file'].file# Upload the fileEwizAttacher(settings_dict=settings.DATABASES['default'],model=ticket,file_reference=file_reference,file_name=self.request.user.username+u'.pdf').attach_file()