Re: mod_wsgi using a subpath in combination with a middleware that calls django.core.urlresolvers.resolve is not working
Op maandag 26 november 2012 19:50:50 UTC+1 schreef ke1g het volgende: > > > > On Thu, Nov 22, 2012 at 11:28 AM, Jan Murre > > wrote: > >> Hi, >> >> I have the following peculiar problem that is very easy to reproduce. >> I use a simple middleware the attaches the 'app_name' that is defined in >> the urlconf to 'request.user' for subsequent use. >> >> >> from django.core.urlresolvers import resolve >> >> class ApplicationAwareMiddleware(object): >> """ >> Middleware class that determines the name of the application of the >> current >> view and attaches that to the current user. >> """ >> >> def process_request(self, request): >> >> request.user.app_name = resolve(request.path).app_name >> - >> >> This middleware kills Django's urls resolution when used with mod_wsgi >> using a suppath, like: >> >> WSGIScriptAlias /subpath /django.wsgi >> >> It seems that the call to 'django.core.urlresolvers.resolve' has some >> kind of nasty side-effect. >> >> I tried things like delaying the call to 'resolve', but to no avail. >> Pointers anyone? >> >> Regards, Jan >> >> >> Are you figuring out the url resolution on your own? I would have > thought that you would use process_view(), so that the view function has > already been looked up, and you can just introspect it. > > I'd be worried that the anonymous user shouldn't be modified. I'd add the > decoration to the request, or maybe request.META, rather than the user. > > It might be cleaner yet to write a decorator for your view that adds the > information as an early positional argument (say, just after request) at > call time. This also allows you to avoid the work for views that don't > need it. > > Or if you're doing this to views that are outside of your control, so that > you couldn't decorate them, maybe I see why you want to put the data on the > user. If so, do check that the anonymous user accepts attribute setting. > And I believe that request.user is a lazy object, so try referencing, say, > request.user.email before you modify the user object, to see if that makes > a difference. > > Bill > > Bill > Hi Bill, Thanx for your help. Using process_view is not helping in this case. Alhough I can introspect the view function, I cannot get hold of "app_name". For that I really need 'reverse'. And the reverse call is causing all the trouble (only when using mod_wsgi on a subpath). I suspect the fact that in 'django.core.urlresolvers' the prefix is stored in a module level variable, but it is hard to pinpoint it, because mod_wsgi and pdb debugging are not working well together (although it is possible). Regards, Jan -- 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/-/hV8e-u2H7w8J. 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.
Enforce HTTPS for authenticated users but HTTP for anonymous
Is there any easy way to have a django site enforce HTTPS for authenticated users while any anonymous users would default to HTTP? This would allow me to protect the sessions and cookies for users who have logged on while conserving server resources for those who aren't authenticated (I would assume the majority of connections). As part of this it would also make sense for me to ensure the login and register pages also use HTTPS to protect any passwords. I'm not sure if it's relevant but I'm using Nginx as a web server with uwsgi dealing with the django requests. 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/-/tUaAAA_NqUUJ. 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: Userprofile, signal and admin inline edit.
Hello Jon, have you ever found a solution for this? Thanks. On Tuesday, June 14, 2011 5:04:09 PM UTC+2, Jon Biddle wrote: > > The issue seems to come from the fact that the order of operations > when you create the user looks like this: > > 1) Django admin saves the new User > 2) post_save on User is triggered, and User's profile is created > 3) Django admin saves the UserProfile... but it already exists, and an > integrity error is raised > > > I'm currently looking into a solution to this as well, and will let > you know what I find. > > On May 26, 8:39 am, Malcolm Box wrote: > > On 26 May 2011 10:23, Jani Tiainen wrote: > > > > > If I extend auth.User with custom profile and add automatic profile > > > creation signal it works as expected. > > > > > But if I try to add admin inline editor for profile when saving I get > > > exception about integration violation. > > > > > It happens because admin tries to create second profile for user when > > > saving. > > > > Have your signal handler check whether this is a creation of a user or > an > > edit. Only create the profile in the first case. > > > > You may also need to check whether the profile already exists before > trying > > to create - get_or_create() is your friend here. > > > > Malcolm -- 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/-/By34T_tvqpsJ. 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: pyodbc utf-8
Ich habe einen Holzweg beschritten und ich werde ihn auch zu Ende gehen... :) I have taken a wrong path and I will follow it through to the end ... :) Am Donnerstag, 29. November 2012 07:53:18 UTC+1 schrieb Nebros: > Its compatible with mysql, but it's not working with mssql. it gave only > errors with the correct settings... thats why i have to make own settings > for the odbc. > > > Am Mittwoch, 28. November 2012 14:30:57 UTC+1 schrieb Daniel Roseman: > >> On Wednesday, 28 November 2012 13:17:39 UTC, Nebros wrote: >> >>> edit: in the db the values are correct and i cant change there >>> something... >>> >> >> Meanwhile we still don't know why you won't use Django's proper ORM >> functionality, which is perfectly compatible with MSSQL and ODBC. >> -- >> DR. >> > -- 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/-/C8nNqF1x3O8J. 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: mod_wsgi using a subpath in combination with a middleware that calls django.core.urlresolvers.resolve is not working
Op donderdag 29 november 2012 09:07:01 UTC+1 schreef Jan Murre het volgende: > > > > Op maandag 26 november 2012 19:50:50 UTC+1 schreef ke1g het volgende: >> >> >> >> On Thu, Nov 22, 2012 at 11:28 AM, Jan Murre wrote: >> >>> Hi, >>> >>> I have the following peculiar problem that is very easy to reproduce. >>> I use a simple middleware the attaches the 'app_name' that is defined in >>> the urlconf to 'request.user' for subsequent use. >>> >>> >>> from django.core.urlresolvers import resolve >>> >>> class ApplicationAwareMiddleware(object): >>> """ >>> Middleware class that determines the name of the application of the >>> current >>> view and attaches that to the current user. >>> """ >>> >>> def process_request(self, request): >>> >>> request.user.app_name = resolve(request.path).app_name >>> - >>> >>> This middleware kills Django's urls resolution when used with mod_wsgi >>> using a suppath, like: >>> >>> WSGIScriptAlias /subpath /django.wsgi >>> >>> It seems that the call to 'django.core.urlresolvers.resolve' has some >>> kind of nasty side-effect. >>> >>> I tried things like delaying the call to 'resolve', but to no avail. >>> Pointers anyone? >>> >>> Regards, Jan >>> >>> >>> Are you figuring out the url resolution on your own? I would have >> thought that you would use process_view(), so that the view function has >> already been looked up, and you can just introspect it. >> >> I'd be worried that the anonymous user shouldn't be modified. I'd add >> the decoration to the request, or maybe request.META, rather than the user. >> >> It might be cleaner yet to write a decorator for your view that adds the >> information as an early positional argument (say, just after request) at >> call time. This also allows you to avoid the work for views that don't >> need it. >> >> Or if you're doing this to views that are outside of your control, so >> that you couldn't decorate them, maybe I see why you want to put the data >> on the user. If so, do check that the anonymous user accepts attribute >> setting. And I believe that request.user is a lazy object, so try >> referencing, say, request.user.email before you modify the user object, to >> see if that makes a difference. >> >> Bill >> >> Bill >> > > Hi Bill, > > Thanx for your help. Using process_view is not helping in this case. > Alhough I can introspect the view function, I cannot get hold of > "app_name". For that I really need 'reverse'. And the reverse call is > causing all the trouble (only when using mod_wsgi on a subpath). > > I suspect the fact that in 'django.core.urlresolvers' the prefix is stored > in a module level variable, but it is hard to pinpoint it, because mod_wsgi > and pdb debugging are not working well together (although it is possible). > > Regards, Jan > > Ok, found it. It turns out that the call to resolve() was already throwing the 404. When the prefix is stripped off of the "request.path" before calling "resolve", the middleware works OK. Regards, Jan -- 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/-/5QRoinUR5CEJ. 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: Installing forum on django 1.4
On Wed, 2012-11-28 at 03:15 -0800, Yogev Metzuyanim wrote: > Hi, > Did someone here managed to install a working forum on django 1.4, I > tried all these and I got all kinds of errors: > PyBB > django-forum > django-forumbr > askbot > snapboard > and more... I suspect your question is too general. You might be better off posting the errors you get from just one of those apps. You might get even better results if you posted to a forum that deals specifically with that particular app. I know askbot uses itself as a support forum. (http://askbot.org/en/questions/) -- 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: Enforce HTTPS for authenticated users but HTTP for anonymous
Could this be achieved, in a view, by quering if the user is logged in and if so, redirecting to the same page but with HTTPS? Something like: def index(request): if request.user.is_authenticated() and not request.is_secure(): # redirect to HTTPS One could argue though that to keep things as simple and robust as possible, running everything over HTTPS would be a better choice. Is HTTPS that much more compute intensive with your traffic? J torstai, 29. marraskuuta 2012 11.32.28 UTC+2 Roarster kirjoitti: > > Is there any easy way to have a django site enforce HTTPS for > authenticated users while any anonymous users would default to HTTP? This > would allow me to protect the sessions and cookies for users who have > logged on while conserving server resources for those who aren't > authenticated (I would assume the majority of connections). As part of > this it would also make sense for me to ensure the login and register pages > also use HTTPS to protect any passwords. > > I'm not sure if it's relevant but I'm using Nginx as a web server with > uwsgi dealing with the django requests. > > 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/-/bQ4TYYmJvswJ. 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 setup with elsatic beanstalk
i give up after a while. every time it was a mess. and AWS is free for 12 months. i switched to appfog, which actually runs for you stuff on AWS. quite easy to set up and put code. basically you need the requirements.txt (as for AWS). and change a bit the setting.py ciao On Thu, Nov 29, 2012 at 3:29 AM, David Seelig wrote: > Did the eb update work? I ran into this same issue; seems like when > creating the first instance it works, but the second time are problems: > https://github.com/boto/boto/issues/1087 > > According to that thread, if you delete the WSGIPath line and then create > a new environment, you might have better luck.. > -D > > > On Tuesday, October 30, 2012 7:43:29 AM UTC-7, Stefano Tranquillini wrote: >> >> Well >> i was able to play with it only right now. >> there's a thing i can't understand. what's the application.py? >> i've back this error >> >> >> 2012-10-30 14:28:42,890 [INFO] (26110 MainThread) >> [directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Output >> from script: 2012-10-30 14:28:42,875 ERRORThe specified WSGIPath of >> "application.py" was not found in the source bundle >> >> >> >> and i don't have any application.py file in my folder . >> this application.py i s specified in the .elasticbeanstalk/optionse** >> ttings >> >> Il giorno mercoledì 24 ottobre 2012 14:06:52 UTC+2, Stefano Tranquillini >> ha scritto: >>> >>> thx. >>> later i try both yr suggestions. i haven;t been notified of the previous >>> reply. >>> thx >>> >>> On Wednesday, October 24, 2012 12:06:13 AM UTC+2, Andrzej Winnicki wrote: Try also to change settings in .elasticbeanstalk/**optionsettings. [aws:elasticbeanstalk:**application:environment] DJANGO_SETTINGS_MODULE = PARAM1 = PARAM2 = PARAM4 = PARAM3 = PARAM5 = [aws:elasticbeanstalk:**container:python] WSGIPath = application.py NumProcesses = 1 StaticFiles = /static= NumThreads = 15 [aws:elasticbeanstalk:**container:python:staticfiles] /static = Then type eb update and trick should work. On Friday, 12 October 2012 11:54:37 UTC+2, Stefano Tranquillini wrote: > > Mmm. seems that i missing something. > > this is the log > > 2012-10-12 09:36:51,352 [INFO] (24716 MainThread) > [directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Output > from script: 2012-10-12 09:36:51,331* ERRORThe specified WSGIPath > of "application.py" was not found in the source bundle* > > 2012-10-12 09:36:51,353 [INFO] (24716 MainThread) > [directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Script > succeeded. > 2012-10-12 09:36:51,443 [INFO] (24641 MainThread) [command.py-126] > [root command execute] Command returned: (code: 0, stdout: , stderr: None) > 2012-10-12 09:36:51,449 [INFO] (24641 MainThread) [command.py-118] > [root command execute] Executing command: Infra-EmbeddedPostBuild - > AWSEBAutoScalingGroup > 2012-10-12 09:36:52,621 [INFO] (24641 MainThread) [command.py-126] > [root command execute] Command returned: (code: 1, stdout: Error occurred > during build: Command 01_syncdb failed > , stderr: None) > 2012-10-12 09:36:52,623 [DEBUG] (24641 MainThread) > [commandWrapper.py-60] [root commandWrapper main] Command result: > {'status': 'FAILURE', 'results': [{'status': 'SUCCESS', 'config_set': > u'Hook-PreAppDeploy', 'events': [*{'msg': 'Your WSGIPath refers to a > file that does not exist.', 'timestamp': 1350034611, 'severity': 'ERROR'}] > *}, {'status': 'FAILURE', 'config_set': u'Infra-EmbeddedPostBuild', > 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: > Command > 01_syncdb failed\n'}], 'api_version': '1.0'} > > what's is this application.py (it's not mentioned in the tutorial) ? > idea about the WSGIPath? > > this is the directory tree: > > . > |.ebextensions > | |config > |.elasticbeanstalk > | |config > | |optionsettings > |manage.py > |mysites > | |.DS_Store > | |__init__.py > | |__init__.pyc > | |settings.py > | |settings.pyc > | |urls.py > | |urls.pyc > | |wsgi.py > | |wsgi.pyc > |requirements.txt > > > > two things. tutorial says that config file should be .config . it > sounds strange. > is it correct? > where the requirements.txt should be located? > > > > On Thu, Oct 11, 2012 at 6:47 PM, Stefano Tranquillini < > stefano.tr...@gmail.com> wrote: > >> same problem, did you solve it? >> >> >> On Monday, October 8, 2012 7:22:51 PM UTC+2, shlomi oberman wrote: >>> >>> I'm trying without succes to setup a simple application using django >>> with elastic beanstalk from my windows machine. >>> Doe
Re: Enforce HTTPS for authenticated users but HTTP for anonymous
On Thu, Nov 29, 2012 at 9:32 AM, Roarster wrote: > Is there any easy way to have a django site enforce HTTPS for authenticated > users while any anonymous users would default to HTTP? This would allow me > to protect the sessions and cookies for users who have logged on while > conserving server resources for those who aren't authenticated (I would > assume the majority of connections). As part of this it would also make > sense for me to ensure the login and register pages also use HTTPS to > protect any passwords. > > I'm not sure if it's relevant but I'm using Nginx as a web server with uwsgi > dealing with the django requests. > > Thanks. > Write some custom middleware to handle your logic. We have a similar requirement at $JOB - SSL on logins, preference pages, anything with a password form on it, but not on other views. I can't show the code, but I can describe the logic. You actually need to specify two things for a URL - is SSL allowed, and is SSL required. Your middleware should hook in to process_request. If the current request is not SSL, check if the URL requires SSL and redirect to SSL if it does. If the current request is SSL, check if SSL is allowed, redirect to non SSL if it doesn't. If the request is a POST and needs redirection, blow up, this is a logic error (you can't redirect a POST, and anything requiring this is doing things in an incorrect order). There is an easy way to check if SSL is required for a view. In your urlconf, you can specify additional keyword arguments for a view. Our middleware checks for the keyword arguments 'ssl_required' and 'ssl_allowed', which neatly allows the configuration for whether a URL is to be handled by SSL to be included along with all the other URL configuration. An important note is that the middleware must remove these additional arguments, since the views will not be expecting them! 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.
Re: Where to put PDF files + how to authenticate the urls requesting them
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.
Re: Enforce HTTPS for authenticated users but HTTP for anonymous
Possibly, but I guess this would involve updating all of my views? As for performance, I'm not sure yet since we haven't launched. I'm really just thinking about things that might keep costs down - particularly if it's easy to do. If any solution is complicated or messy then I probably will just go with HTTPS for everything. On Thursday, 29 November 2012 10:47:14 UTC, kahara wrote: > > Could this be achieved, in a view, by quering if the user is logged in and > if so, redirecting to the same page but with HTTPS? Something like: > > def index(request): > > if request.user.is_authenticated() and not request.is_secure(): > > # redirect to HTTPS > > > One could argue though that to keep things as simple and robust as > possible, running everything over HTTPS would be a better choice. Is HTTPS > that much more compute intensive with your traffic? > > > J > > > torstai, 29. marraskuuta 2012 11.32.28 UTC+2 Roarster kirjoitti: >> >> Is there any easy way to have a django site enforce HTTPS for >> authenticated users while any anonymous users would default to HTTP? This >> would allow me to protect the sessions and cookies for users who have >> logged on while conserving server resources for those who aren't >> authenticated (I would assume the majority of connections). As part of >> this it would also make sense for me to ensure the login and register pages >> also use HTTPS to protect any passwords. >> >> I'm not sure if it's relevant but I'm using Nginx as a web server with >> uwsgi dealing with the django requests. >> >> 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/-/4hZopf0UwPIJ. 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: Enforce HTTPS for authenticated users but HTTP for anonymous
On Thursday, 29 November 2012 11:10:22 UTC, Tom Evans wrote: > Write some custom middleware to handle your logic. We have a similar > requirement at $JOB - SSL on logins, preference pages, anything with a > password form on it, but not on other views. I can't show the code, > but I can describe the logic. > > You actually need to specify two things for a URL - is SSL allowed, > and is SSL required. > Your middleware should hook in to process_request. > If the current request is not SSL, check if the URL requires SSL and > redirect to SSL if it does. > If the current request is SSL, check if SSL is allowed, redirect to > non SSL if it doesn't. > If the request is a POST and needs redirection, blow up, this is a > logic error (you can't redirect a POST, and anything requiring this is > doing things in an incorrect order). > > There is an easy way to check if SSL is required for a view. In your > urlconf, you can specify additional keyword arguments for a view. Our > middleware checks for the keyword arguments 'ssl_required' and > 'ssl_allowed', which neatly allows the configuration for whether a URL > is to be handled by SSL to be included along with all the other URL > configuration. > > An important note is that the middleware must remove these additional > arguments, since the views will not be expecting them! > > Cheers > > Tom > Tom, that sounds like a very clean approach. I haven't really done any middleware development yet but looking at the documentation it sounds like this shouldn't be that complicated so I might give it a bash. Does it cause any issues if an authenticated user is redirected to HTTPS? I assume the cookie is still sent to the server and they remain authenticated? -- 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/-/Vw7Ew_qGqXgJ. 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
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.
504 Gateway Timeout
Dear all, I'm just facing a problem with little longer runnig SQL select command, and DJago framework returns a "504 Gateway Timeout" after aprox 10 seconds. My sql command is executed on Oracle SQL database through "django.db.backends.oracle" driver. Unfortunately I'm not able to find a place where to change the timeout. Please help. Thanks and Regards. -- 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/-/RVOrb6egREEJ. 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.
Error: No module named books
Hi all, I'm working through the Django book and I've run into an error that wasn't predicted. I've got a project called mysite. I used "python manage.py startapp books" to create an app called books inside of it. I added a few models to the models.py file inside books, then tried to use "python manage.py validate". I got "Error: No module named books" in return. __init__.py is perfectly intact in both the second mysite directory and the books directory. I've added mysite.books to INSTALLED_APPS. All the results I could find searching for this problem deal with someone that's made a spelling mistake somewhere. I've been through my files multiple times, and my spelling is pristine. I figure I'm making an obvious, beginner's mistake - could anyone help? -- 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/-/5gaeHt1dGtwJ. 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.
Re: 504 Gateway Timeout
On Thu, Nov 29, 2012 at 11:58 AM, bikeridercz wrote: > Dear all, > > I'm just facing a problem with little longer runnig SQL select command, and > DJago framework returns a "504 Gateway Timeout" after aprox 10 seconds. My > sql command is executed on Oracle SQL database through > "django.db.backends.oracle" driver. > > Unfortunately I'm not able to find a place where to change the timeout. > > Please help. > > Thanks and Regards. > The timeout comes from your web server, not Django. I think this error is from nginx + FastCGI (I know it is not Apache :) http://wiki.nginx.org/HttpFastcgiModule#fastcgi_send_timeout 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.
Re: 504 Gateway Timeout
> I'm just facing a problem with little longer runnig SQL select command, and DJago framework returns a "504 Gateway Timeout" after aprox 10 seconds. My sql command is executed on Oracle SQL database through "django.db.backends.oracle" driver. You'd have to change multiple timeouts to make this work. There are several approaches in similar situations, pick what suits your situation (which you have not described in detail). - calculate data *before* user requests it and keep the calculated copy - caching of any data that takes long to compute (retrieve) - can and should be combined with above - using asyncronous queries, typically achived via celery (django-celery) and some AJAX calls You need to provide more details about your long-running query if you need people to help you further. Cheers Jirka -- 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: Error: No module named books
I am learning django book too. Do you check the output of error.? Generally, there are hint like ValueError in the output. On Wednesday, November 28, 2012, Chris Recher wrote: > Hi all, > > I'm working through the Django book and I've run into an error that wasn't > predicted. I've got a project called mysite. I used "python manage.py > startapp books" to create an app called books inside of it. I added a few > models to the models.py file inside books, then tried to use "python > manage.py validate". I got "Error: No module named books" in return. > __init__.py is perfectly intact in both the second mysite directory and the > books directory. I've added mysite.books to INSTALLED_APPS. All the results > I could find searching for this problem deal with someone that's made a > spelling mistake somewhere. I've been through my files multiple times, and > my spelling is pristine. I figure I'm making an obvious, beginner's mistake > - could anyone help? > > -- > 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/-/5gaeHt1dGtwJ. > To post to this group, send email to > django-users@googlegroups.com 'django-users@googlegroups.com');> > . > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com 'django-users%2bunsubscr...@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: 504 Gateway Timeout
On Thu, Nov 29, 2012 at 1:01 PM, Jirka Vejrazka wrote: >> I'm just facing a problem with little longer runnig SQL select command, >> and DJago framework returns a "504 Gateway Timeout" after aprox 10 seconds. >> My sql command is executed on Oracle SQL database through >> "django.db.backends.oracle" driver. > > You'd have to change multiple timeouts to make this work. There are several > approaches in similar situations, pick what suits your situation (which you > have not described in detail). Not that many; django itself has no timeouts, so you only need to adjust the timeouts on your http server. Normally there are several that apply - a timeout between writes, a timeout for the total response time, etc. This timeout is happening due to timeout between writes, so adjusting that one first and seeing where you go would be a start. > > - calculate data *before* user requests it and keep the calculated copy > - caching of any data that takes long to compute (retrieve) - can and > should be combined with above > - using asyncronous queries, typically achived via celery (django-celery) > and some AJAX calls > You missed 'just increase the timeouts', which is architecturally simpler than any of those options, and may easily fit within the desired performance for the app - only the OP can know that though. It is also possible that your query could be optimised. Have you analysed the query yet? Could additional indices be added to speed up this particular query? 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.
Re: Error: No module named books
On Thu, Nov 29, 2012 at 4:51 AM, Chris Recher wrote: > Hi all, > > I'm working through the Django book and I've run into an error that wasn't > predicted. I've got a project called mysite. I used "python manage.py > startapp books" to create an app called books inside of it. I added a few > models to the models.py file inside books, then tried to use "python > manage.py validate". I got "Error: No module named books" in return. > __init__.py is perfectly intact in both the second mysite directory and the > books directory. I've added mysite.books to INSTALLED_APPS. All the results > I could find searching for this problem deal with someone that's made a > spelling mistake somewhere. I've been through my files multiple times, and > my spelling is pristine. I figure I'm making an obvious, beginner's mistake > - could anyone help? > Hi Chris First hint, newlines are free to use! Consider some next time! Second, Django is an evolving framework. It helps to know what version you are using. Finally, launch the django shell ("python mange.py shell" instead of "python manage.py runserver"). Try to import your module - "import mysite.books" - does it work? If it doesn't, does this work? - "import books" 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.
_set.all in template should be simple, wood and trees maybe?
I dont get the hot_topic_set.all from the newsletter instance x and I really don't see why can anyone else please? model: class NewsLetter(models.Model): title = models.CharField(max_length=200) text = models.TextField(null=True, blank=True) document = models.FileField(upload_to="newsletters/", null=True, blank=True) priority = models.IntegerField(default=50) def __unicode__(self): return self.title def get_absolute_url(self): return "/newsletters/" class Meta: ordering = ('priority',) class Hot_Topic(models.Model): newsletter = models.ForeignKey(NewsLetter, related_name="letter_set") topic = models.CharField(max_length=100) priority = models.IntegerField(default=50) class Meta: verbose_name_plural = "Hot Topics" ordering = ('priority',) view def index(request): list = NewsLetter.objects,all() return render_to_response('newsletter/index.html', {''list': list,}, context_instance=RequestContext(request)) template: {% for x in list %} {% if x.text %} . {% else %} {% for t in x.hot_topic_set.all %} {{ t.topic }} {% endfor %} {% endif %} {% endfor %} I dont get the hot_topic_set.all from the newsletter instance x and I really don't see why can anyone else please? -- 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/-/LWo5COXB5-wJ. 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: 504 Gateway Timeout
Tom, you were right ! I'm using a Cherokee http server and 15s timeout was one of options. Now it works OK. Radim Kolek, Ing. GSM: +420602608696 ICQ: 85591428 Dne 29.11.2012 13:58, Tom Evans napsal(a): On Thu, Nov 29, 2012 at 11:58 AM, bikeridercz wrote: Dear all, I'm just facing a problem with little longer runnig SQL select command, and DJago framework returns a "504 Gateway Timeout" after aprox 10 seconds. My sql command is executed on Oracle SQL database through "django.db.backends.oracle" driver. Unfortunately I'm not able to find a place where to change the timeout. Please help. Thanks and Regards. The timeout comes from your web server, not Django. I think this error is from nginx + FastCGI (I know it is not Apache :) http://wiki.nginx.org/HttpFastcgiModule#fastcgi_send_timeout 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.
admin foreign key issues
This is probably very simple, but I've never run into this before and googling has not revealed anything. I have these 2 models: class Category(models.Model): class Meta: db_table = 'data_category' name = models.CharField(max_length=20, unique=True, db_index=True) class Tool(models.Model): class Meta: db_table = 'data_tool' name = models.CharField(max_length=10, unique=True) category = models.ForeignKey(Category) In admin when I click on 'Categorys' I get a table of 'Category object' and I have to click on those to get at an actual row in the table. How can I make the data available from 'Categorys' without that extra level? Similarly, in Tools the Category column has 'Category object' and when I click on a specific tool and get into change tool, the Category is a drop down that has 'Category object' as every choice. How can I make the actual category names appear here? I tried defining a CategoryAdmin class: class CategoryAdmin(admin.ModelAdmin): list_display = ('name') list_filter = ('name') admin.site.register(Category, CategoryAdmin) But that fails with 'CategoryAdmin.list_display' must be a list or tuple. And finally, how can I get it to display 'Categories' instead of 'Categorys' TIA! -larry -- 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.
how to use named urls from apps
I'm trying to use the url template tag to call the login view from contrib.auth. I've tried the following but none work: {% url login %} {% url auth:login %} {% url auth.login %} {% url contrib.auth.login %} Can someone enlighten me please? Mike -- 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/-/UpjZZCj-U5wJ. 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 use named urls from apps
Try {% url 'auth_login' %} That works for me in Django 1.4 On Thu, 2012-11-29 at 06:32 -0800, Mike wrote: > I'm trying to use the url template tag to call the login view from > contrib.auth. I've tried the following but none work: > > > {% url login %} > {% url auth:login %} > {% url auth.login %} > {% url contrib.auth.login %} > > > Can someone enlighten me please? > Mike -- 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: _set.all in template should be simple, wood and trees maybe?
Good question, I have attempted to shell the problem out and no I dont get a dataset returned, I should do as NewsLetter is foreignkeyed to Hot_Topic and Hot_Topic_Inline is an inlines to NewsLetterAdmin so the models are definately related -- 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/-/9Dd5Ea1WMYwJ. 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/celery - celery status: Error: No nodes replied within time constraint
Hi I solved my problem, it was a very simple solution, but it was also a weird one: What I did was: $ /etc/init.d/celerybeat restart $ /etc/init.d/celeryd restart $ service celeryd restart I had to do this in that order, other way I'd get an ugly Error: No nodes replied within time constraint On Tuesday, November 27, 2012 5:57:38 AM UTC-6, Hector Armando Vela Santos wrote: > > I'm trying to deploy a simple example of celery in my production server, > I've followed the tutorial in the celery website about running celery as > daemon > http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#daemonizing, > > and I got the config file in*/etc/default/celeryd* > * > * > > 1 # Name of nodes to start > 2 # here we have a single node > 3 CELERYD_NODES="w1" > 4 # or we could have three nodes: > 5 #CELERYD_NODES="w1 w2 w3" > 6 > 7 # Where to chdir at start. > 8 CELERYD_CHDIR="/home/audiwime/cidec_sw" > 9 > 10 # Python interpreter from environment. > 11 ENV_PYTHON="/usr/bin/python26" > 12 > 13 # How to call "manage.py celeryd_multi" > 14 CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi" > 15 > 16 # # How to call "manage.py celeryctl" > 17 CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl" > 18 > 19 # Extra arguments to celeryd > 20 CELERYD_OPTS="--time-limit=300 --concurrency=8" > 21 > 22 # Name of the celery config module. > 23 CELERY_CONFIG_MODULE="celeryconfig" > 24 > 25 # %n will be replaced with the nodename. > 26 CELERYD_LOG_FILE="/var/log/celery/%n.log" > 27 CELERYD_PID_FILE="/var/run/celery/%n.pid" > 28 > 29 # Workers should run as an unprivileged user. > 30 CELERYD_USER="audiwime" > 31 CELERYD_GROUP="audiwime" > 32 > 33 export DJANGO_SETTINGS_MODULE="cidec_sw.settings" > > but if I run > > celery status > > in the terminal, i got this response: > > Error: No nodes replied within time constraint > > I can restart celery via the celeryd script provided in > https://github.com/celery/celery/tree/3.0/extra/generic-init.d/ > > /etc/init.d/celeryd restart > celeryd-multi v3.0.12 (Chiastic Slide) > > w1.one.cloudwime.com: DOWN > > Restarting node w1.one.cloudwime.com: OK > > I can run > > python26 manage.py celeryd -l info > > and my tasks in django run fine, but if I let the daemon do its work i > dont get any results, don't even errors in */var/log/celery/w1.log* > > I know that my task has been registered because I did this from celery > import current_app def call_celery_delay(request): print current_app.tasks > run.delay(request.GET['age']) return HttpResponse(content="celery task > set",content_type="text/html") and I get a dictionary in wich my task appear > > {'celery.chain': <@task: celery.chain>, 'celery.chunks': <@task: > celery.chunks>, 'celery.chord': <@task: celery.chord>, 'tasks.add2': > <@task: tasks.add2>, 'celery.chord_unlock': <@task: > celery.chord_unlock>,*'tareas.tasks.run': > <@task: tareas.tasks.run>*, 'tareas.tasks.add': <@task: > tareas.tasks.add>, 'tareas.tasks.test_two_minute': <@task: > tareas.tasks.test_two_minute>, 'celery.backend_cleanup': <@task: > celery.backend_cleanup>, 'celery.map': <@task: celery.map>, 'celery.group': > <@task: celery.group>, 'tareas.tasks.test_one_minute': <@task: > tareas.tasks.test_one_minute>, 'celery.starmap': <@task: celery.starmap>} > > but besides that I get nothing else, no result from my task, no error in > the logs, nothing. Can anyone tell me what can be wrong? You are my only > hope... > > -- 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/-/NUciKmM0z-4J. 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 use named urls from apps
On Thu, Nov 29, 2012 at 2:32 PM, Mike wrote: > I'm trying to use the url template tag to call the login view from > contrib.auth. I've tried the following but none work: > > {% url login %} > {% url auth:login %} > {% url auth.login %} > {% url contrib.auth.login %} > > Can someone enlighten me please? > Mike > Named urls are URLs defined in your urlconf that have named views. The contrib auth app, although it provides a bunch of views, does not automatically install any of them at any URLs, hence this would fail. If you include the login view in one of your urlconfs, it will not have the 'auth' app label, it will have whatever name you decide to give it. Cheers Tom PS: The fully qualified view name may have worked - "django.contrib.auth.views.login". There is a function at "django.contrib.auth.login", but that function is used to actually log users in, not to present a login form and process it. -- 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: _set.all in template should be simple, wood and trees maybe?
{% for x in list %} {{x.text}} {% for t in x.hot_topic_set.all %} {{ t.topic }} {% endfor %} {% endfor %} try only erase the if tag work for me !! On Thu, Nov 29, 2012 at 9:17 AM, MikeKJ wrote: > Good question, I have attempted to shell the problem out and no I dont get > a dataset returned, I should do as NewsLetter is foreignkeyed to Hot_Topic > and Hot_Topic_Inline is an inlines to NewsLetterAdmin so the models are > definately related > > -- > 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/-/9Dd5Ea1WMYwJ. > > 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: admin foreign key issues
On Thu, Nov 29, 2012 at 9:10 AM, Larry Martell wrote: > This is probably very simple, but I've never run into this before and > googling has not revealed anything. > > I have these 2 models: > > class Category(models.Model): > class Meta: db_table = 'data_category' > name = models.CharField(max_length=20, unique=True, db_index=True) > > class Tool(models.Model): > class Meta: db_table = 'data_tool' > name = models.CharField(max_length=10, unique=True) > category = models.ForeignKey(Category) > > In admin when I click on 'Categorys' I get a table of 'Category > object' and I have to click on those to get at an actual row in the > table. How can I make the data available from 'Categorys' without that > extra level? > > Similarly, in Tools the Category column has 'Category object' and when > I click on a specific tool and get into change tool, the Category is a > drop down that has 'Category object' as every choice. How can I make > the actual category names appear here? > > I tried defining a CategoryAdmin class: > > class CategoryAdmin(admin.ModelAdmin): > list_display = ('name') > list_filter = ('name') > admin.site.register(Category, CategoryAdmin) > > But that fails with 'CategoryAdmin.list_display' must be a list or tuple. > > > And finally, how can I get it to display 'Categories' instead of > 'Categorys' > > Start by creating a __unicode__() method on each of your models that returns a string giving a better description of your object, say by using its 'name' field. If you are using python3, then see the recent discussion here about what to do instead of __unicode__(). Use of the __unicode__() method is described in the tutorial. Bill -- 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: _set.all in template should be simple, wood and trees maybe?
You have specified related_name to the foreign key in HotTopic. Try either taking that out, or using newsletter_instance.letter_set.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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to use named urls from apps
> > > Named urls are URLs defined in your urlconf that have named views. The > contrib auth app, although it provides a bunch of views, does not > automatically install any of them at any URLs, hence this would fail. > > If you include the login view in one of your urlconfs, it will not > have the 'auth' app label, it will have whatever name you decide to > give it. > > Cheers > > Tom > > That makes sense, and explains why none of my solutions worked. The solution provided by Paul Backhouse works, I suppose because it is referring to the view function and not the url name. > -- 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/-/FPKR0dd0bPUJ. 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: _set.all in template should be simple, wood and trees maybe?
Perfect, thanks On Thursday, November 29, 2012 3:48:41 PM UTC, ke1g wrote: > > You have specified related_name to the foreign key in HotTopic. Try > either taking that out, or using newsletter_instance.letter_set.all . > -- 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/-/HPquxQCyfBIJ. 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: Error: No module named books
Im betting you're using Django 1.4x The layout is different in 1.4. Download the version the book is using (1.1? https://www.djangoproject.com/download/ bottom right), then all should work. On Thu, Nov 29, 2012 at 4:33 PM, Tom Evans wrote: > On Thu, Nov 29, 2012 at 4:51 AM, Chris Recher > wrote: > > Hi all, > > > > I'm working through the Django book and I've run into an error that > wasn't > > predicted. I've got a project called mysite. I used "python manage.py > > startapp books" to create an app called books inside of it. I added a few > > models to the models.py file inside books, then tried to use "python > > manage.py validate". I got "Error: No module named books" in return. > > __init__.py is perfectly intact in both the second mysite directory and > the > > books directory. I've added mysite.books to INSTALLED_APPS. All the > results > > I could find searching for this problem deal with someone that's made a > > spelling mistake somewhere. I've been through my files multiple times, > and > > my spelling is pristine. I figure I'm making an obvious, beginner's > mistake > > - could anyone help? > > > > Hi Chris > > First hint, newlines are free to use! Consider some next time! > > Second, Django is an evolving framework. It helps to know what version > you are using. > > Finally, launch the django shell ("python mange.py shell" instead of > "python manage.py runserver"). > Try to import your module - "import mysite.books" - does it work? > If it doesn't, does this work? - "import books" > > 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: admin foreign key issues
On Thu, Nov 29, 2012 at 10:43 AM, Bill Freeman wrote: > > > On Thu, Nov 29, 2012 at 9:10 AM, Larry Martell > wrote: >> >> This is probably very simple, but I've never run into this before and >> googling has not revealed anything. >> >> I have these 2 models: >> >> class Category(models.Model): >> class Meta: db_table = 'data_category' >> name = models.CharField(max_length=20, unique=True, db_index=True) >> >> class Tool(models.Model): >> class Meta: db_table = 'data_tool' >> name = models.CharField(max_length=10, unique=True) >> category = models.ForeignKey(Category) >> >> In admin when I click on 'Categorys' I get a table of 'Category >> object' and I have to click on those to get at an actual row in the >> table. How can I make the data available from 'Categorys' without that >> extra level? >> >> Similarly, in Tools the Category column has 'Category object' and when >> I click on a specific tool and get into change tool, the Category is a >> drop down that has 'Category object' as every choice. How can I make >> the actual category names appear here? >> >> I tried defining a CategoryAdmin class: >> >> class CategoryAdmin(admin.ModelAdmin): >> list_display = ('name') >> list_filter = ('name') >> admin.site.register(Category, CategoryAdmin) >> >> But that fails with 'CategoryAdmin.list_display' must be a list or tuple. >> >> >> And finally, how can I get it to display 'Categories' instead of >> 'Categorys' >> > Start by creating a __unicode__() method on each of your models that returns > a string giving a better description of your object, say by using its 'name' > field. If you are using python3, then see the recent discussion here about > what to do instead of __unicode__(). > > Use of the __unicode__() method is described in the tutorial. Thanks much Bill, that did the trick. Now does anyone know how to get it to display 'Categories' instead of 'Categorys'? -- 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: admin foreign key issues
On Thu, Nov 29, 2012 at 12:30 PM, Larry Martell wrote: > On Thu, Nov 29, 2012 at 10:43 AM, Bill Freeman wrote: > > > > > > On Thu, Nov 29, 2012 at 9:10 AM, Larry Martell > > wrote: > >> > >> This is probably very simple, but I've never run into this before and > >> googling has not revealed anything. > >> > >> I have these 2 models: > >> > >> class Category(models.Model): > >> class Meta: db_table = 'data_category' > >> name = models.CharField(max_length=20, unique=True, db_index=True) > >> > >> class Tool(models.Model): > >> class Meta: db_table = 'data_tool' > >> name = models.CharField(max_length=10, unique=True) > >> category = models.ForeignKey(Category) > >> > >> In admin when I click on 'Categorys' I get a table of 'Category > >> object' and I have to click on those to get at an actual row in the > >> table. How can I make the data available from 'Categorys' without that > >> extra level? > >> > >> Similarly, in Tools the Category column has 'Category object' and when > >> I click on a specific tool and get into change tool, the Category is a > >> drop down that has 'Category object' as every choice. How can I make > >> the actual category names appear here? > >> > >> I tried defining a CategoryAdmin class: > >> > >> class CategoryAdmin(admin.ModelAdmin): > >> list_display = ('name') > >> list_filter = ('name') > >> admin.site.register(Category, CategoryAdmin) > >> > >> But that fails with 'CategoryAdmin.list_display' must be a list or > tuple. > >> > >> > >> And finally, how can I get it to display 'Categories' instead of > >> 'Categorys' > >> > > Start by creating a __unicode__() method on each of your models that > returns > > a string giving a better description of your object, say by using its > 'name' > > field. If you are using python3, then see the recent discussion here > about > > what to do instead of __unicode__(). > > > > Use of the __unicode__() method is described in the tutorial. > > Thanks much Bill, that did the trick. > > Now does anyone know how to get it to display 'Categories' instead of > 'Categorys'? > > verbose_name_plural Model Meta option? https://docs.djangoproject.com/en/1.4/ref/models/options/#verbose-name-plural -- 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: admin foreign key issues
On Thu, Nov 29, 2012 at 12:34 PM, Bill Freeman wrote: > > > On Thu, Nov 29, 2012 at 12:30 PM, Larry Martell > wrote: >> >> On Thu, Nov 29, 2012 at 10:43 AM, Bill Freeman wrote: >> > >> > >> > On Thu, Nov 29, 2012 at 9:10 AM, Larry Martell >> > wrote: >> >> >> >> This is probably very simple, but I've never run into this before and >> >> googling has not revealed anything. >> >> >> >> I have these 2 models: >> >> >> >> class Category(models.Model): >> >> class Meta: db_table = 'data_category' >> >> name = models.CharField(max_length=20, unique=True, db_index=True) >> >> >> >> class Tool(models.Model): >> >> class Meta: db_table = 'data_tool' >> >> name = models.CharField(max_length=10, unique=True) >> >> category = models.ForeignKey(Category) >> >> >> >> In admin when I click on 'Categorys' I get a table of 'Category >> >> object' and I have to click on those to get at an actual row in the >> >> table. How can I make the data available from 'Categorys' without that >> >> extra level? >> >> >> >> Similarly, in Tools the Category column has 'Category object' and when >> >> I click on a specific tool and get into change tool, the Category is a >> >> drop down that has 'Category object' as every choice. How can I make >> >> the actual category names appear here? >> >> >> >> I tried defining a CategoryAdmin class: >> >> >> >> class CategoryAdmin(admin.ModelAdmin): >> >> list_display = ('name') >> >> list_filter = ('name') >> >> admin.site.register(Category, CategoryAdmin) >> >> >> >> But that fails with 'CategoryAdmin.list_display' must be a list or >> >> tuple. >> >> >> >> >> >> And finally, how can I get it to display 'Categories' instead of >> >> 'Categorys' >> >> >> > Start by creating a __unicode__() method on each of your models that >> > returns >> > a string giving a better description of your object, say by using its >> > 'name' >> > field. If you are using python3, then see the recent discussion here >> > about >> > what to do instead of __unicode__(). >> > >> > Use of the __unicode__() method is described in the tutorial. >> >> Thanks much Bill, that did the trick. >> >> Now does anyone know how to get it to display 'Categories' instead of >> 'Categorys'? >> > verbose_name_plural Model Meta option? > https://docs.djangoproject.com/en/1.4/ref/models/options/#verbose-name-plural Thanks again, Bill. -- 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: [ANNOUNCE] Django 1.5 beta 1 released
On Tue, Nov 27, 2012 at 11:17 PM, James Bennett wrote: > Our second milestone on the road to Django 1.5 came today, with the > release of the first beta package. > > Blog post about it is here: > > https://www.djangoproject.com/weblog/2012/nov/27/15-beta-1/ > > Release notes are here: > > https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/ > > And you can get the alpha from the downloads page: > > https://www.djangoproject.com/download/ > We have also updated the BitNami DjangoStack to include 1.5 beta1. The stack also includes PostgreSQL 9.2.1 with PostGIS 2.0.1 so now that GeoDjango supports PostGIS 2.0 you can easily test it. Here you can find a few notes: http://blog.bitnami.org/2012/11/django-15-beta-geodjango-support-for.html The native installers, Ubuntu virtual machines and Amazon Cloud images are available in http://bitnami.org/stack/djangostack Cheers, Victoria. > -- > 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.
difficulty with static files
Hello django experts I am unable to get my static files to work. Here are my settings: projectfiles | |-myproject | | | |-static | | | | | |-css | | |-js | |-__init__.py | |-settings.py | |-urls.py | |-wsgi.py | |-myapp | |-templates +++ settings.py import os SITE_ROOT = (os.path.realpath(os.path.dirname(__file__))).replace('\\','/') DEBUG = True MEDIA_ROOT = (os.path.join(SITE_ROOT, '/static')).replace('\\','/') MEDIA_URL = '/static/' STATIC_ROOT = '' STATIC_URL = '' STATICFILES_DIRS = () STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) + + urls.py urlpatterns = patterns('', (r'^myurl/$', myview), ) from myproject.settings import DEBUG if DEBUG: urlpatterns += patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': 'static'})) +++ +++ the app works fine but no connection to my css's or javascripts. I'm using pycharm if that makes a difference. Any help would be greatly appreciated. -- 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/-/kFq9WoTc9awJ. 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: difficulty with static files
On Thu, Nov 29, 2012 at 6:00 PM, Sammy wrote: > Hello django experts > I am unable to get my static files to work. Here are my settings: > > projectfiles > | > |-myproject > | | > | |-static > | | | > | | |-css > | | |-js > | |-__init__.py > | |-settings.py > | |-urls.py > | |-wsgi.py > | > |-myapp > | > |-templates > > > +++ > > > > settings.py > import os > SITE_ROOT = (os.path.realpath(os.path.dirname(__file__))).replace('\\','/') > DEBUG = True > MEDIA_ROOT = (os.path.join(SITE_ROOT, '/static')).replace('\\','/') > MEDIA_URL = '/static/' > STATIC_ROOT = '' > STATIC_URL = '' I think you are confused about MEDIA and STATIC. MEDIA is where files are uploaded to by users, STATIC is where files are served from, the _ROOT postfix denotes a directory path, the _URL postfix a URL path. So you should have STATIC_ROOT=os.path.join(...) and STATIC_URL='/static/' > STATICFILES_DIRS = () > STATICFILES_FINDERS = ( > 'django.contrib.staticfiles.finders.FileSystemFinder', > 'django.contrib.staticfiles.finders.AppDirectoriesFinder', > 'django.contrib.staticfiles.finders.DefaultStorageFinder', > ) > But do you have the staticfiles app in INSTALLED_APPS? > + > + > > > urls.py > urlpatterns = patterns('', > (r'^myurl/$', myview), > ) > > > from myproject.settings import DEBUG You should always import settings like this: from django.conf import settings if settings.DEBUG https://docs.djangoproject.com/en/1.4/topics/settings/#using-settings-in-python-code (It's really important actually, it can cause hard to find bugs!) > if DEBUG: > urlpatterns += patterns('', (r'^static/(?P.*)$', > 'django.views.static.serve', > > {'document_root': 'static'})) This is not needed if you are using runserver in development, if you are not using runserver, then it is better to use the shortcut methods provided https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-in-development 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.
Re: Error: No module named books
Thanks for the help everyone. I was using 1.4.x, not the 1.0 the book is based on. After fooling around with the commands for a bit, I was able to figure out that the problem was in the INSTALLED_APPS section - I included 'mysite.books', but the new way to do that is just 'books'. -- 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/-/IzEq71WVR7wJ. 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: django1.5 subclass AbstractUser, How to get a password-(re)set field in admin
Hi Russel, I have followed https://docs.djangoproject.com/en/dev/topics/auth/#a-full-example then added: password = ReadOnlyPasswordHashField(label=_("Password"), help_text=_("Raw passwords are not stored, so there is no way to see " "this user's password, but you can change the password " "using this form."), widget=ReadOnlyPasswordHashWidget()) >From what I seen in django/contrib/auth/forms UserChangeForm this gives me the change password URL however I get the error: 'CustUser' object has no attribute 'username' looking at the error line 136 /Library/Python/2.7/site-packages/django/contrib/auth/admin.py in user_change_password 1. 'title': _('Change password: %s') % escape(user.username), It looks like this is either a bug or doesn't work with a custom user as planed as it looks for a username even though in the example you set the email to username field with: USERNAME_FIELD = 'email' Am I missing something? Regards, Bruce On Saturday, November 3, 2012 4:09:09 PM UTC-7, Russell Keith-Magee wrote: > > > On Sat, Nov 3, 2012 at 11:15 PM, Michael Muster > > > wrote: > >> Hi again, >> >> I have a subclass from AbstractUser >> >> 1 from django.contrib.auth.models import AbstractUser >> 2 from django.conf import settings >> 3 >> 4 class cpUser(AbstractUser): >> 5 twitter = models.CharField(max_length=100) >> 6 def __unicode__(self): >> 7 return self.username >> >> and >> AUTH_USER_MODEL = 'account.cpUser' >> in my settings.py set. >> >> How do i get a password field to set and reset >> a password in my admin app? >> Adding the password field to admin.py does obviously not >> work as it enters plain text and not the hashed password. >> >> 1 from django.contrib import admin >> 2 class cpUserAdmin(admin.ModelAdmin): >> 3fields = ['twitter','username', 'first_name', 'last_name', >> 'password',] >> 4 >> 5 admin.site.register(cpUser, cpUserAdmin) >> >> >> Do i have to set a passwort field to the models.py or >> can i geht that from the models which i "abstracted" from >> (as done with username, first_name, last_name...) >> >> You need to follow the instructions that are in the documentation. > > > https://docs.djangoproject.com/en/dev/topics/auth/#custom-users-and-django-contrib-admin > > The key is that you can't just subclass admin.ModelAdmin -- you need to > subclass the existing Django admin class for Users > (django.contrib.auth.admin.UserAdmin) - that base class is what provides > all the special password handling etc for User models. > > Yours, > Russ Magee %-) > -- 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/-/sRmpO1m1Ng0J. 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.