Commits

Vladimir Korsun committed b13b475

Initial commit

Comments (0)

Files changed (8)

+recursive-include templates *.html
+About
+=====
+
+Django application that can change the field widget attributes in place.
+
+Install
+=======
+
+Clonning repository
+-------------------
+
+    hg clone https://amigo@bitbucket.org/amigo/django-field-attributes
+
+Via package index
+-----------------
+
+    pip install django-field-attributes
+
+Usage
+=====
+
+Template example:
+
+    {% load field_attributes %}
+
+    {% field form['title'] class="announce" %}
+
+from distutils.core import setup
+
+setup(
+    name='django-field-attributes',
+    version='1.0',
+    packages=['django-field-attributes',
+              'django-field-attributes.templatetags'],
+    url='http://bitbucket.org/amigo/django-field-attributes',
+    license='BSD',
+    author='Vladimir Korsun',
+    author_email='korsun.vladimir@gmail.com',
+    description='Django field attribute substitute',
+    requires=['django (>=1.4)'],
+    package_dir={
+        'django-field-attributes': 'src',
+    },
+    package_data={
+        'django-field-attributes': ['templates/*.html'],
+    },
+    classifiers=[
+        'Environment :: Web Environment',
+        'Framework :: Django',
+        'Operating System :: OS Independent',
+        'License :: OSI Approved :: BSD License',
+        'Programming Language :: Python',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+    ]
+)

src/__init__.py

Empty file added.

src/models.py

Empty file added.

src/templates/field.html

+{{ field }}

src/templatetags/__init__.py

Empty file added.

src/templatetags/field_attributes.py

+from django.template import Library
+
+register = Library()
+
+@register.inclusion_tag('field.html')
+def field(field, *args, **kwargs):
+    """
+    Substitute field widget attributes
+    """
+    field.field.widget.attrs.update(kwargs)
+    return {'field': field}