|
|
楼主 |
发表于 2025-4-23 22:35:38
|
显示全部楼层
Internal Server Error: /hello/china/
' C0 K$ _& @. sTraceback (most recent call last):
- r: y: m+ J/ w- u H/ Z/ ], v File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner' _ A) E. p& X0 r; ?, n) }
response = get_response(request). ^9 J2 ^( i O5 ?5 X
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
. v% z3 ?2 N& U# w! C" B response = self.process_exception_by_middleware(e, request)
; ]5 `# G& j0 N: P2 x1 C. O! ` File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response8 q9 I4 y) j0 g: L. Y3 h: r
response = wrapped_callback(request, *callback_args, **callback_kwargs)
. Y$ @. F: W! I0 v. {/ I File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 11, in hello_china$ W2 v$ y& r7 v4 S( }4 r
url= reverse('hello_china')
3 I% u. P) Y5 a( M% B+ M File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\base.py", line 87, in reverse
* U5 L7 v) i; I return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))0 d$ N% l4 W6 S1 ~2 b1 w
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 617, in _reverse_with_prefix1 I" b& _: O7 t+ i+ Q
self._populate()
p5 J* _. y6 ?& M+ s6 r File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 455, in _populate
1 j, j' O4 c4 ?" V' P for url_pattern in reversed(self.url_patterns):6 V" S; A1 `' A0 S
TypeError: 'set' object is not reversible
1 E8 \2 J9 G# k+ b[23/Mar/2025 22:26:12] "GET /hello/china/ HTTP/1.1" 500 81834# ?; ?" S3 r0 L1 k
: W% I4 Q- G8 E P3 p, V3 c3 i# n7 e: _' f
问题的原因找到了,是因为根路径下的urls.py 文件中
9 h2 T) I. k. V' L! A: L [! G: N+ i. J0 C1 v6 V9 l( g" A
urlpatterns = {
. n3 _% F: Z+ ?- I* J ]* S; T" A& D9 W path('admin/', admin.site.urls),
" G' W9 z, g# |! s: a: n3 P path('hello/', hello_world),
7 d( X: B+ r1 T path('hello/', include('hello.urls')),
: Y Y1 J, Y2 D! }) \8 k3 C}
0 r* n/ T5 H2 f6 K需要改成6 z; P3 w) l0 l' C' O
urlpatterns = [7 ^1 Q, t5 i0 Y# K! G
path('admin/', admin.site.urls),4 o. Q4 v4 K. {4 U0 m
path('hello/', hello_world),
, ?6 J8 }! q, P, g# v path('hello/', include('hello.urls')),$ W* z6 g7 _% j" r: \7 Z
], l, e- M3 }' `
问题完美解决。 |
|