Git Product home page Git Product logo

django-dynamic-forms's Introduction

Django Dynamic Form

No Maintenance Intended

image

image

image

image

image

django-dynamic-forms lets you create your forms through the Django admin. You can add and remove form fields as you need them. That makes it perfect for creating survey or application forms.

Documentation: https://django-dynamic-forms.readthedocs.org/

INSTALLATION

Add 'dynamic_forms.apps.DynamicFormsConfig' to the INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'dynamic_forms.apps.DynamicFormsConfig',
    ...
)

Add 'dynamic_forms.middlewares.FormModelMiddleware' to the MIDDLEWARE_CLASSES (probably at the end):

MIDDLEWARE_CLASSES = (
    ...
    'dynamic_forms.middlewares.FormModelMiddleware'
)

Add 'dynamic_forms.urls' to the URL patterns:

urlpatterns = patterns('',
    ...
    url(r'^dynamic_forms/',
        include('dynamic_forms.urls', namespace='dynamic_forms')),
    ...
)

Important

Make sure that you get the namespace straight: dynamic_forms!

You can set DYNAMIC_FORMS_EMAIL_RECIPIENTS in your settings to a list of e-mail addresses. Forms being send via e-mail will then be send to those addresses instead of those defined in settings.ADMINS. Each recipient will see all other recipients. See send_mail in the officiall documentation.

Example

  1. Change into the example/ directory
  2. Apply all migrations: python manage.py migrate
  3. Create a superuser (if not asked before): python manage.py createsuperuser
  4. Run python manage.py runserver

The admin is available at http://127.0.0.1:8000/admin/.

You can find an example form at http://127.0.0.1:8000/example-form/.

Running the tests

  1. Make sure to install tox: $ pip install tox
  2. Run tox

django-dynamic-forms's People

Contributors

carltongibson avatar gladson avatar jedie avatar markush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-dynamic-forms's Issues

CSRF vulnerability when submitting forms

The FormModelMiddleware used to call the DynamicFormView and DynamicTemplateView directly without performing CSRF checks.

Thanks to @knbk for reporting the issue and providing a patch.

The issue has been fixed in v0.4.1 and v0.5.0

No django 1.11 support?!?

It seems that this project is not under active development, isn't it?

The last commit is from Jan 2017: 02a60ac about added django 1.10 support...

What's about django 1.11 support?!?

User tracking

I'd like to contribute changes that track the currently logged in user on FormModelData, and add options for requiring login for viewing and/or submitting a form. Is this something you'd be interested in? Would you be fine with me adding a FormModelData.user ForeignKey?

Ability to extend the possible fields set with custom fields

It would be great if one can easily extend this app with own custom fields. E.g. imagine I have a django app for storing sports results. For some reason I want to give my admin users the ability to define custom forms (thus I use this django app). Now there is a field they always need which is a dropdown with all recorded teams. Instead of manually adding all entries for every form (thus making it cumbersome to maintain) I'd like to create a new custom field type that includes data directly from the database.

Docs: Where does the field data get stored?

I read the docs, and did not find information about how the field data gets stored.

What models (database tables) hold the data which gets entered?

Could you please update the docs?

Thank you.

Added support for formsets

repeated item in a form similar to the image in the link below

this type of form is very common in service business, such as repair shop,
What I'm thinking of is like entering (Qty, Material, price, amount) then ask user (or checkbox) to enter more of the same, once user enters all items, press done with items, then go to fill the rest of the form

this enhancement would be really nice, since it's very common in service business

paper form

Request for demo project

I'm trying to create a sample project but unable to figure out how it works. The referenced example project doesn't seem to work.

I would really appreciate if someone could clarify how to run the sample project or alternatively provide a sample project that example how to use django-dynamic-forms

Unable to

Hey, I tried to used the app in one of my project but I run into some issues.

Example project

I tried to use the example project to see what I can accomplish with this app but I got the following error.

$ python manage.py migrate
SystemCheckError: System check identified some issues:

ERRORS:
?: (urls.E004) Your URL pattern '' is invalid. Ensure that urlpatterns is a list of url() instances.
	HINT: Try removing the string ''. The list of urlpatterns should not have a prefix string as the first element.

