Git Product home page Git Product logo

Comments (10)

sveetch avatar sveetch commented on August 23, 2024

It's pretty strange since your settings.CRISPY_TEMPLATE_PACK is correct. What version of crispy_forms are you using ?

I didnt look at it, maybe the 1.5.x is adding some restrictions.

from crispy-forms-foundation.

sveetch avatar sveetch commented on August 23, 2024

And by the way, can you paste me your full exception in a pastebin or alike ?

from crispy-forms-foundation.

compfaculty avatar compfaculty commented on August 23, 2024

TemplateSyntaxError at /login/

crispy tag's template_pack argument should be in ('bootstrap', 'uni_form', 'bootstrap3')

Request Method: GET
Request URL: http://localhost:8000/login/
Django Version: 1.8.3
Exception Type: TemplateSyntaxError
Exception Value:

crispy tag's template_pack argument should be in ('bootstrap', 'uni_form', 'bootstrap3')

Exception Location: /home/alex/py3/lib/python3.4/site-packages/crispy_forms/templatetags/crispy_forms_tags.py in do_uni_form, line 285
Python Executable: /home/alex/py3/bin/python
Python Version: 3.4.0
Python Path:

['/home/alex/PycharmProjects/JobTest',
'/home/alex/py3/lib/python3.4',
'/home/alex/py3/lib/python3.4/plat-x86_64-linux-gnu',
'/home/alex/py3/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/alex/py3/lib/python3.4/site-packages',
'/home/alex/PycharmProjects/JobTest/JobTest',
'/home/alex/PycharmProjects/JobTest/apps',
'/home/alex/PycharmProjects/JobTest/libs']

Server time: Sun, 23 Aug 2015 07:00:19 -0700
Error during template rendering

In template /home/alex/PycharmProjects/JobTest/apps/base/templates/base/login.html, error at line 8
crispy tag's template_pack argument should be in ('bootstrap', 'uni_form', 'bootstrap3')
1 {% extends 'base.html' %}
2 {% load crispy_forms_tags %}
3
4 {% block main_content %}
5


6

7

8
{% crispy login_form %}
.......................................

from crispy-forms-foundation.

compfaculty avatar compfaculty commented on August 23, 2024

crispy-forms-foundation==0.5.2
django-crispy-forms==1.5.1
Django==1.8.3

from crispy-forms-foundation.

sveetch avatar sveetch commented on August 23, 2024

Seems you are using the tag like this {% crispy form 'bootstrap' %} in your template with a form that does not set an helper, can you confirm ?

You should avoid this exception either adding an helper to your form or defining the setting CRISPY_ALLOWED_TEMPLATE_PACKS with something like this :

CRISPY_ALLOWED_TEMPLATE_PACKS = ('bootstrap', 'uni_form', 'bootstrap3', 'foundation-5')

I'm awaiting your confirm about crispy tag usage to update the documentation about this problem, thanks.

from crispy-forms-foundation.

compfaculty avatar compfaculty commented on August 23, 2024

Looks like CRISPY_ALLOWED_TEMPLATE_PACKS = ('bootstrap', 'uni_form', 'bootstrap3', 'foundation-5') helps. After all, I made a hard mix with crispy-forms(including some bootstrap parts) and your module, think it was a problem too. Problem not in tag. -
My form

class LoginForm(forms.Form):
    login = forms.CharField(label=_('Login'), widget=forms.TextInput(attrs={'required':''}), required=True, max_length=30)
    password = forms.CharField(label=_('Password'), widget=forms.TextInput(attrs={'required':''}), required=True, max_length=30)

    def __init__(self, *args, **kwargs):
        # Init layout form with crispy
        self.helper = FormHelper()
        self.helper.form_id = 'id-LoginForm'
        self.helper.form_method = 'post'
        self.helper.form_action = '.'
        self.helper.form_error_title = 'Oooops...'
        self.helper.form_show_labels = False
        # self.helper.attrs = {'data_abide': ''}
        self.helper.form_action = '.'
        self.helper.layout = Layout(
            Fieldset(
                _('Authentification'),
                'login',
                'password',
            ),
            ButtonHolder(

                Submit('submit', _('Send'),css_class='large-offset-6 margintop-10  button round'),
            ),
        )

        super(LoginForm, self).__init__(*args, **kwargs)

View

def login_view(request):
    redirect_url = request.GET.get('next')
    if request.method == 'POST':
        login_form = LoginForm(request.POST)
        if login_form.is_valid():
            username = login_form.cleaned_data['login']
            password = login_form.cleaned_data['password']
            user = authenticate(username=username, password=password)

            if user is not None:
                if user.is_active:
                    login(request, user)
                    return redirect(redirect_url or "base:home")
                else:
                    messages.error(request, "user is not active")
            else:
                messages.error(request, "ask your administrator to create account for you!")
        return render(request, "base/login.html", context={'login_form': login_form})

Template

{% extends 'base.html' %}
{% load crispy_forms_tags %}

{% block main_content %}
<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            {% crispy login_form %}
            {% if messages %}
            <ul class="messages">
                {% for message in messages %}
                <li
                {% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
                {% endfor %}
            </ul>
            {% endif %}
        </div>
    </div>
</div>
{% endblock main_content %}

from crispy-forms-foundation.

compfaculty avatar compfaculty commented on August 23, 2024

Great support as for open source project, David ;-) Thanks a lot!

from crispy-forms-foundation.

sveetch avatar sveetch commented on August 23, 2024

Reopening this until i update the doc about settings.CRISPY_ALLOWED_TEMPLATE_PACKS to set because it seems a requirement since crispy 1.5.x

from crispy-forms-foundation.

pauline-rugwevera avatar pauline-rugwevera commented on August 23, 2024

Thank you so much. ran into similar problem, couldnt solve it for days. You saved me

from crispy-forms-foundation.

askarsaparov avatar askarsaparov commented on August 23, 2024

I had this error too

from crispy-forms-foundation.

Related Issues (20)

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.