|
|
楼主 |
发表于 2025-4-23 22:35:38
|
显示全部楼层
Internal Server Error: /hello/china/
1 d6 t" D" P/ {! nTraceback (most recent call last):
4 x) ]+ t7 ~% } p9 ? File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner9 _0 H+ _+ f5 f) G' Y% a' ~8 V
response = get_response(request)# y4 |: l+ M3 t
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response. J% [7 v. U" G% R/ y7 Q
response = self.process_exception_by_middleware(e, request)
5 H9 X8 K, v/ H" W& A- M! K File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response; d; E R1 A, E @) r3 [' |; O
response = wrapped_callback(request, *callback_args, **callback_kwargs)
7 x8 e7 i. |) D3 N0 P/ E; R. K# J File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 11, in hello_china
! ^; u8 Z( E( R* F* a1 H url= reverse('hello_china')/ p' J$ M" [5 F2 Z3 |' n
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\base.py", line 87, in reverse
5 B' T/ h# |1 X! W# ]7 I! j return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
8 R. V4 A5 O$ b4 N File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 617, in _reverse_with_prefix, p e1 ?9 Z! H$ ~4 U
self._populate()" q* P0 W7 }' I
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 455, in _populate
C2 @" f8 e7 a% o- c. `$ w for url_pattern in reversed(self.url_patterns):
" q( T+ ^# { Y$ `! BTypeError: 'set' object is not reversible
/ v5 _- m) g4 r* I[23/Mar/2025 22:26:12] "GET /hello/china/ HTTP/1.1" 500 81834
9 T+ }# D8 q! J, ?6 f5 _9 L
+ ]3 V: \! r2 G4 A" [3 Q6 x& G1 r8 Q5 R
问题的原因找到了,是因为根路径下的urls.py 文件中; k1 i2 d8 e5 }8 ^0 X ?6 h# q
% W6 Y; k$ R p, w6 n* Y" }
urlpatterns = {
$ O8 b2 _% A! T ^6 ^; m: X path('admin/', admin.site.urls),5 F' V, T: i6 U9 p; V& w, Y
path('hello/', hello_world),- j: @& s; W* G" y. D3 r& y. L
path('hello/', include('hello.urls')),
& G7 Q. _" R' l) @$ u1 H- T}4 }: ?. I: M" q2 e( t/ }& L( K
需要改成
1 t& @: }3 g7 ]! T4 xurlpatterns = [2 ^: s. d4 `3 @. |2 X' @6 {
path('admin/', admin.site.urls),! b- y: u" z( g( y
path('hello/', hello_world),
: f0 U) @( P' N" l0 S7 Y path('hello/', include('hello.urls')),
, {5 Y; J0 D2 Y) l) j* V3 T]
1 B0 t9 j/ Y' P6 Z; H! `3 e$ f6 Z; |1 s问题完美解决。 |
|