So I solved the issue by removing the blank url pattern in example.urls.

Then I visited /admin/ but I got the following error.

[21/Jan/2017 22:14:58] "GET /en/admin/ HTTP/1.1" 302 0
Internal Server Error: /en/admin/login/
Traceback (most recent call last):
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/template/response.py", line 109, in render
    self.content = self.rendered_content
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/template/response.py", line 84, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/template/response.py", line 68, in resolve_template
    return get_template(template, using=self.using)
  File "/home/zoli/projects/test_django_dynamic_forms2/env/lib/python3.5/site-packages/django/template/loader.py", line 25, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: admin/login.html

So I set up the templates in settings.

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, "templates")],
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
        ],
        'loaders':[
            ('django.template.loaders.cached.Loader', [
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
            ]),
        ],
    },
}
]

It worked, I can now create forms via admin. It says I can find an example at http://127.0.0.1:8000/example-form/ but I cannot. Actually after 15 minutes I wasn't able to figure out how to render the form itself on the page.

It's really inconvenient if the example doesn't work.

Custom project

I was able to install the app without any issues, create forms but again, I cannot figure out how to render them.


Could you tell me how can I render my forms? The app itself seems very promising but it needs a better documentation otherwise people won't be able to use it.

get() returned more than one FormModelData

I keep getting this error if I submit a form more than once:

MultipleObjectsReturned at /form/test/done/
get() returned more than one FormModelData -- it returned 11!

The issue happens because of the following code:

       try:
            display_key = self.request.GET.get('display_key')
            data = FormModelData.objects.get(display_key=display_key)
            context.update({
                'data': data,
            })
        except FormModelData.DoesNotExist:
            pass

The issue is fixed if one uses FormModelData.objects.filter(display_key=display_key).all()[0]. But this feels more like a hotfix/hack, because the issue lies deeper, you expect that display_key is unique, which is not the case if the same guy submits twice.

The other fix would be to except all exception and simply pass...

Django 1.10 support: AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'

Package is currently not compatibile with Django 1.10:

    Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fb1f340a598>
    Traceback (most recent call last):
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
        fn(*args, **kwargs)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
        autoreload.raise_last_exception()
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
        six.reraise(*_exception)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
        fn(*args, **kwargs)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
        app_config.import_models(all_models)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/django/apps/config.py", line 199, in import_models
        self.models_module = import_module(models_module_name)
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 662, in exec_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/dynamic_forms/models.py", line 18, in <module>
        from dynamic_forms.fields import TextMultiSelectField
      File "/home/maciek/.virtualenvs/ankiety/lib/python3.5/site-packages/dynamic_forms/fields.py", line 13, in <module>
        class TextMultiSelectField(six.with_metaclass(models.SubfieldBase,
    AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'

Missing migration?

With Django 1.7.1, after installing dynamic_forms I'm running python manage.py makemigrations. This creates a new migration in the dynamic_forms package.

Migrations for 'dynamic_forms':
  0004_auto_20141113_1745.py:
    - Alter field allow_display on formmodel
    - Alter field success_url on formmodel

This looks like it should be already included in the dynamic-forms package.

While it's no problem to create the migration myself, it does cause problems when working with other developers, as the newly created migration is saved with the dynamic_forms package files rather than with any project-specific files.

The created migration looks like this:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
        ('dynamic_forms', '0003_auto_20140916_1433'),
    ]

    operations = [
        migrations.AlterField(
            model_name='formmodel',
            name='allow_display',
            field=models.BooleanField(default=False, help_text='Allow a user to view the input at a later time. This requires the \u201cStore in database\u201d action to be active. The sender will be given a unique URL to recall the data.', verbose_name='Allow display'),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='formmodel',
            name='success_url',
            field=models.CharField(default='', help_text='The full URL path where the user will be redirected after successfully sending the form. It should start and end with a forward slash (<code>/</code>). If empty, the success URL is generated by appending <code>done/</code> to the \u201cSubmit URL\u201d.', max_length=100, verbose_name='Success URL', blank=True),
            preserve_default=True,
        ),
    ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.