Skip to main content

Store python source code (syntax checked) in database.

Project description

If you need to store python source code in a field in a django model, this is the app you need.

Obviously, you should not be accepting any old user data if you will be executing it, but for my use case (admin users only, needed complex data rules that varied between models), python code was the best choice.

So, you use it by:

  • $ python setup.py install

  • add python_field to your settings.INSTALLED_APPS (optional, but required if you want syntax highlighting).

  • Use as follows in your model:

    from django.db import models
    from python_field.fields import PythonCodeField
    
    class MyModel(models.Model):
        ....
        source = PythonCodeField(blank=True, null=True)
    
        ....

The text will be compiled using the inbuild python compile() function, and errors will be shown in the form errors field.

CodeMirror and Syntax Highlighting

This package uses parts of the CodeMirror package for syntax highlighting, and for replacing the textarea with an editable iframe.

Parts of the CodeMirror package that are not required have not been included, and the package has been minified. [This is not the case just yet.]

The original license file is included for your reference.

CodeMirror can be found at http://codemirror.net/

History

This project is a fork of Matthew Schinckel’s project at http://bitbucket.org/schinckel/django-python-code-field/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_field-0.0.1.tar.gz (43.2 kB view details)

Uploaded Source

File details

Details for the file python_field-0.0.1.tar.gz.

File metadata

  • Download URL: python_field-0.0.1.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python_field-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9367bc2fb4add9753434400378d5cb11262d53325f10ea16f52a2a1e44e4a7f7
MD5 f6810cf24c56ee201792ba0e07a225f8
BLAKE2b-256 b70a0ebf7d4a3319efbbafd9131453883920e9ebd5ea5cde4ffe5ab84ff70207

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page