在我在 Linux 机器(在 AWS 中)的 Django 项目中,我正在使用:
我为我的项目创建了虚拟环境,并且所有依赖项都在那里完美安装。对于数据库,我使用sqlite3。请参阅下面的版本详细信息。
>>>import sqlite3
>>>sqlite3.version
'2.6.0'
>>>sqlite3.sqlite_version_info
(3, 7, 17)
Run Code Online (Sandbox Code Playgroud)
在settings.py 中的DATABASES部分如下:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
Run Code Online (Sandbox Code Playgroud)
在运行 runserver 时,我收到一个异常,如sqlite3.NotSupportedError: URIs not supported正在生成错误django.db.utils.NotSupportedError: URIs not supported,我无法修复。
我已经浏览了djangoproject.com和google.forum 之类的帖子,但仍然无法理解此错误的原因。我也尝试做python manage.py makemigrations但同样的错误也会出现。
注意:在 Windows 机器中,我的项目运行良好。
请参阅下面的回溯:
# python manage.py runserver
Performing system checks...
System check identified no issues (0 …Run Code Online (Sandbox Code Playgroud) 我的Angular4 页面中有两个选项卡(PrimeNg Tabview),其中包含许多输入字段,例如textboxes、textareas、下拉列表等。我还有一个侧边菜单栏可以导航到应用程序中的其他页面。我想如果这些输入字段中的数据有任何更改,那么如果用户尝试更改选项卡或使用侧面导航到其他页面,则会出现一条弹出消息(模式或确认框)菜单栏。
ngOnDestroy()方法我试过了。虽然此方法仅在页面关闭时触发(通过导航到其他页面或移动到下一个标签页),但它不允许您从方法中显示模式/确认框,因为它处于销毁生命周期挂钩.
请帮助我确定实际事件,如果页面/表单中的任何输入字段发生更改,我可以使用该事件向用户提示确认框。
@surjit 建议:
my-guard.service.ts:
export interface CanComponentDeactivate {
CanDeactivate: () => Observable<boolean> | Promise<boolean> | boolean;
}
@Injectable()
export class CreateRequestGuardService implements CanDeactivate<CanComponentDeactivate> {
canDeactivate(component: CanComponentDeactivate) {
let vDeactivate = component.CanDeactivate ? component.CanDeactivate() : true;
return vDeactivate;
}
}
Run Code Online (Sandbox Code Playgroud)
在my-component.ts 中:
import { CreateRequestGuardService } from './my-guard.service';
canDeactivate(): Observable<boolean> | boolean {
console.log('I am moving away!');
if (!this.isSaved) {
const confirmation = window.confirm('Are you …Run Code Online (Sandbox Code Playgroud)