login page shouldn't open when I am already logged in, but it does !
Hi all I am trying to build a login page using Django auth app, it is all working nice but there is one problem: If I browse to accounts/login (the login url) when I am already logged in, in normal situation the login view shouldn't be rendered and the correct action will be to redirect to the home page/the request url/etc.. But this just doesn't happen ! It renders the login view normally as if I am not logged in! I even checked the source code, and indeed it doesn't check whether the user is already logged in. So is this a bug or something ? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/YtY426bWAiUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: login page shouldn't open when I am already logged in, but it does !
ookie_session_id is set): > > calculate new_cookie_session_id(remarkable data_headers, database > information,...) //through concatenation and hashes > if (new_cookie_session_id == cookie_session_id, > *and the session is not expired*): > return redirection_to_main_page > else: > *make sure that the user is not authenticated and clear > the foreign key entry if needed (that is to say if it exists and the > session is outdated)* > return > what_should_be_the_template_that_allows_the_user_to_identify_him_self > else: > return > what_should_be_the_template_that_allows_the_user_to_identify_him_self > > > *submit_page* > /* after the user gets to give his own parameters and submit the form > you should manage the data with a view function that sets the > cookie_session_id for the session */ > > > if(the_user_has_the_right_to_authenticate_with_submitted_values): > calculate cookie_session_id(remarkable data_headers, database > information,...) > set cookie_session_id > *add according entry in the foreignkey field, adding it as well > in the sessionid table* > return the_user_main_page > else: > return an_error_and_allow_your_user_to_log_again // or something > of that kind > > > I hope I gave you sufficient hints. > Feel free to ask for more explanations if needed. I would be happy to help > > Regards, > > > 2012/11/20 Loai Ghoraba > > >> Hi all >> >> I am trying to build a login page using Django auth app, it is all >> working nice but there is one problem: If I browse to accounts/login (the >> login url) when I am already logged in, in normal situation the login view >> shouldn't be rendered and the correct action will be to redirect to the >> home page/the request url/etc.. >> >> But this just doesn't happen ! It renders the login view normally as if I >> am not logged in! >> I even checked the source code, and indeed it doesn't check whether the >> user is already logged in. >> >> So is this a bug or something ? >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/YtY426bWAiUJ. >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yQKXbP_uCW0J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: login page shouldn't open when I am already logged in, but it does !
Thanks for user.is_authenticated(), , but Django built in login view function doesn't call it before executing. So I guess I have to wrap Django login myself when using it. So the code will change to be this, I use this to wrap only Django login function-since I cannot modify it-, otherwise I can use user.is_authenticated(). def check_not_login(view): def new_view(request,*args,**kwargs): #the user is already logged in, redirect to the home page if request.user.is_authenticated(): return HttpResponseRedirect('/faculty/') return view(request,*args,**kwargs) return new_view On Wednesday, November 21, 2012 2:51:49 PM UTC+2, Daniel Roseman wrote: > > On Wednesday, 21 November 2012 12:04:45 UTC, Loai Ghoraba wrote: > >> Well, thanks very much for your effort-y reply. I have read it and it is >> useful, though it requires a second reading to recap :) >> >> Well, I thought of a simple solution and it worked: just having a >> wrapping function around django login such that it checks whether the use >> is logged in or not before viewing the login page. I had to import the >> SESSION_KEY variable used by django to set the user session. I think this >> is a bad thing since they may change the variable name in future releases, >> however they don't provide a getter method for it. >> >> cod: /* myview.py */ >> from django.contrib.auth import SESSION_KEY >> >> >> def check_not_login(view): >> def new_view(request,*args,**kwargs): >> #the user is already logged in, redirect to the home page >> if SESSION_KEY in request.session: >> if request.session[SESSION_KEY]==request.user.id: >> return HttpResponseRedirect('/faculty/') >> return view(request,*args,**kwargs) >> return new_view >> >> /*urls.py*/.. >> url(r'^accounts/login/$', check_not_login(login)) >> .. >> and it is working :) >> >> On Wednesday, November 21, 2012 12:54:43 AM UTC+2, Issam Outassourt wrote: >>> >>> Hi, >>> >>> Well what you could do actually, and it's of commun use is to give your >>> user a session-cookie id, which you can generate based on some informations >>> in the header, typically his login, his ip adress, his password, his >>> user-agent... >>> As he tries to get the login page, challenge him by checking if the >>> cookie is set. >>> If it is set, you should recompute the value and check wether it >>> matches. If it does, then you can redirect the response to another url, >>> otherwise you show back the login page. >>> >>> Well, i'll give you the structure of the code : >>> >>> *login page* >>> >>> if(cookie_session_id is set): >>> >>> calculate new_cookie_session_id(remarkable data_headers, >>> database information,...) //through concatenation and hashes >>> if (new_cookie_session_id == cookie_session_id): >>> return redirection_to_main_page >>> else: >>> return >>> what_should_be_the_template_that_allows_the_user_to_identify_him_self >>> else: >>> return >>> what_should_be_the_template_that_allows_the_user_to_identify_him_self >>> >>> >>> *submit_page* >>> /* after the user gets to give his own parameters and submit the form >>> you should manage the data with a view function that sets the >>> cookie_session_id for the session */ >>> >>> >>> if(the_user_has_the_right_to_authenticate_with_submitted_values): >>> calculate cookie_session_id(remarkable data_headers, database >>> information,...) >>> set cookie_session_id >>> return the_user_main_page >>> else: >>> return an_error_and_allow_your_user_to_log_again // or >>> something of that kind >>> >>> DONE ! >>> The idea behind that is that if the facility is not offered or you did >>> not afford the time to check the documentation, you can try to solve your >>> problem by your own. Yet more, you should consider checking the >>> cookie_session_id any time the user tries to browse a page that contains >>> sensitive or not public information. What would help you do so is to add a >>> widget in all pages that shows the login_form if not logged or >>> login+photo+profile_link (be creative and make sure you check what happens >>> secu
Javascript in external file not working
Hi all When I have a script like this: window.onload=function f(){} it is working fine. but when I create an external js file and put it within the static directory, and call the function like this window.onload=f It is not working at all. (by the way the url is mapped correctly to the js file "I tested it via viewing the source of the web page") Any idea? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/m9Dv6qeozQQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Where to put PDF files + how to authenticate the urls requesting them
Hi I have a little question: First, I am hosting my PDF files within / static directory, (as my understanding is that they are static files), so is this the correct way to host PDF files and downloadable files generally ? Second: Only authenticated users may view the links for those PDF files, but what if someone knows the url of the files ? he can just get them. So how to authenticate a url call to a static file ? Thanks alot -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Where to put PDF files + how to authenticate the urls requesting them
Thanks for the reply, but I am still new to the web technology world, so I would like to fully use Django now before , moving to another ways to host my files. Actually I am totally new to serving stuff, so if there is some best practice or that my way is totally wrong, please tell me. So in short: is there a way to provide some kind of authentication against /static/whatever urls ? Because I want Django to host the file now Also, assuming I found someway to do this, django says that to mark a file as downloadable, we can do this https://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment >>> response = HttpResponse(my_data, >>> content_type='application/vnd.ms-excel')>>> response['Content-Disposition'] >>> = 'attachment; filename="foo.xls"' Now what is the type of my_data? any file object ? Thanks a lot. On Wednesday, November 28, 2012 5:08:11 PM UTC+2, Javier Guerra wrote: > > On Wed, Nov 28, 2012 at 10:03 AM, Javier Guerra Giraldez > > wrote: > > i think there are a couple Django apps that help with that, while also > > abstracting the differences between servers. > > found these: > > https://gist.github.com/1776202 > https://github.com/johnsensible/django-sendfile > > > -- > Javier > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/5lsWnXK9eRQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to make a url pattern that catch any url ?
Hi I am serving some files, and I want whenever I have a url :/download/path/to/some/file to map this to a view function with path/to/some/file sent as a parameter of the function, so how could I accomplish that ? I want a url of the following schema : url(r'downloads/(?P\[Anything including backslashes])$', 'download_file'), Thanks a lot. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_cVverOl0AoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to make a url pattern that catch any url ?
I just go it, it is url(r'^download/(?P.*)$', 'faculty.views.Main.download_file'), Thanks :) On Wed, Nov 28, 2012 at 10:10 PM, Loai Ghoraba wrote: > Hi > > I am serving some files, and I want whenever I have a url > :/download/path/to/some/file to map this to a view function with > path/to/some/file sent as a parameter of the function, so how could I > accomplish that ? > > I want a url of the following schema : > url(r'downloads/(?P\[Anything including backslashes])$', > 'download_file'), > > Thanks a lot. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/_cVverOl0AoJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to make a url pattern that catch any url ?
thanks for the important advise :) On Wed, Nov 28, 2012 at 10:28 PM, Tim Chase wrote: > On 11/28/12 14:19, Loai Ghoraba wrote: > > I just go it, it is > > > > url(r'^download/(?P.*)$', 'faculty.views.Main.download_file'), > > Just be careful to normalize the resulting path so that people don't > do things like > > http://example.com/download/../../etc/passwd > > Fortunately, the standard library has functions in os.path.* for > getting the absolute path, checking against leading subdirectory > paths, and the like. > > -tkc > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Where to put PDF files + how to authenticate the urls requesting them
I am still new to sreving stuff (in fact I know barely anything about it :)) Then you instruct to have something like this url(r'^media/(?P.*)$', 'myview,func', { 'document_root': MEDIA_ROOT, }), and my func have the instructions to the real web servers ? And another question: Does this applies also to light static files like css and javascript ? Thanks a lot On Thu, Nov 29, 2012 at 1:15 PM, Tom Evans wrote: > On Wed, Nov 28, 2012 at 6:27 PM, Loai Ghoraba wrote: > > Thanks for the reply, but I am still new to the web technology world, so > I > > would like to fully use Django now before , moving to another ways to > host > > my files. > > Actually I am totally new to serving stuff, so if there is some best > > practice or that my way is totally wrong, please tell me. > > > > So in short: is there a way to provide some kind of authentication > against > > /static/whatever urls ? Because I want Django to host the file now > > Also, assuming I found someway to do this, django says that to mark a > file > > as downloadable, we can do this > > > > > https://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment > > > >>>> response = HttpResponse(my_data, > >>>> content_type='application/vnd.ms-excel') > >>>> response['Content-Disposition'] = 'attachment; filename="foo.xls"' > > > > > > Now what is the type of my_data? any file object ? > > > > A string, or any file like object - it's just like any HttpResponse. > > You do not want to do this though, using Django to download static > files is very wasteful. Others have pointed out solutions where you > use django to authenticate the request, and then instruct your web > server (eg Apache, nginx) to serve the correct file, which will be an > order of magnitude more efficient. > > Django is never served by itself, there should always be a real web > server in front of it. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Where to put PDF files + how to authenticate the urls requesting them
I read it and it seems nice, I will further read about the topic Thanks a lot for the help :) On Thu, Nov 29, 2012 at 1:44 PM, Tom Evans wrote: > On Thu, Nov 29, 2012 at 11:30 AM, Loai Ghoraba wrote: > > I am still new to sreving stuff (in fact I know barely anything about it > :)) > > Then you instruct to have something like this > > > > url(r'^media/(?P.*)$', 'myview,func', { > > 'document_root': MEDIA_ROOT, > > }), > > > > and my func have the instructions to the real web servers ? > > Read up on X-Sendfile and if anything doesn't make sense, ask some > questions on here. > > http://stackoverflow.com/questions/7296642/django-understanding-x-sendfile > > > > > And another question: Does this applies also to light static files like > css > > and javascript ? > > It applies to any file you want to control access to via django. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django apache mod_wsgi permission denied
Hi I have installed apache and mod_wsgi and my basic site *skeleton is running* on local host, but with NO static files loaded such as css, when I try to access a static file (e.g:http://localhost/static/css/base.css) it says that I don't have permission to access the file, same goes to media files I have followed the steps in the presentation slides http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf and made the directories accessible to others via chmod o+rx , my httpd.conf part is : WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py WSGIPythonPath /home/loai/workspace/Faculty Alias /media/ /home/loai/workspace/Faculty/Faculty/media Alias /static/ /home/loai/workspace/Faculty/Faculty/static Order deny,allow Allow from all Order deny,allow Allow from all Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LG9AgaTxaWAJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
I have ran chmod o+rx on the root directory, isn't this enough (isn't chmod applied to all folders down recursively ?) ? and I have checked the directories from the root down to static, all have the permission of drwxr-xr-x On Sat, Dec 1, 2012 at 2:21 AM, Chris Cogdon wrote: > Make sure all the directories, from static leading all the way up to the > root, are chmod a+x > > > On Friday, November 30, 2012 4:00:55 PM UTC-8, Loai Ghoraba wrote: >> >> Hi >> >> I have installed apache and mod_wsgi and my basic site *skeleton is >> running* on local host, but with NO static files loaded such as css, when I >> try to access a static file >> (e.g:http://localhost/static/**css/base.css<http://localhost/static/css/base.css>) >> it says that I don't have permission to access the file, same goes to media >> files >> >> I have followed the steps in the presentation slides >> http://code.google.com/**p/modwsgi/downloads/detail?** >> name=mod_wsgi-pycon-sydney-**2010.pdf<http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf> >> and >> made the directories accessible to others via chmod o+rx >> , my httpd.conf part is : >> >> WSGIScriptAlias / /home/loai/workspace/Faculty/**Faculty/wsgi.py >> WSGIPythonPath /home/loai/workspace/Faculty >> >> Alias /media/ /home/loai/workspace/Faculty/**Faculty/media >> Alias /static/ /home/loai/workspace/Faculty/**Faculty/static >> >> >> Order deny,allow >> Allow from all >> >> >> >> Order deny,allow >> Allow from all >> >> >> Thanks >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/L3Sm-aDXA_UJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
thanks, but still I can't find what's wrong with the permission thing. The html pages are loaded without static content, no css or js or whatever, neither the media is accessible. On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst wrote: > On 1/12/2012 3:57pm, Loai Ghoraba wrote: > >> thanks, but I have tried this now and it also doesn't work :X though the >> author slides presentation mentioned chmod o+rx on the root dir only. >> >> On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst > <mailto:mi...@dewhirst.com.au>**> wrote: >> >> chmod -R o+rx >> > > Here is my working apache2 conf for project "proj" on site mydomain.com. > It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj > directories and files rwxrwx--- > > This is because I need users in the group to have access but no-one from > outside. Apache is the owner. > > Good luck > > Mike > > # proj ##**### > > > > # proj resolves to lenny 109 > DocumentRoot /var/www/proj/htdocs/ > ServerName proj.mydomain.com > ServerAdmin webmas...@mydomain.com > > HostnameLookups Off > UseCanonicalName Off > > ErrorLog ${APACHE_LOG_DIR}/proj-error.**log > CustomLog ${APACHE_LOG_DIR}/proj-access.**log combined > > Alias /robots.txt /var/www/static/proj/robots/**robots.txt > Alias /favicon.ico /var/www/static/proj/img/proj.**ico > > # lock the public out > > AllowOverride None > Order deny,allow > Deny from all > > > # serve uploaded media from here > > AllowOverride None > > Order deny,allow > Allow from all > > > # serve static stuff from here > > AllowOverride None > > Order deny,allow > Allow from all > > > > Alias /media/ /var/www/media/proj/ > Alias /static/ /var/www/static/proj/ > Alias /tiny_mce/ /var/www/static/proj/js/tiny_**mce/ > Alias /jquery/ /var/www/static/proj/js/**jquery/ > > > >WSGIScriptAlias / /var/www/proj/proj/proj.wsgi > > > Order deny,allow > Allow from all > > > > > > > > > > > >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscribe@**googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >> . >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to django-users+unsubscribe@** > googlegroups.com . > For more options, visit this group at http://groups.google.com/** > group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> > . > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
a strange thing is that when I remove the directive so it becomes: Order deny,allow Allow from all instead of Order deny,allow Allow from all then trying to access any static or media file raises (not found) instead of permission denied ! On Sat, Dec 1, 2012 at 7:42 AM, Loai Ghoraba wrote: > thanks, but still I can't find what's wrong with the permission thing. The > html pages are loaded without static content, no css or js or whatever, > neither the media is accessible. > > > > On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst wrote: > >> On 1/12/2012 3:57pm, Loai Ghoraba wrote: >> >>> thanks, but I have tried this now and it also doesn't work :X though the >>> author slides presentation mentioned chmod o+rx on the root dir only. >>> >>> On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst >> <mailto:mi...@dewhirst.com.au>**> wrote: >>> >>> chmod -R o+rx >>> >> >> Here is my working apache2 conf for project "proj" on site mydomain.com. >> It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj >> directories and files rwxrwx--- >> >> This is because I need users in the group to have access but no-one from >> outside. Apache is the owner. >> >> Good luck >> >> Mike >> >> # proj ##**### >> >> >> >> # proj resolves to lenny 109 >> DocumentRoot /var/www/proj/htdocs/ >> ServerName proj.mydomain.com >> ServerAdmin webmas...@mydomain.com >> >> HostnameLookups Off >> UseCanonicalName Off >> >> ErrorLog ${APACHE_LOG_DIR}/proj-error.**log >> CustomLog ${APACHE_LOG_DIR}/proj-access.**log combined >> >> Alias /robots.txt /var/www/static/proj/robots/**robots.txt >> Alias /favicon.ico /var/www/static/proj/img/proj.**ico >> >> # lock the public out >> >> AllowOverride None >> Order deny,allow >> Deny from all >> >> >> # serve uploaded media from here >> >> AllowOverride None >> >> Order deny,allow >> Allow from all >> >> >> # serve static stuff from here >> >> AllowOverride None >> >> Order deny,allow >> Allow from all >> >> >> >> Alias /media/ /var/www/media/proj/ >> Alias /static/ /var/www/static/proj/ >> Alias /tiny_mce/ /var/www/static/proj/js/tiny_**mce/ >> Alias /jquery/ /var/www/static/proj/js/**jquery/ >> >> >> >>WSGIScriptAlias / /var/www/proj/proj/proj.wsgi >> >> >> Order deny,allow >> Allow from all >> >> >> >> >> >> >> >> >> >> >> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscribe@**googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >>> . >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to django-users+unsubscribe@** >> googlegroups.com . >> For more options, visit this group at http://groups.google.com/** >> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >> . >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
okay it works now, I was just missing a trailing slash at Alias /static/ /home/loai/workspace/Faculty/Faculty/static/ On Sat, Dec 1, 2012 at 8:17 AM, Loai Ghoraba wrote: > a strange thing is that when I remove the directive so it > becomes: > > > Order deny,allow > Allow from all > > > instead of > > > > Order deny,allow > Allow from all > > > > then trying to access any static or media file raises (not found) instead > of permission denied ! > > On Sat, Dec 1, 2012 at 7:42 AM, Loai Ghoraba wrote: > >> thanks, but still I can't find what's wrong with the permission >> thing. The html pages are loaded without static content, no css or js or >> whatever, neither the media is accessible. >> >> >> >> On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst wrote: >> >>> On 1/12/2012 3:57pm, Loai Ghoraba wrote: >>> >>>> thanks, but I have tried this now and it also doesn't work :X though the >>>> author slides presentation mentioned chmod o+rx on the root dir only. >>>> >>>> On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst >>> <mailto:mi...@dewhirst.com.au>**> wrote: >>>> >>>> chmod -R o+rx >>>> >>> >>> Here is my working apache2 conf for project "proj" on site mydomain.com. >>> It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj >>> directories and files rwxrwx--- >>> >>> This is because I need users in the group to have access but no-one from >>> outside. Apache is the owner. >>> >>> Good luck >>> >>> Mike >>> >>> # proj ##**### >>> >>> >>> >>> # proj resolves to lenny 109 >>> DocumentRoot /var/www/proj/htdocs/ >>> ServerName proj.mydomain.com >>> ServerAdmin webmas...@mydomain.com >>> >>> HostnameLookups Off >>> UseCanonicalName Off >>> >>> ErrorLog ${APACHE_LOG_DIR}/proj-error.**log >>> CustomLog ${APACHE_LOG_DIR}/proj-access.**log combined >>> >>> Alias /robots.txt /var/www/static/proj/robots/**robots.txt >>> Alias /favicon.ico /var/www/static/proj/img/proj.**ico >>> >>> # lock the public out >>> >>> AllowOverride None >>> Order deny,allow >>> Deny from all >>> >>> >>> # serve uploaded media from here >>> >>> AllowOverride None >>> >>> Order deny,allow >>> Allow from all >>> >>> >>> # serve static stuff from here >>> >>> AllowOverride None >>> >>> Order deny,allow >>> Allow from all >>> >>> >>> >>> Alias /media/ /var/www/media/proj/ >>> Alias /static/ /var/www/static/proj/ >>> Alias /tiny_mce/ /var/www/static/proj/js/tiny_**mce/ >>> Alias /jquery/ /var/www/static/proj/js/**jquery/ >>> >>> >>> >>>WSGIScriptAlias / /var/www/proj/proj/proj.wsgi >>> >>> >>> Order deny,allow >>> Allow from all >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To post to this group, send email to django-users@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> django-users+unsubscribe@**googlegroups.com >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >>>> . >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to django-users+unsubscribe@* >>> *googlegroups.com . >>> For more options, visit this group at http://groups.google.com/** >>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >>> . >>> >>> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
no I mean the root of my project guys :) thanks a lot :D which lives in path/to/my/project :) On Sat, Dec 1, 2012 at 11:42 AM, Timothy Makobu wrote: > Root directory??? As in / ? Nooo nonono > > > On Sat, Dec 1, 2012 at 12:14 PM, Chris Cogdon wrote: > >> >> >> On Friday, November 30, 2012 8:53:42 PM UTC-8, Mike Dewhirst wrote: >>> >>> On 1/12/2012 3:48pm, Loai Ghoraba wrote: >>> > I have ran chmod o+rx on the root directory, isn't this enough (isn't >>> > chmod applied to all folders down recursively ?) ? >>> >>> No. You need chmod -R o+rx >>> >> >> Oh hell no, don't do that... that will impact the ENTIRE FILESYSTEM >> >> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/cB-WWrnMMP8J. >> >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django login twice required when using xsendfile with apache
Hi I am using apache2 server with xsend file to protect against static files, the python view is: @staff_member_required def media_xsendfile(request, path, document_root): print "is staff",request.user.is_staff response = HttpResponse() response['Content-Disposition'] = 'attachment' response['X-Sendfile'] = (os.path.join(document_root, path)).encode('utf-8') return response and in apache httpd.conf XSendFile on XSendFilePath /path/to/files/ If the user is not a staff member, he is redirected correctly to the login page and once he login, the file is download, this is only in the local development server, however when I use apache server, after the first login nothing happens (the login page is still there) and he has to login again.for the file to be downloaded. Any clue ? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_5o_fX1N6n0J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django login twice required when using xsendfile with apache
and another issue: using apache, even when the user is logged in and is_staff, he is redirected to the login page, and he needs to login to download the file, and this continues on. On Sat, Dec 1, 2012 at 7:30 PM, Loai Ghoraba wrote: > Hi > > I am using apache2 server with xsend file to protect against static files, > the python view is: > > @staff_member_required > def media_xsendfile(request, path, document_root): > print "is staff",request.user.is_staff > response = HttpResponse() > response['Content-Disposition'] = 'attachment' > response['X-Sendfile'] = (os.path.join(document_root, > path)).encode('utf-8') > return response > > and in apache httpd.conf > > XSendFile on > XSendFilePath /path/to/files/ > > If the user is not a staff member, he is redirected correctly to the login > page and once he login, the file is download, this is only in the local > development server, however when I use apache server, after the first login > nothing happens (the login page is still there) and he has to login > again.for the file to be downloaded. > > Any clue ? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/_5o_fX1N6n0J. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django apache mod_wsgi permission denied
Thanks a million for the tip :) On Sun, Dec 2, 2012 at 5:08 AM, Chris Cogdon wrote: > > > On Saturday, December 1, 2012 3:47:39 AM UTC-8, Loai Ghoraba wrote: >> >> no I mean the root of my project guys :) thanks a lot :D which lives in >> path/to/my/project :) >> > > Oh thank god for that! > > I'd actually done something similiar once... I'd removed a bunch of > permissions using chmod -R / rather than chmod -R . ... This was on an > oldold NCR Tower 32 running SVR3. I ended up writing a program to go > through the archives on tape (yes, tape) and copy only the permission bits > from all the tape files. > > Anyway, a better form of that command is chmod -R a+rX > > The capital X means "only set the execute bit if any execute bits are > set". If you use lower-case x, then you'll send up setting the execute bit > for normal files, too, which is another potential security risk. If you > want to fix this up, do: > > find . -type f -print0 | xargs -0 chmod a-x > chmod a+x manage.py # Restore x for the Django management command > > Protip: always use the -print0 | xargs -0 form of the "find/xargs" > pattern, as this will prevent spaces in your paths from causing havoc. > > I wish I knew of a better way to set the x bits all the way up the tree, > without giving someone a program to run, the best I can come up with is: > > cd static > chmod a+x . .. ../.. ../../.. ../../../.. ../../../../.. ../../../../../.. > ../../../../../../.. > > and hope that's enough :) > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/_8jpEFytyesJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'
Hi I have this in my urls.py url(r'^accounts/login/$', login,name="accounts-login") and in a template base.html login And when I try to open the site, this error is raised: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login' But when I change the name of the url in both urls.py and base.html to something without the score '-', it works: like :accountslogin. So are scores banned in named urls ? I have seen scored-named-urls in the documentation ! Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/g19mRQ4vHd4J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'
not working, giving: Reverse for '' with arguments '()' and keyword arguments '{}' not found. also I want to know about this dash (sorry for using the term score in the previous post ) thing On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma wrote: > {% url auth_login %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template syntax error: Could not parse the remainder: '-login' from 'accounts-login'
okay I found it: it should be login with quotes. Thanks. On Mon, Dec 3, 2012 at 2:50 PM, Loai Ghoraba wrote: > not working, giving: Reverse for '' with arguments '()' and keyword > arguments '{}' not found. > > also I want to know about this dash (sorry for using the term score in the > previous post ) thing > > On Mon, Dec 3, 2012 at 2:34 PM, Nikhil Verma wrote: > >> {% url auth_login %} > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django ajax HTTP 500 when trying to access request.GET
Hi all I am trying to write a simple ajax that tries to know whether the username already exist before registering. Whenever I try to access the request.GET in my view function, a HTTP 500 error is raised, if the view function doesn't access it and only use hard coded values-for test- it works. Any help ? My code is : jquery: function checkUserNameUnique() { $.ajax({url:"/ajax/", data:{username:$("input.username").val()}, success: function(result){ $("span#usernameMessage").text(result); } } ); } view: def ajax(request): username=request.GET["username"] msg="" try: user=User.objects.get(username=username) msg="username is okay" except User.DoesNotExist: msg="username already exists" return HttpResponse(msg); -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Acr4kmnJtSYJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django ajax HTTP 500 when trying to access request.GET
the problem is solved now, seems rebooting sometimes works :) ! On Tue, Dec 11, 2012 at 2:04 AM, Loai Ghoraba wrote: > Hi all > > I am trying to write a simple ajax that tries to know whether the username > already exist before registering. > Whenever I try to access the request.GET in my view function, a HTTP 500 > error is raised, if the view function doesn't access it and only use hard > coded values-for test- it works. > > Any help ? > > My code is : > jquery: > > function checkUserNameUnique() > { > $.ajax({url:"/ajax/", > data:{username:$("input.username").val()}, > success: function(result){ > $("span#usernameMessage").text(result); > } > } > ); > } > view: > def ajax(request): > username=request.GET["username"] > msg="" > try: > user=User.objects.get(username=username) > msg="username is okay" > except User.DoesNotExist: > msg="username already exists" > return HttpResponse(msg); > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/Acr4kmnJtSYJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Converting Django app into a Desktop app
Hi I am very comfortable with Django, and I was wondering about whether there is some way to convert a Django web app into a Desktop app (may be not 100%), so that I can distribute it to users. May be wrapping it in a light web server "if there is something like this". Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-kBVrtdpjo4J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting Django app into a Desktop app
@ all thanks for your responses, I will try to investigate them @Chris: you got me right :) I can use runserver, but it would be too light, or make the client install and configure apache (which is not a good idea if the client is a normal user, not a programmer). On Tue, Dec 18, 2012 at 9:23 PM, Chris Cogdon wrote: > I think what Loai is asking for is a way to "wrap up" the python/django > application, along with a light-weight webserver (not as light-weight as > "runserver" though), so it looks like a stand-alone application... apart > from needing to run a web browser to connect to it. > eNo module named _tkinter, please install the python-tk package > I, too, am very interested in this. > > Just doing some cursory poking around, here's some starting points: > > Python Freeze: http://wiki.python.org/moin/Freeze > > cx_Freeze: http://cx-freeze.sourceforge.net > > Py2Exe: http://wiki.python.org/moin/Py2Exe > > py2app: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html > > > These handle turning the python program into a stand-alone executable. It > doesn't solve the web-server issue, though. There are a ton of choices > there (eg: gunicorn, twisted, tornado, web.py) but I have no opinion on > which one is going to both "freeze" well, serve static files well, and work > well with Django > > > > On Tuesday, December 18, 2012 8:06:19 AM UTC-8, Loai Ghoraba wrote: >> >> Hi >> >> I am very comfortable with Django, and I was wondering about whether >> there is some way to convert a Django web app into a Desktop app (may be >> not 100%), so that I can distribute it to users. May be wrapping it in a >> light web server "if there is something like this". >> >> Thanks >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/ruJ-QX6bLO8J. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting Django app into a Desktop app
@all thanks a lot, I will try your suggestions, may be mixing them :) On Tue, Dec 18, 2012 at 11:39 PM, Chris Cogdon wrote: > Personally, I'd prefer something that didn't require packaging up > additional programs (xampp and python, in this example). > > It should be _perfectly possible_ to find a native-python moderate > performance webserver, then wrap up that, django, the application and the > python interpreter into a single package. > > > > On Tuesday, December 18, 2012 12:14:59 PM UTC-8, peter_julian wrote: >> >> Don't realy mathers is xampp comes or not with python, you just need to >> add wsgi module to xampp. and then configure your app to run from >> xampp. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/pRN_aCJPT8sJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting Django app into a Desktop app
thanks a lot, I will look at them if I have time :) On Sat, Mar 2, 2013 at 3:00 AM, Czarek Tomczak wrote: > Hi Loai, > > Have a look at CEF Python that embeds Chrome browser: > https://code.google.com/p/cefpython/ > You will need to run a web server to convert it into a desktop > application, have a look > at CefBottleDesktop <https://github.com/eristoddle/CefBottleDesktop> that > embeds CEF and runs a python web server along with > bottle.py <https://github.com/defnull/bottle> framework. > > Also have a look at Python Desktop that embeds Internet Explorer browser > and > Mongoose web server: > https://code.google.com/p/phpdesktop/wiki/EmbeddingOtherScriptingLanguages > > I am the author of both projects. > > Cheers, > Czarek. > > > On Tuesday, December 18, 2012 8:06:19 AM UTC-8, Loai Ghoraba wrote: > >> Hi >> >> I am very comfortable with Django, and I was wondering about whether >> there is some way to convert a Django web app into a Desktop app (may be >> not 100%), so that I can distribute it to users. May be wrapping it in a >> light web server "if there is something like this". >> >> Thanks >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/-VGqvHew35g/unsubscribe?hl=en > . > To unsubscribe from this group and all its topics, send an email to > django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.