Django dummie question
Hi i'm beginning to learn django and i'm facing same trouble .Could you guys help with a silly question .
i have a nav menu at my base.html it works 开发者_开发知识库fine but the problem is that when i click in one of the links , my view.py render_to_response correctly to the page , but once i got there if i click again in this link it just and to my url the same pattern and my urls.py dont find it. Same thing like that.
First time click :
//127.0.0.1:8000/cliente/cadastro/
Second time click:
//127.0.0.1:8000/cliente/cadastro/cliente/cadastro/
I belive that is the same problem i'm facing with admin
First time click :
//127.0.0.1:8000/admin/
It works.
Second time click:
//127.0.0.1:8000/cliente/cadastro/admin/
it does not Work.
The url.py is the follow:
urlpatterns = patterns('',
# Example:
(r'^', include('cliente.urls')),
(r'^admin/', include(admin.site.urls)),
)
#seta os arquivos estaticos , css e javascript
urlpatterns += patterns('',
(r'^/css/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':'/home/lioy/django_projects/terrasis/css/'}),
(r'^/js/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':'/home/lioy/django_projects/terrasis/js/'}),
)
the include('cliente.urls') :
urlpatterns = patterns('cliente.views',
(r'^$', 'home'),
(r'^cliente/cadastro/$', 'cadastro'),
)
how can i managed that ?
In your base.html
file you should make sure to use absolute paths instead of relative.
This is an example of an absolute path (note the leading forward-slash):
<a href="/cliente/cadastro/">A client</a>
<!-- ^ leading slash -->
And this is what you should probably avoid:
This is an example of a relative path (no leading forward-slash):
<a href="cliente/cadastro/">ay, que barbaridad</a>
<!-- ^ no leading slash -->
精彩评论