Django部署,所有链接都以index.wsgi为前缀(Django deployment, all links are prepended with index.wsgi)
我想在Apache和mod_wsgi的Ubuntu服务器中部署我的django应用程序。 我正在关注本教程http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
在我的网站文件中
<VirtualHost *:80> ServerAdmin webmaster@mydomain.com ServerName mydomain.com ServerAlias www.mydomain.com WSGIScriptAlias / var/www/index.wsgi Alias /static/ /var/www/static/ <Location "/static/"> Options -Indexes </Location > </VirtualHost >
不要介意通用的mydomain.com条目。 该网站仅用于进度显示,因此我可以与我的朋友讨论。
在/var/www/index.wsgi我有这个
import os import sys import site # Add the site-packages of the chosen virtualenv to work with site.addsitedir('/home/voger/venvs/ssite/local/lib/python2.7/site-packages') # Add the app's directory to the PYTHONPATH sys.path.append('/home/voger/projects/ssite') sys.path.append('/home/voger/projects/ssite/ssite') os.environ['DJANGO_SETTINGS_MODULE'] = 'ssite.settings' # Activate your virtual env activate_env=os.path.expanduser("/home/voger/venvs/ssite/bin/activate_this.py") execfile(activate_env, dict(__file__=activate_env)) import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
在我的settings.py中,登录和注销后我有两行用于重定向。 这些不是在index.wsgi之前添加的
LOGIN_REDIRECT_URL = '/login_redirect' ACCOUNT_LOGOUT_REDIRECT_URL = "/logout_redirect"
当请求这些URL时,它返回404
Reverse for 'login_redirect' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
在我的HTML中,我有4个链接
<a id="logout" style="display: inline-block;" href="/index.wsgi/accounts/logout/">Logout</a> <a id="profile" style="display: inline-block;" href="/accounts/profile">My Account</a> <a id="signup" style="display: none;" href="/index.wsgi/accounts/signup/">Sign Up</a> <a id="login" style="display: none;" href="/index.wsgi/accounts/login/">Sign In</a>
正如您所看到的,使用{%url%}插入的3个条目会自动添加到/index.wsgi中,而唯一一个硬编码的条目不会被添加到前面。 但他们仍然按预期工作。
为什么我要预先添加/index.wsgi,如何删除它? 在我的开发机器上使用django的内置服务器一切正常。
我不知道它是否相关,但登录,注销和注册网址是由django-allauth提供的。
感谢您的任何回答或评论
I want to deploy my django app in a Ubuntu server with Apache and mod_wsgi. I am following this tutorial http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
in my site file I have
<VirtualHost *:80> ServerAdmin webmaster@mydomain.com ServerName mydomain.com ServerAlias www.mydomain.com WSGIScriptAlias / var/www/index.wsgi Alias /static/ /var/www/static/ <Location "/static/"> Options -Indexes </Location > </VirtualHost >
Don't mind the generic mydomain.com entries. The site is for progress display only so I can discuss it with my friend.
in /var/www/index.wsgi I have this
import os import sys import site # Add the site-packages of the chosen virtualenv to work with site.addsitedir('/home/voger/venvs/ssite/local/lib/python2.7/site-packages') # Add the app's directory to the PYTHONPATH sys.path.append('/home/voger/projects/ssite') sys.path.append('/home/voger/projects/ssite/ssite') os.environ['DJANGO_SETTINGS_MODULE'] = 'ssite.settings' # Activate your virtual env activate_env=os.path.expanduser("/home/voger/venvs/ssite/bin/activate_this.py") execfile(activate_env, dict(__file__=activate_env)) import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
in my settings.py I have two lines for redirecting after login and logout. These are not prepended with index.wsgi
LOGIN_REDIRECT_URL = '/login_redirect' ACCOUNT_LOGOUT_REDIRECT_URL = "/logout_redirect"
When these urls are requested it returns 404
Reverse for 'login_redirect' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
In my html I have 4 links
<a id="logout" style="display: inline-block;" href="/index.wsgi/accounts/logout/">Logout</a> <a id="profile" style="display: inline-block;" href="/accounts/profile">My Account</a> <a id="signup" style="display: none;" href="/index.wsgi/accounts/signup/">Sign Up</a> <a id="login" style="display: none;" href="/index.wsgi/accounts/login/">Sign In</a>
and as you can see 3 entries that are inserted with {% url %} are prepended automatically with /index.wsgi while the only one who is hardcoded it is not prepended. But still they work as expected.
Why do I have this /index.wsgi prepended and how can I remove it? In my development machine using django's built in server everything works fine.
I don't know if it is related but the login, logout and signup urls are provided by django-allauth.
Thank you for any answer or comment
原文:https://stackoverflow.com/questions/21505793
最满意答案
子视图继承了alpha值。 而是尝试将背景放置为具有所需alpha的按钮的兄弟。 比按钮“上面”它。
<RelativeLayout> <LinearLayout> Fill parent and alpha = X </LinearLayout> <Button> Placed wherever and alpha = 1 </Button> </RelativeLayout>
The alpha value is inherited for child views. Instead try to place a background as a sibling of the buttons with the required alpha. Than have the buttons "above" it.
<RelativeLayout> <LinearLayout> Fill parent and alpha = X </LinearLayout> <Button> Placed wherever and alpha = 1 </Button> </RelativeLayout>
相关问答
更多-
带有透明背景的WPF窗口包含不透明控件[复制](WPF Window with transparent background containing opaque controls [duplicate])[2022-10-29]
不要设置窗口的不透明度,而要设置其背景的不透明度:子视图继承了alpha值。 而是尝试将背景放置为具有所需alpha的按钮的兄弟。 比按钮“上面”它。Fill parent and alpha = X 如何使用不透明的UIView作为半透明UIView的子视图?(How can I have an opaque UIView as a subview of a semi-transparent UIView?)[2022-04-02]
不,不是真的。 您想要的是使用叠加视图,并使其具有清晰的背景颜色。 作为新叠加层的子视图,您的观点将灰蒙蒙色。 而作为一个同胞的观点,让你的观点,你想是不透明的。 [OpaqueView] [DimmingView] | | [OverlayView] No, not really. What you want is to take your overlay view, and make it just have a clear background colo ...表单加载为半透明的原因是因为表单必须移动到起始位置,触发Move事件。 您可以通过确定是否设置不透明度来确定表单是否已完全加载。 ResizeEnd事件在表单移动完成后触发,所以应该这样工作: bool canMove = false; private void Form1_Load(object sender, EventArgs e) { canMove = true; } private void Form1_Move(object sender, EventArgs e) { i ...您可以创建按钮的样式以扩展默认样式(如果您使用的是Holo.Light): 然后使用style属性手动将样式应用于按钮,或者,如果要更改所有按钮,请在应用主题中设置buttonStyle: