Giter Club home page Giter Club logo

django-uni-form's Introduction

django-crispy-form has replaced django-uni-form

We've decided to move development on django-uni-form to django-crispy-forms. From now on, development on django-uni-form has been stopped, and any future work will be for security issues only on legacy code.

django-uni-form

The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered HTML. All this without breaking the standard way of doing things in Django, so it plays nice with any other form application.

The application mainly provides:

  • A filter named |as_uni_form that will render elegant div based forms. Think of it as the built-in methods: as_table, as_ul and as_p. You cannot tune up the output, but it is easy to start using.
  • A tag named {% uni_form %} that will render a form based on your configuration and specific layout setup. This gives you amazing power without much hassle, helping you save tons of time.

By default all the templates were designed to work with Uni-form, but you can create your own or use other bundles available, see the docs for more information.

Authors

Documentation

For extensive documentation see the docs folder or read it on readthedocs

Note

django-uni-form only supports Django 1.2 or higher and Python 2.5.4, Python 2.6.x and Python 2.7.x. If you need to support earlier versions of Django or Python you will need to use django-uni-form 0.7.0.

django-uni-form's People

Contributors

acdha avatar adamcupial avatar agentk avatar akaihola avatar arowla avatar bmihelac avatar boardman avatar brosner avatar copelco avatar issackelly avatar j0hnsmith avatar jjmaestro avatar jmacul2 avatar johnthedebs avatar jtauber avatar juandecarrion avatar kinpoo avatar maraujop avatar pydanny avatar reavis avatar skyl avatar sorki 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

django-uni-form's Issues

some default values missing in BasicNode.get_render()

In uni_form_tags.py, the BasicNode.get_render() method refers to the local variables form_action and form_method when building the context dictionary.

These variables are only assigned in the if attrs clause. So if for any reason attrs is non-true, an exception is raised.

I got this situation when I forgot to add helper = FormHelper() in a form class. The if helper and if attrs clauses hint that django-uni-form was supposed to handle this situation somehow more gracefully.

Row() and formRow are broken

Apparently, helper class Row() renders a div tag with the .formRow css class, but .formRow is not defined in CSS shipped by django-uni-form.

According to http://sprawsm.com/uni-form/, it should be multiField. I just tryed to changed "formRow" to "multiField" in helpers.py but apparently it is not sufficient.

Any idea?

Clean up test project

View libraries are ugly. Thoughts:

  • Convert to 1.2.x style generic views everywhere possible
  • Add django-coverage so we can see actual coverage of the library in unittests

Improve i18n support

Templates' fixed messages should be turned into i18n so we can start adding translation for django-uni-form.

error in doc with uni-form-generic.css

it seems that the "uni-form-generic.css" has been renamed to "default.uni-form.css" but this is not reflected in the docs. At least in my version I cannot find "uni-form-generic.css".

  • I just signed up and I am sorry, if this wasn't the appropriate way to tell about the error.

input classes dont seem to be appearing?

django-uni-form does add any descriptive classes to any of the inputs? (it used to do 'textinput' etc.) It's coming up with anything anymore... (as per email I sent)

problem with django-uni-form's layout

Hi, i got a problem using django-uni-form, the layout is breaking, this is layout's image: http://img839.imageshack.us/img839/6177/67085534.png

And here is my code:

{% load uni_form_tags %}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>

    <script src="{{ MEDIA_URL }}uni_form/jquery.js" type="text/javascript"></script>
    <script src="{{ MEDIA_URL }}uni_form/uni-form.jquery.js" type="text/javascript"></script>

    <link rel="stylesheet" href="{{ MEDIA_URL }}uni_form/uni-form.css" type="text/css" />
    <link rel="stylesheet" href="{{ MEDIA_URL }}uni_form/default.uni-form.css" type="text/css" />                   

</head>
<body>
    <form method="post" class="uniForm" >           
        {{ form|as_uni_form }}
        <input type="submit" value="enviar">
    </form>

</body>
</html>

Put the color scheme and border style in an external css file

I'm currently realigning the the uni_form design where I took the uni-form.css and replaced all the color and border styles. I don't need to touch most values like:

.uniForm .blockLabels .fileUpload{ width: 53%; /* <- Required property */ }

Only the lines who contains the color values:

.uniForm #OKMsg{ background: #C8FFBF; border: 1px solid #A2EF95; border-width: 1px 0; margin: 0 0 1.5em 0; padding: 7px; }

Might be a good idea to put these color and border stuff into it's own theme css.

uni form input field ids

Hi

I mentioned this on pinax-users http://groups.google.com/group/pinax-users/browse_thread/thread/d764aed5ab7bdbec and we exchanged a few emails.

In discussion with Brosner on IRC we (he) found the problem, the ids come from the widget class names in django. There should be a dict that maps widget classes to uni form classes, with a fallback to the widget class name for types not in the dict (for custom or new widgets). textinput vs textInput is due the lower call.

See http://github.com/pydanny/django-uni-form/blob/master/uni_form/templatetags/uni_form_field.py#L11

I will clone this project and attempt to implement this at some point as I need this for my project but it might be a while before I get to it.

Regards

Small README issues

In README.rst, Customizations on '*' required fields (optional):

The line:
cp /Django-uni-form/uni_form/templates/field.html .
should read:
cp /Django-uni-form/uni_form/templates/uni_form/field.html .

Also, I think the readme would benefit just from a small mention somewhere that jQuery is required, since it's not included in the static files provided by uni-form.

Thanks

