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

楼主 |
发表于 2025-4-23 22:35:38
|
显示全部楼层
Internal Server Error: /hello/china/ |8 w1 p& {& o
Traceback (most recent call last):
9 _' M# h$ B" D+ {( d File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner7 D4 ~* ?1 A( u5 Z$ i
response = get_response(request)
0 p6 S5 n& c% g+ ?5 S- e0 } File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response/ a- w: O) e9 K' Q' Z( j: ]$ N$ q
response = self.process_exception_by_middleware(e, request)/ B8 m. P8 m6 L9 d, d G( D
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response* m# ^5 j+ S# k& d* W8 ?+ i
response = wrapped_callback(request, *callback_args, **callback_kwargs); ~% j: n5 T) f* k0 \3 o# n0 H t
File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 11, in hello_china; e# q# _7 Z) F
url= reverse('hello_china')8 a0 k- z# `* U/ B* m* c/ V
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\base.py", line 87, in reverse% J/ P6 _2 X4 e& i. U7 m6 f) S
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
+ K# C! ]0 @7 _1 y0 I0 K File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 617, in _reverse_with_prefix% v: @+ N$ b* s
self._populate()& u! P/ {( ]. H- n) Q4 w0 y7 F3 k
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 455, in _populate6 E( ]% y0 W& y
for url_pattern in reversed(self.url_patterns):
, P* I5 c0 P3 J# t3 MTypeError: 'set' object is not reversible; U- l) k9 B/ J& [, Q3 s
[23/Mar/2025 22:26:12] "GET /hello/china/ HTTP/1.1" 500 81834( v9 u8 J1 R" H; l" J3 T" X
' y. Z$ }3 j+ P/ P+ O
+ ~0 F$ R* X- d/ F ]7 v问题的原因找到了,是因为根路径下的urls.py 文件中: ~% H$ t! y4 U( W
! g# e* l3 V0 Y- ~
urlpatterns = {
' f3 |, p0 F3 b% s) p path('admin/', admin.site.urls),9 U" J- O) n/ n n$ v
path('hello/', hello_world),
/ s! P/ j) ], V9 s5 V5 L- Q9 g4 w, N- X path('hello/', include('hello.urls')),
) ~& ~+ @. ]4 O0 a}
! x- T. m# V: t/ T% _+ ~需要改成
, _) M! s' y& U( m+ b8 Iurlpatterns = [
- i8 `8 T8 S3 T: I* q path('admin/', admin.site.urls),
5 D4 T4 r& p$ D' W, Q9 a; p6 I+ U path('hello/', hello_world),
M, B) k- q$ v. r' m$ _$ X6 N/ t path('hello/', include('hello.urls')),
1 O1 f! M0 |0 x3 L* k% n]) ^# J6 U; H: c$ N& k4 H
问题完美解决。 |
|