django.template.exceptions.TemplateDoesNotExist: bootstrap4/field.html

Am trying to upload my first project on pythonanywhere and i have this problem i dont know exactly what is the issue.

CRISPY_TEMPLATE_PACK = 'bootstrap4'

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'jijiapp',
    'jijistore',
    'crispy_forms',
    
]

this is my login form because it has to redirect user to login page first

{% extends 'jijiapp/base/base.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block title %} Upload Item {% endblock %}


{% block content %}


<div class="container">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <h2>Sign in</h2>
            <hr>
            
            <form method="POST" action="{% url 'login' %}">
                
                {% csrf_token %}
                <div class="form-group col-md-10 mx-auto">
                    <div class="text-success mx-auto">
                        {% for msgs in messages %}
                        <span>
                            {{ msgs }}
                        </span>
                        {% endfor %}
                    </div>
                    <label class="col-md-5 col-form-label">{{ form.label }}</label>
                    <div class="col-sm-5 form-control ">
                        {{ form.username|as_crispy_field }}
                    </div>  
    
                </div>
                
                <div class="form-group col-md-10 mx-auto mb-3">
                    
                    <label class="col-md-5 col-form-label">{{ form.label }}</label>
                    <div class="col-sm-5 form-control ">
                        {{ form.password|as_crispy_field }}
                    </div>  
                  
                    {% if form.errors %}
                        <div class="alert alert-danger">
                            <strong>Error:</strong> {{ form.non_field_errors.0 }}
                        </div>
                    {% endif %}
                    
                    <button type="submit" class="btn btn-primary pt-3 px-5">Sign in</button>
                    <p class="">Don't have an account?<a href="{% url 'signup' %}">Signup</a> </p>
                    <p class="">Forget Password<a href="{% url 'password_reset' %}">Reset</a> </p>
                </div>
                
                
            </form>
        </div>
    </div>
    
</div>

{% endblock %}

this is the error from pythonanywhere

  Traceback (most recent call last):
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
      response = get_response(request)
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 220, in _get_response
      response = response.render()
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/template/response.py", line 114, in render
      self.content = self.rendered_content
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/template/response.py", line 92, in rendered_content
      return template.render(context, self._request)
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/template/backends/django.py", line 63, in render
      reraise(exc, self.backend)
    File "/home/Wilfred7/.virtualenvs/venv/lib/python3.8/site-packages/django/template/backends/django.py", line 84, in reraise
      raise new from exc
  django.template.exceptions.TemplateDoesNotExist: bootstrap4/field.html

thank you in advance

The error message is very clear (This template ““bootstrap4/field.html”” doesn’t not exist TemplateDoesNotExist ) you have to search in this way
And due to low information, I think you miss installing bootstrap4 or if it installed you forgot to put it in INSTALLEDAPP .
Try to feed us by more info in order to help you

It’s documented here - Installation — django-crispy-forms 2.0 documentation

You need to install the package crispy-bootstrap4.

1 Like

Thank you so much. It realy worked