|
|
楼主 |
发表于 2025-4-23 22:35:38
|
显示全部楼层
Internal Server Error: /hello/china/
2 b* S( d" w, ~ _% G# g) D$ n3 e5 `Traceback (most recent call last):; Q5 A5 L8 p! ?/ r1 K$ W$ F. o
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
. D. ]0 Q3 M% m5 T! _* M& h response = get_response(request)
9 D" P7 R& ~3 M) V File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response3 r; L6 B# x! a/ t% P
response = self.process_exception_by_middleware(e, request)
3 y& X: W( C$ \; r" @ File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
3 s- |% k% b# d3 w response = wrapped_callback(request, *callback_args, **callback_kwargs) f6 ~7 k5 @# L0 A
File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 11, in hello_china2 g7 c& h' K* w' ~
url= reverse('hello_china') x3 U( E( a( b# `! K
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\base.py", line 87, in reverse
* w1 m A2 o5 h4 U8 H# } return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))5 X+ `. d; w, ]8 ^9 L- e! K
File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 617, in _reverse_with_prefix
5 l' o8 j9 n5 Q: ` self._populate()
- F6 I' x7 I0 X% L9 Q8 F0 e! Z File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\urls\resolvers.py", line 455, in _populate
( t! r. [1 {$ Z0 J for url_pattern in reversed(self.url_patterns):
7 o$ r |3 M: V% @8 X. h e! }TypeError: 'set' object is not reversible
0 G, W$ t: J8 t2 S. V0 U[23/Mar/2025 22:26:12] "GET /hello/china/ HTTP/1.1" 500 81834
6 w" R4 w5 o8 Q3 n+ V2 {: h, z! g% r, W, N! d
) j. V# I! a) N% O3 U4 k# _问题的原因找到了,是因为根路径下的urls.py 文件中
6 }9 ~1 U" a5 P- ^4 j! N h
) r k- C4 W$ I9 furlpatterns = {
, w2 P/ U4 A2 }# [9 u" c9 H path('admin/', admin.site.urls),/ g7 S8 Y+ I2 s8 s
path('hello/', hello_world),
. D# A4 p0 m7 I# g7 B path('hello/', include('hello.urls')),7 M* v" F Y! }' o$ e2 ?9 H, X2 r
}2 R1 X6 }) L% U. l9 F6 i
需要改成2 J! R3 d6 A( m8 N4 ?, H
urlpatterns = [
$ n/ L) Y0 K8 p/ Z; f0 Y/ u path('admin/', admin.site.urls),5 e* ?* R& a3 t2 u5 d) g
path('hello/', hello_world),( f" d0 E; i$ h/ M% N
path('hello/', include('hello.urls')),
: d. q# k' ^1 v9 k) W4 s% D]7 u6 z, j! {+ n( A
问题完美解决。 |
|