I have django+angular6 web app and, probably, problems with routing.
My 1st example of urls.py
looks like:
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()),
and current version of 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 { }
While running on local, on 127.0.0.1:8000
I am obviously getting page not found
error.
Solution could be simple, but when I change r'index/'
at urls.py
to r''
it runs into an error when I'm trying to post any data.
Already tested a lot of options, such as posting through python script and changing angular component models, didnt work any good. I hope I could be sure that the problem in these parts of code, but if its not - will update post with other parts.
As for python, it works only in first example, second one says
CSRF verification failed. Request aborted
Note: I'm not using any auth on backend. Thanks in advance for extended answers