django-renderformplain

django-renderformplain is a Django app that allows you to render forms in plain text. I have found myself implementing quite a bit of styling into my forms and thought why do it once more when I want to render just the data. Renderformplain works both with bound forms (renders bound data) and unbound forms (renders initial data). The project is new, so there is no release yet1. But I’d like you to try it out and tell me what you think about it. And maybe find a few bugs.

An Example

After you copy renderformplain folder somewhere within your PYTHONPATH, add "renderformplain" to your INSTALLED_APPS setting to be able to run the example.

Let’s say you have a model File:

   1 class File(models.Model):
   2     name = models.CharField(max_length=100)
   3     path = models.CharField(max_length=250)
   4     size = models.IntegerField()
   5     last_modified = models.DateTimeField(default=datetime.datetime.now)
   6     created = models.DateTimeField(default=datetime.datetime.now)
   7     permissions = models.IntegerField()

And a form FileForm:

   1 class FileForm(forms.ModelForm):
   2     class Meta:
   3         model = File

Now assume you are using django.contrib.formtools.preview.FormPreview to review entered data before saving. In your formtools/preview.html template, instead of rendering the form as an HTML form, you can render it in plain text like this:

{% load renderformplain_tags %}

{% plainform form as plain_form %}

<h1>Preview your submission</h1>
{{ plain_form.as_table }}

<form action="" method="post">
  {{ form.as_hidden }}
  <input type="hidden" name="{{ stage_field }}" value="2" />
  <input type="hidden" name="{{ hash_field }}" value="{{ hash_value }}" />
  <p><input type="submit" value="Submit" /></p>
</form>

This will render the plain_form just like a normal form, except all fields will be replaced with read-only plain text.

Anyway. Try renderformplain and tell me what you think.


1: I will tag releases. Check out the repository for tags.

Bookmark and Share

Related posts:

  1. django-formfieldset
  2. What’s New in django-formfieldset 1.1
  3. Dynamic Translation Apps for Django
  4. Developing Reusable Django Apps
  5. Django Fixtures

Tags: , , ,

Comments are closed.

Additional comments powered by BackType