403从空索引路由时出错

2024-10-06 11:24:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有django+angular6网络应用程序,可能还有路由问题。你知道吗

我的第一个urls.py示例如下:

url(r'index/', views.GenericView.as_view()),
url(r'api/checks/', views.GetChecksView.as_view()),
url(r'api/editcheck/', views.ChecksEdit.as_view()),
url(r'api/createcheck/', views.CreateCheckView.as_view()),

以及app-routing-module.ts的当前版本:

const routes: Routes = [
  { path: '', redirectTo: '/checks', pathMatch: 'full' },
  { path: 'checks', component: ChecksComponent },
  { path: 'editcheck/:id', component: CheckEditComponent },
  { path: 'createcheck', component: AddCheckComponent}
];
@NgModule({
  exports: [
    RouterModule
  ],
  imports: [
    RouterModule.forRoot(routes)
  ]
})
export class AppRoutingModule { }

在本地运行时,在127.0.0.1:8000上我显然得到了page not found错误。你知道吗

解决方案可能很简单,但当我将r'index/'处的urls.py更改为r''时,在尝试发布任何数据时会遇到错误。你知道吗

已经测试了很多选项,比如通过python脚本发布和更改角度组件模型,但效果并不好。我希望我可以确定的问题,在这些部分的代码,但如果不是-将更新后与其他部分。你知道吗

至于python,它只在第一个例子中起作用,第二个例子说

CSRF verification failed. Request aborted

注意: 我没有在后台使用任何身份验证。 提前感谢您的详细回答


Tags: pathpyviewapiurlindexasurls