所以我在開發人員中使用Django和React URL路由的問題為零,但是現在我試圖進入生產階段,遇到了各種各樣的問題。是的,涉及到正則表達式時,我很爛。看起來就像只貓在鍵盤上走路。絕對是我需要坐下來并致力于學習的東西。在開發人員中,我最擅長的是以下完美工作的工具:url(r'', TemplateView.as_view(template_name='index.html')),在生產中,我得到了Uncaught SyntaxError: Unexpected token <。正如向我解釋的那樣,這與JS被捕獲在URL中而不是index.htmlJS需要“通過”有關。有人告訴我嘗試:url(r'^$', TemplateView.as_view(template_name='index.html')),這行得通。Web應用程序已加載,我能夠進行導航。但是,當涉及到驗證電子郵件鏈接時,出現了另一個問題。我Page not found (404)遇到的問題又不是我的開發設置中的問題。電子郵件鏈接如下所示:https://test.example.com/auth/security_questions/f=ru&i=101083&k=6d7cd2e9903232a5ac28c956b5eded86c8cb047254a325de1a5777b9cca6e537我得到的是:Page not found (404)Requested URL: http://test.example.com/auth/security_questions/f%3Dru&i%3D101083&k%3D6d7cd2e9903232a5ac28c956b5eded86c8cb047254a325de1a5777b9cca6e537/我的反應路線如下:<App> <Switch> <Route exact path='/auth/security_questions/f=:f&i=:id&k=:key' component={SecurityQuestions} /> <Route exact path='/auth/*' component={Auth} /> <Route exact path='/' component={Auth} /> </Switch></App>這應該渲染/auth/security_questions/...路線。另外,authentication.urls:urlpatterns = [ url(r'^security_questions/', SecurityQuestionsAPIView.as_view(), name='security_questions'),]似乎Django正在嘗試處理路由,顯然沒有匹配的路由,實際上它應該只是呈現index.html并讓其react-router-dom接管以將請求從FE發送到API。因此,看來我需要做一個讓JS順利通過的包羅萬象的東西。我遇到了一個似乎相關的問題:反應路由和django url沖突。因此,我添加了以下內容,以使我有一個“/抓手”,然后“抓緊一切”。# match the rooturl(r'^$', TemplateView.as_view(template_name='index.html')),# match all other pagesurl(r'^(?:.*)/?$', TemplateView.as_view(template_name='index.html')),仍然不會呈現驗證鏈接。對最后捕獲的所有URL進行了其他嘗試:url(r'^', TemplateView.as_view(template_name='index.html')),結果是 Uncaught SyntaxError: Unexpected token <url(r'^.*', TemplateView.as_view(template_name='index.html')),因此,我們將深入研究Django,正則表達式,并嘗試對其進行梳理,但與此同時...我在這里做錯了什么?
添加回答
舉報
0/150
提交
取消