- 积分
- 16841
在线时间 小时
最后登录1970-1-1
|

楼主 |
发表于 2025-4-23 22:35:38
|
显示全部楼层
Internal Server Error: /hello/china/
9 i5 x7 K' t! }$ ^7 x6 vTraceback (most recent call last):
) E! A% k" y& L/ m: h$ ~0 k" W0 v File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
" i9 b( |: w) O' N5 N/ T9 { response = get_response(request), Q' x: r" l4 l3 q' C
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response/ i, {4 [8 i# B, ~! b
response = self.process_exception_by_middleware(e, request)* u, U; e9 ?; m( I
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
: I" h: n! X. | c5 S3 W5 G response = wrapped_callback(request, *callback_args, **callback_kwargs)) c3 j7 @- ]3 T1 T. \
File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 11, in hello_china8 p- d. ^1 Y4 @- \0 @
url= reverse('hello_china')
( L3 H! P9 A, Q1 ~/ ]: b, K1 i File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\base.py", line 87, in reverse
$ b9 P* D& c5 m7 v1 A- ? return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
( S: o6 x3 F) K4 f/ f4 E g7 O& c File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 617, in _reverse_with_prefix
2 \5 I( M: k1 j8 G# V: w self._populate()% P( ?5 i! D" I; r5 B% \
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 455, in _populate
4 f$ v* N1 A7 F, N4 B for url_pattern in reversed(self.url_patterns):& b# |* M$ G7 N" l. Z3 B
TypeError: 'set' object is not reversible; M- }' j% k/ d5 w0 w& o9 F, U' b# l; r
[23/Mar/2025 22:26:12] "GET /hello/china/ HTTP/1.1" 500 81834
" Y; R% f7 G$ ?3 {* {' c) `, W/ \% {) p9 r* }
7 \$ @$ H4 Q* @# T/ D问题的原因找到了,是因为根路径下的urls.py 文件中0 i- L; n% r" y; B# H+ b8 R) ^ h0 h
5 k# H& q' a0 _0 _8 Vurlpatterns = {
+ Z9 `; M1 k$ b! i ^$ W! B path('admin/', admin.site.urls),
/ C: Q4 I$ `7 x; V3 l path('hello/', hello_world),
/ \% n' b t2 D; r path('hello/', include('hello.urls')),
+ z$ t2 h/ W5 U1 V& ?}
6 y! j% D" Y+ P& B9 @1 {需要改成+ M* f) J0 Z9 o- R Z
urlpatterns = [
: B2 @3 d8 L1 h) h path('admin/', admin.site.urls),5 \: N2 }% E' c" |' B
path('hello/', hello_world),
% f, D+ T% L# f c% F path('hello/', include('hello.urls')),
2 `( H$ n7 H& i1 {9 s], I, i" @9 I* J" n0 D
问题完美解决。 |
|