url-pattern

Django1.4: Generic way to set language links in template to work with i18n_patterns?

寵の児 提交于 2019-12-03 12:51:46
I started to play with new i18n_patterns in Django 1.4. Basically, i want to have language links for each of my supported languages on all of my templates headers. I have implemented my header as a separate template that is being included in other templates. Is there a way to keep my header generic and solve this without passing the current view name or current url in template context? I guess it comes to a question how do i retrieve the current view or url from inside the template in a generic way. BTW, i discovered that my previous approach with set_lang view to change the active language

Getting part of request url inside servlet

旧巷老猫 提交于 2019-12-03 12:45:20
问题 I have an EmailVerification Servlet mapped with /ev/* url-pattern. http://example.com/ev/ce52320570 How can I get this ce52320570 part of the URL in my Servlet? protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String vid = ""; // Here I need to get the id from the URL } 回答1: Considering a Servlet (called EmailVerification ) mapped to /ev/* : Will the URL http://example.com/ev/ce52320570 trigger the EmailVerification servlet

Why can't I get my static dir to work with django 1.3?

为君一笑 提交于 2019-12-03 10:58:42
问题 This problem is very simple, but I just can't figure it out added to my urlpatterns url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/user/www/site/static'}) where my main.css is : /home/user/www/site/static/css/main.css when I access http://localhost:8000/static/ I get: 404: Directory indexes are not allowed here. when I access http://localhost:8000/static/css/main.css I get: 404: 'css/main.css' could not be found What am I doing wrong? Fixed it: url(r'

Django 1.6 and django-registration: built-in authentication views not picked up

左心房为你撑大大i 提交于 2019-12-03 06:57:51
问题 I am trying to upgrade my webapp from Django 1.5 to Django 1.6 and as part of my set of django apps I am using django-registration 1.0. After upgrading to Django 1.6 my app does not recognize the built-in authentication views any more. They are integrated in django registration as can be seen here, but they stopped working. The Django release notes describe a change in the way these views should be integrated, when comparing that to the source code in the registration-app that looks fine. I

Error: /login.xhtml Not Found in ExternalContext as a Resource

纵饮孤独 提交于 2019-12-03 06:18:00
I'm using JBoss 7.1 with JSF 2.1/Prime Faces and keep running into the error listed in the title. I've tried many of the suggestions made here and all end up with the same error. File structure is: WEB-INF faces login.xhtml I have the following in web.xml: <display-name>clientAccountManager</display-name> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.PROJECT

Why can't I get my static dir to work with django 1.3?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 00:32:53
This problem is very simple, but I just can't figure it out added to my urlpatterns url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/user/www/site/static'}) where my main.css is : /home/user/www/site/static/css/main.css when I access http://localhost:8000/static/ I get: 404: Directory indexes are not allowed here. when I access http://localhost:8000/static/css/main.css I get: 404: 'css/main.css' could not be found What am I doing wrong? Fixed it: url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT } ), in settings

Django 1.6 and django-registration: built-in authentication views not picked up

痞子三分冷 提交于 2019-12-02 20:36:39
I am trying to upgrade my webapp from Django 1.5 to Django 1.6 and as part of my set of django apps I am using django-registration 1.0 . After upgrading to Django 1.6 my app does not recognize the built-in authentication views any more. They are integrated in django registration as can be seen here , but they stopped working. The Django release notes describe a change in the way these views should be integrated , when comparing that to the source code in the registration-app that looks fine. I am introducing the registration urls as follows: urlpatterns = patterns('', ..., url(r'^accounts/',

Django - Strange behavior using static files

二次信任 提交于 2019-12-02 11:59:51
I'm new to Django. I'm getting insane trying to understand what is going on with static files(css's and images). The resume of the problem is the following... when I use static views from a 3rd party App(Haystack) I can't use static files. My project have this directory structure: 1001empbr (name of the folder for the project) | |------ 1001emp (name of the django project) | |------ 1001empbr (name of my App) |------ site_media (folder with static files CSS/JPG/GIF) |------ templates (folder with the templates) When I use urlpatterns(urls.py) like this works great: import os.path # Para poder

request.POST empty after upgrading from Django 1.11 to Django 2.1

我们两清 提交于 2019-12-02 11:49:51
This post is a follow-up of this previous question: Django request.POST empty I had a project up and running with Python 3.5.4 and Django 1.11.13 , on Visual Studio 2015. I later updated to Django 2.1.2 because I wanted to import the "path" module, so that I can use this: urlpatterns = [ path ( '', c_views.Indice, name = 'indice' ), path ( '<int:CompiladoID>', c_views.Detalle, name = 'detalle'), path ( 'elementos/<int:CompiladoID>', c_views.Elementos, name = 'elementos'), path ( 'datoselementos/<int:ElementoID>', c_views.DatosElemento, name = 'datoselemento'), ...instead of this: urlpatterns =

你真的理解SpringMVC DispatcherServlet中的映射了吗?

故事扮演 提交于 2019-12-02 09:47:10
一、Request URL 与 Servlet url-pattern匹配顺序与关系 当一个请求发送到 servlet 容器(服务器)的时候,容器先会将请求的 url 减去当前应用上下文的路径,就是 scheme://ip:port/context 的 url 作为 servlet 的映射 url ,访问的是 http://localhost:8080/test/index.html ,我的应用上下文( context )是 test ,容器会将 http://localhost:8080/test 去掉,剩下的 /index.html 部分拿来和 servlet 的 url-pattern 进行匹配。 1. 精确路径匹配 ( 完全匹配 ) 以 ”/” 开始的,不包含通配符 * (不以通配符结尾)的,例如: <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/index.html</url-pattern> </servlet-mapping> 2. 最长路径匹配(路径匹配) 以 ”/” 开始的,并且以通配符 * 结尾的(通配符只能在结尾,不能放中间。例如, /index/te*/index.html 这样的) <servlet-mapping> <servlet-name>default<