#Crispy forms

37 messages · Page 1 of 1 (latest)

torpid raptor
#

Hello everyone.

I am facing this when i try to implement crispy forms to my register.html template.
I did all those pips but I am still getting trouble when I try to access the form from localhost.

fluid solar
#

Please don't share images of code. Text is best shared as text as per #readme-1st

torpid raptor
#

ok

#

ALLOWED_HOSTS = []

Application definition

INSTALLED_APPS = [
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]

#

Static files (CSS, JavaScript, Images)

https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'

Default primary key field type

https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

CRISPY_TEMPLATE_PACK = 'bootstrap4'

twilit knot
#

Where do you see this {% template .... %} code?

torpid raptor
#

i have te {%%} on my register.html template

#

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
{% template "bootstrap4/uni_form.html" %}
{% block content %}
<div class="content-section">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Join Today</legend>
{{ form|crispy }}

</fieldset>
<div class="form-group">
    <button class="btn btn-outline-info" type="submit">Sign Up</button>
</div>
</form>
<div class="border-top pt-3">
    <small class="text-muted">
        Already Have An Account? <a class="ml-2" href="#">Sign In</a>
    </small>
</div>
</div>

{% endblock content %}

#

I am trying to do {%temple"bootstrap4/uni_form.html%}

#

but it also is not working

#

L: http://127.0.0.1:8000/register/
Django Version: 5.0.7
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag on line 3: 'template'. Did you forget to register or load this tag?
Exception Location: C:\Users\jeffs\OneDrive\FOTOS\workSpace\prototypes\django\django-cs.venv\Lib\site-packages\django\template\base.py, line 565, in invalid_block_tag

twilit knot
#

This is my question, where did you see {% template "bootstrap4/uni_form.html" %}

#

Did you copy this from somewhere?

torpid raptor
#

i did a reseach on ai

twilit knot
#

AI isn't meant to replace the official knowledge base, it's supposed to compliment it.

#

In this instance, AI has given you incorrect code.

torpid raptor
#

i see

#

so, i took off that

#

now the code is like that

#

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}

{% block content %}
<div class="content-section">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Join Today</legend>
{{ form|crispy }}

</fieldset>
<div class="form-group">
    <button class="btn btn-outline-info" type="submit">Sign Up</button>
</div>
</form>
<div class="border-top pt-3">
    <small class="text-muted">
        Already Have An Account? <a class="ml-2" href="#">Sign In</a>
    </small>
</div>
</div>

{% endblock content %}

#

but I am still facing problems

#

reraise(exc, self.backend)
File "C:\Users\jeffs\OneDrive\FOTOS\workSpace\prototypes\django\django-cs.venv\Lib\site-packages\django\template\backends\django.py", line 84, in reraise
raise new from exc
django.template.exceptions.TemplateDoesNotExist: bootstrap4/uni_form.html
[06/Aug/2024 11:19:44] "GET /register/ HTTP/1.1" 500 167239

#

he is trying to reach that bootstrap4/uni_form.html

twilit knot
torpid raptor
#

i did the pip install bootstrap4

twilit knot
#

bootstrap4 or crispy-bootstrap4 ?

torpid raptor
#

yes, i did

#

s\jeffs\onedrive\fotos\workspace\prototypes\django\django-cs.venv\lib\site-packages (from django>=4.2->crispy-bootstrap4) (3.8.1)
Requirement already satisfied: sqlparse>=0.3.1 in c:\users\jeffs\onedrive\fotos\workspace\prototypes\django\django-cs.venv\lib\site-packages (from django>=4.2->crispy-bootstrap4) (0.5.1)
Requirement already satisfied: tzdata in c:\users\jeffs\onedrive\fotos\workspace\prototypes\dja

twilit knot
#

Restart your server.

torpid raptor
#

TemplateDoesNotExist at /register/
bootstrap4/uni_form.html
Request Method: GET
Request URL: http://127.0.0.1:8000/register/
Django Version: 5.0.7
Exception Type: TemplateDoesNotExist
Exception Value:
bootstrap4/uni_form.html
Exception Location: C:\Users\jeffs\OneDrive\FOTOS\workSpace\prototypes\django\django-cs.venv\Lib\site-packages\django\template\backends\django.py, line 84, in reraise
Raised during: users.views.register

#

ok

#

ok i will restar the server

#

ooooooohhhhoooo

#

blobyes
that worked

#

ooooooohhhhoooo

#

@twilit knot Thank's very much!