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.
37 messages · Page 1 of 1 (latest)
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.
Please don't share images of code. Text is best shared as text as per #readme-1st
ok
ALLOWED_HOSTS = []
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_URL = 'static/'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Where do you see this {% template .... %} code?
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
This is my question, where did you see {% template "bootstrap4/uni_form.html" %}
Did you copy this from somewhere?
i did a reseach on ai
AI isn't meant to replace the official knowledge base, it's supposed to compliment it.
Please use the official tutorial: https://django-crispy-forms.readthedocs.io/en/latest/index.html
In this instance, AI has given you incorrect code.
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
i did the pip install bootstrap4
bootstrap4 or crispy-bootstrap4 ?
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
Restart your server.
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

that worked
ooooooohhhhoooo
@twilit knot Thank's very much!