Code Monkey home page Code Monkey logo

django-jinja-bootstrap-form's People

Contributors

alextford11 avatar bianchimro avatar bitdeli-chef avatar caumons avatar cyluss avatar epicserve avatar gsiegman avatar jiaaro avatar jodal avatar jonathanmarriott avatar jtauber avatar jweiher avatar karls avatar mattaustin avatar mpapierski avatar nivl avatar palfrey avatar prudnikov avatar ptrck avatar raphendyr avatar samuelcolvin avatar siloraptor avatar tomhamiltonstubber avatar tzangms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-jinja-bootstrap-form's Issues

Empty required_css_class not handles well

Here is what I get for default login form:

      <label class="control-label  {{ no such element: django.contrib.auth.forms.AuthenticationForm object['required_css_class'] }}" for="id_username">Username</label>

Detailed configuration / setting up

Hi there,

Thanks for making this library.

I was expecting to use the lib by simply pip installing it and adding bootstrapform_jinja to INSTALLED_APPS, but unfortunately this plug-in-and-play doesn't seem to work in my environment.

I got the following 2 issues:

  1. The filters ( bootstrap, etc ) are not registered to the Jinja Environment object, which caused the error ("No filter named 'bootstrap'.",)
  2. After manual registering of the filters, bootstrapform_jinja was not processed by the Jinja backend, which caused the error Invalid block tag on line 1: 'import'. Did you forget to register or load this tag?

My Jinja configuration was based on the example in the Django official doc here
https://docs.djangoproject.com/en/4.1/topics/templates/#django.template.backends.jinja2.Jinja2

from django.templatetags.static import static
from django.urls import reverse
from jinja2 import Environment

def environment(**options):
    env = Environment(**options)
    env.globals.update({
        'static': static,
        'url': reverse,
    })
    return env

And this environment was registered in the Django TEMPLATES settings like

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.jinja2.Jinja2',
        ...
        'OPTIONS': {
            'environment': '__path_to_the_above_file__.environment',
            ...
        },
    },
   ...
]

To solve 1st issue, I tried attaching the internal filters to the env returned, like this

from django_jinja.library import _update_env

def environment(**options):
    env = Environment(**options)
    # ...
    _update_env(env)
    return env

Now came the 2nd error. This time I tried adding the path of bootstrapform_jinja/templates in TEMPLATES, like this

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.jinja2.Jinja2',
        'DIRS': ['/absolute/path/to/venv/site-packages/bootstrapform_jinja/templates',
                 'TEMPLATES FOLDER OF OTHER APPS', ...],
    },
   ...
]

And now it works. Though, neither of those changes looks good to be pushed into production environment.

Wonder how I was supposed to use this library. Any help is appreciated.


UPDATE:

I was using Python 3.9.7, along with

asgiref==3.5.2
Babel==2.10.3
Django==4.1.1
django-filter==22.1
django-jinja==2.10.2
django-jinja-bootstrap-form==4.3.5
Jinja2==3.1.2
MarkupSafe==2.1.1
pytz==2022.2.1
sqlparse==0.4.2

TemplateDoesNotExist error

template:

bootstrapform/form.jinja

was not found.

I'm using Django 1.11.4 all the packages are at the latest version.

Not really sure from where this error arise...

 {% csrf_token %}
 {{ form|bootstrap_inline }}
 <div class="form-group">
    <div class="col-sm-10 col-sm-offset-2">
        <button type="submit" class="btn btn-primary">Submit</button>
    </div>
</div>

Python 3.8 v.s. 3.5

The README says "Python >=3.5", but the setup.py says 3.8 only. Which is the supported version range?

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.