Better handling of additional CSS classes

django-uni-form/uni_form/templatetags/uni_form_field.py does the following in with_class:

try:
    field.field.widget.attrs['class'] += class_name
except KeyError:
    field.field.widget.attrs['class'] = class_name

This should be something like the following to avoid the need for authors to remember to add extra whitespace when specifying custom widget classes:

if "class" in field.field.widget.attrs:
    field.field.widget.attrs['class'] += " %s" % class_name
else:
    field.field.widget.attrs['class'] = class_name

It appears that certain fields are not considered required when they are.

I have this as a model.

class CreditCard(models.Model):
    user        = models.ForeignKey(User, related_name="credit_cards")
    number      = models.CharField(max_length=16,primary_key=True)
    exp         = models.CharField(max_length=10)
    cvv         = models.CharField(max_length=4)

The "number" field is not showing up as required as it does not have the "*" next to it, of course Django knows better and will show the error that the field is required, but seems as though uni-form doesn't know that.

Minor XHTML validation issue: form method case

Currently the default form_method uses "POST". XHTML wants that to be "post". This could be hacked in the template using |lower but it seems easiest just to change it in helpers.py and let people change if they have some unusual reason for wanting to do so.

add support for formsets

It would be useful to have a template tag for rendering a formset. Field labels would be shown only at the top and suppressed from individual forms.

Handle passwords' inputs as textinput

It only requires to add a line to your class_converter:

class_converter = {
    "textinput":"textinput textInput",
    "passwordinput":"passwordinput textInput",  # that one
    "fileinput":"fileinput fileUpload"
}

Let me know if you want a patch for that. And thanks for your work!

dependency on jQuery not explicitly mentioned

Based on the uni-form.jquery.js file name it is obvious that jQuery is a requirement for django-uni-form. jQuery 1.2.6 is also provided with test_app.

However, the dependency is not mentioned in the documentation. It would be also useful if it was made clear which versions of jQuery are known to work.

field errors are in the wrong place

In django-uni-form / uni_form / templates / uni_form / field.html the errors should be displayed before the field's label, not after the field.

The reason why is this happens on textareas http://www.imagehousing.com/imageupload.php?id=217883, checkout the uni form homepage and you'll see the error is before the tag http://sprawsm.com/uni-form/.

This code should be moved from line 22 to line 6.

        {% for error in field.errors %}
            <p id="error_{{ field.auto_id }}" class="errorField">
                {{ error }}
            </p>
        {% endfor %}

Problem with csrf_token templatetag in latest Django trunk

Latest Django from trunk is marked as 1.3 pre-alpha SVN-13409, so the version check in uni_form_tags.py fails:

if django_version.startswith('1.1.2') or django_version.startswith('1.2'):
    is_old_django=False

I suggest replacing this piece of code with:

from distutils import version
if version.LooseVersion(django_version) >= version.LooseVersion('1.1.2'):
    is_old_django=False

pypi package contains mac meta-files

In the media/uni_form directory in the pypi package, there are two strange files:
"._uni-form.css" and "._uni-form-generic.css" which appear to be some meta-data for some mac os X feature. (at least they contain the string "Mac OS X").

I assume these shouldn't be in the released package

Helper methods do not support translations

When layout with Fieldsets is defined on form, and legend is given as ugettext_lazy, it would be converted to unicode on Fieldset initialization and thus won't be properly translated.

layout = Layout(
                Fieldset(_('Contact details'),))

Small documentation fault concerning media files

In README.rst it is stated that one should copy the media files to /media/uni_form folder. But later the documentation assumes media files are found in /media/uni-form folder (underscore vs. minus)

Also uni_form/templates/uni_form/includes.html has this errors. I sent a pull request with fixes! Hope it helps.

add class to the 'field.required' asterisk

in the README it mentions copying field.html locally to customise the '*' for required fields. That is true but a good starting point would be adding a class. That would let easy CSS changes be possible without needing to copy the whole field.html.

ie change
<span> * </span>
to
<span class="fieldRequired"> * </span>

how to use uni-form with formwizard?

If one uses a formwizard, then the template receives some extra parameters besides the {{ form }} object, and a working formwizard template snippet looks like the following. In this case all the template objects were created automatically by the formwizard.

<form method="post" action="."> <table> {{form}} <tr><td> <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> {{ previous_fields|safe }} <input type="submit"/></td></tr> </table> </form>

The main things to not are the hidden fiels "step_field", and the "previous_fields|safe" parts. These should be added somehow to the form.

I see two possibilities, one would be to add a templatetag for formwizards that would accept the step fiels and previous field objects as argument. The other possibility is to use the FormWizard class' render_template method, but that seems to me like a really dirty hack.

I'll be happy to try adding the templatetag, if you support the idea.

thanks for your work!

docs change easy_install

README.rst line 19

-easy_install install django-uni-form
+easy_install django-uni-form

that's what worked for me :)

Getting up to date with forks

Here I will link the commits and ideas thrown into some of the forks of this project, so we can discuss integrating them into branch 0.8.0-test

This project gathers 54 forks, some of these have great contributions.

fields.html can't load uni_form_field

a template syntax error is raised when the template fields.html calls {% load uni_form_field %}

'uni_form_field' is not a valid tag library: Could not load template library from django.templatetags.uni_form_field, No module named uni_form_field

line 1 of fields.html
{% load uni_form_field %}
{% if field.is_hidden %}
{{ field }}
{% else %}


[...]

was a file missing from the commit?

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.