简体   繁体   English

为什么我收到 No module named 'django.utils.lru_cache' 错误?

[英]Why am I getting No module named 'django.utils.lru_cache' error?

I am working a Django project.我正在做一个 Django 项目。 I have created a form and tried to use Crispy-forms to style the form.我创建了一个表单并尝试使用 Crispy-forms 来设置表单样式。 However, when I runserver I get the following error.但是,当我运行服务器时,出现以下错误。

File "D:\Django_Project\venv\lib\site-packages\django\template\backends\django.py", line 131, in get_package_libraries文件“D:\Django_Project\venv\lib\site-packages\django\template\backends\django.py”,第 131 行,在 get_package_libraries

raise InvalidTemplateLibrary(django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to 'crispy_forms.templatetags.crispy_forms_field': No module named 'django.utils.lru_cache'引发 InvalidTemplateLibrary(django.template.library.InvalidTemplateLibrary:指定的模板库无效。尝试“crispy_forms.templatetags.crispy_forms_field”时引发 ImportError:没有名为“django.utils.lru_cache”的模块

This is the template where I am using crispy-forms这是我使用crispy-forms的模板

        {% load crispy_forms_filters %}
        {% 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 %}```
        
        
        
I am using Django==4.0.6
Crispy-form==1.14.0
        
Have searched online for possible fix unsuccessfully. Please I need help.

I found an alternative hard coding with bootstrap since I couldn't find anyway to style using crispy-forms ''' from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm I found an alternative hard coding with bootstrap since I couldn't find anyway to style using crispy-forms ''' from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm

class UserRegisterForm(UserCreationForm): email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'})) first_name = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class': 'form-control'})) last_name = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class': 'form-control'})) class UserRegisterForm(UserCreationForm): email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'})) first_name = forms.CharField(max_length=50, widget=forms.TextInput(attrs ={'class': 'form-control'})) last_name = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class': 'form-control'}))

class Meta:
    model = User
    fields = ['username', 'first_name', 'last_name', 'email', 'password1', 'password2']

def __init__(self, *args, **kwargs):
    super(UserRegisterForm, self).__init__(*args, **kwargs)

    self.fields['username'].widget.attrs['class'] = 'form-control'
    self.fields['password1'].widget.attrs['class'] = 'form-control'
    self.fields['password2'].widget.attrs['class'] = 'form-control'

''' '''

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我为什么会收到此错误:“ ModuleNotFoundError:没有名为&#39;nst_utils&#39;的模块” - Why am I getting this error: “ModuleNotFoundError: No module named 'nst_utils'” 为什么我不断收到此“没有名为 utils 的模块”错误? - Why do I keep getting this 'no module named utils' error? 为什么我收到错误:没有名为“email.MIMEMultipart”的模块? - Why am I getting the error: No module named 'email.MIMEMultipart'? 为什么我会收到“没有名为 OpenAI 的模块”导入错误? - Why am I getting a 'No module named OpenAI' Import error? 为什么我没有名为“pyautogui”的模块? - Why am I getting No module named 'pyautogui'? 为什么我会收到此导入错误? ImportError:无法从“social_django.utils”导入名称“setting” - Why am I getting this Import Error? ImportError: cannot import name 'setting' from 'social_django.utils' Django没有名为utils的模块 - Django no module named utils 当我运行应用程序时,我收到此错误 ModuleNotFoundError: No module named 'preferences' in django - when i run the app i am getting this error ModuleNotFoundError: No module named 'preferences' in django 我得到了异常值:django中没有名为views的模块 - I am getting Exception Value:No module named views in django 尝试启动Django应用程序时,为什么会收到“ no module named wagtail”错误 - Why am I receiveing 'no module named wagtail' error when I try to launch django app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM