将Django频道添加到设置文件中的installed_apps后出现错误 [英] Error after adding Django channels to installed_apps in settings file

查看:73
本文介绍了将Django频道添加到设置文件中的installed_apps后出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试django频道,所以我创建了一个虚拟环境并安装了django,drf和频道.它要求安装可视化c ++生成工具后就解决了该错误.然后,我创建了一个渠道项目和一个应用程序.然后,仅出于测试目的,我添加了以下示例模型,并向管理员注册了该模型.它编译良好,而且我也可以在管理页面中看到该模型.

I am just trying out django channels so I created a virtual environment and installed django, drf and channels. It threw error asking for visual c++ build tools which got resolved after installing it. Then I created a channels project and an app. Then just for testing I added a sample model as below and registered it with the admin. It compiled well and also I was able to see the model in the admin page.

我的模特失事

from django.db import models

# Create your models here.
class College(models.Model):
    name = models.CharField(max_length=50)
    address = models.CharField(max_length=150)
    objects = models.Manager()

    def __str__(self):
        return self.name

我的管理员.py

from django.contrib import admin
from .models import College

# Register your models here.
admin.site.register(College)

现在是问题

我将频道添加到了settings.py文件中的INSTALLED_APPS列表中,如下所示,

I added channels to the INSTALLED_APPS list in the settings.py file like below,

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'channelApp',
    'channels',
]

现在,当我尝试使用runserver命令运行服务器时,出现以下错误

Now when I try to run the server using the runserver command I get the following error

ModuleNotFoundError:没有名为"win32api"的模块

ModuleNotFoundError: No module named 'win32api'

LookupError:未安装带有标签"admin"的应用.

LookupError: No installed app with label 'admin'.

我一直在搜索,但是找不到任何合适的答案.请帮我.

I have been searching but failed to find any suitable answer. Kindly help me out.

谢谢.

推荐答案

就在我发布此帖子后,我偶然发现了一个SO帖子

Just after I posted this I stumbled onto a SO post

安装Django频道后的问题

简而言之,这是一个开放的错误,解决方法是安装以下程序包

Just to reiterate in short, this is an open bug and the work around is to install the following package

pip install pypiwin32

安装后,您可能必须关闭并重新打开编辑器,以反映所做的更改.错误已解决.

After installing you may have to close and reopen the editor for the changes to reflect. And the error is resolved.

这篇关于将Django频道添加到设置文件中的installed_apps后出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