loader.select_template breaks template name
Hi, I'm receiving some odd results while playing with select_template (Django 1.4) I'm calling the following code in my view: loader.select_template('test.html') Which results in the following error: TemplateDoesNotExist at /test t, e, s, ., h, m, l Can't really figure out what I'm doing wrong as this should be rather straightforward. Thanks -- 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: loader.select_template breaks template name
I tried to retyped the template name (I'm using sublime text 2) with the same results. I've also tried editing the file in BBEdit and can't see any odd characters in there. On Apr 8, 8:01 am, Ejah wrote: > The sentence loader.select_template("test.html') renders with a > whitespace between h and tml on my screen. I suggest you retype the > template name from scratch. There might be some odd character out of > place. > Hth > > On 7 apr, 22:01, gnesher wrote: > > > > > > > > > Hi, > > > I'm receiving some odd results while playing with select_template > > (Django 1.4) > > > I'm calling the following code in my view: > > loader.select_template('test.html') > > > Which results in the following error: > > > TemplateDoesNotExist at /test > > t, e, s, ., h, m, l > > > Can't really figure out what I'm doing wrong as this should be rather > > straightforward. > > > Thanks -- 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: loader.select_template breaks template name
I've retyped the template name but I'm still getting the same results. I'm using Sublime Text 2 (also tried BBEdit) and I can't see any odd characters in the document On Apr 8, 8:01 am, Ejah wrote: > The sentence loader.select_template("test.html') renders with a > whitespace between h and tml on my screen. I suggest you retype the > template name from scratch. There might be some odd character out of > place. > Hth > > On 7 apr, 22:01, gnesher wrote: > > > > > > > > > Hi, > > > I'm receiving some odd results while playing with select_template > > (Django 1.4) > > > I'm calling the following code in my view: > > loader.select_template('test.html') > > > Which results in the following error: > > > TemplateDoesNotExist at /test > > t, e, s, ., h, m, l > > > Can't really figure out what I'm doing wrong as this should be rather > > straightforward. > > > Thanks -- 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: loader.select_template breaks template name
Thanks, that solved the problem. On a side note this means there is a bug in the Django documentations as this was the example they were giving : get_template('story_detail.html') (at https://docs.djangoproject.com/en/dev/ref/templates/api/) I will open a ticket about this On Apr 8, 9:01 am, Russell Keith-Magee wrote: > Hi, > > loader.select_template() is expecting a list of values, and you're providing > a single value. However, Django interprets a string as a list of strings > (each one character long), so it doesn't raise an error due to the type of > the data; it only raises an error because the single-letter filename can't be > found. > > Make a call to loader.select_template(['test.html']), and everything should > work as expected. > > Yours, > Russ Magee %-) > > > > > > > > On Sunday, 8 April 2012 at 4:01 AM, gnesher wrote: > > Hi, > > > I'm receiving some odd results while playing with select_template > > (Django 1.4) > > > I'm calling the following code in my view: > > loader.select_template('test.html') > > > Which results in the following error: > > > TemplateDoesNotExist at /test > > t, e, s, ., h, m, l > > > Can't really figure out what I'm doing wrong as this should be rather > > straightforward. > > > Thanks > > > -- > > 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 > > (mailto:django-users@googlegroups.com). > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > (mailto:django-users+unsubscr...@googlegroups.com). > > For more options, visit this group > > athttp://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: loader.select_template breaks template name
Thanks, that solved the problem. The example in the Django documents is somewhat misleading as they first present a get_template example (to show the difference), which I've mistaken for select_template. On Apr 8, 9:01 am, Russell Keith-Magee wrote: > Hi, > > loader.select_template() is expecting a list of values, and you're providing > a single value. However, Django interprets a string as a list of strings > (each one character long), so it doesn't raise an error due to the type of > the data; it only raises an error because the single-letter filename can't be > found. > > Make a call to loader.select_template(['test.html']), and everything should > work as expected. > > Yours, > Russ Magee %-) > > > > > > > > On Sunday, 8 April 2012 at 4:01 AM, gnesher wrote: > > Hi, > > > I'm receiving some odd results while playing with select_template > > (Django 1.4) > > > I'm calling the following code in my view: > > loader.select_template('test.html') > > > Which results in the following error: > > > TemplateDoesNotExist at /test > > t, e, s, ., h, m, l > > > Can't really figure out what I'm doing wrong as this should be rather > > straightforward. > > > Thanks > > > -- > > 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 > > (mailto:django-users@googlegroups.com). > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > (mailto:django-users+unsubscr...@googlegroups.com). > > For more options, visit this group > > athttp://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.
Loading static files from a dev environment
I'm having an odd problem with my test Django environment. It seems that static filles I've collected from different apps using the collectstatic command works fine, while other static files I placed in myself result in 404 error. This can happen from the same directory (where a png that was collected will load, but a png i just drop in will fail). all files have the same permissions, and I can't figure out why this would happen. I'm currently able to solve this by serving the files through ngnix - but I really shouldn't need to do that. Any ideas why this might be happening ? Thanks -- 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 static files STATIC_ROOT vs STATICFILES_FINDERS
Hi, I'm not sure if this is a bug or am I missing something but I've created a very simple test environment and placed a single png file within my static folder. The file is being served fine when I set : STATIC_ROOT = '' STATICFILES_DIRS = ( '/Users/guynesher/Work/play/quicktest/testproj/static/', ) however I'm geting a 404 error when I set it like this : STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/' STATICFILES_DIRS = ( ) Based on the STATICFILES_DIRS comment (Additional locations of static files) I expected I will only need to use it if I have multiple static files directory which doesn't seem to be the case. What am I missing here? -- 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 static files STATIC_ROOT vs STATICFILES_FINDERS
But then shouldn't I expect the files to be served from the STATIC_ROOT as well ? On Apr 23, 12:38 pm, Philip Mountifield wrote: > There is a slight difference: > > * STATIC_ROOT is where you would like the files to be collected to > when you run "manage.py collectstatic" and should be empty to begin > with. > * STATICFILES_DIRS is where the actual files are located and they will > be automagically servered under the development server. > * You can also create a folder called "static" in any app and put > files in there. > > Regards > Phil > > On 23/04/2012 12:32, gnesher wrote: > > > > > > > > > > > Hi, > > > I'm not sure if this is a bug or am I missing something but I've > > created a very simple test environment and placed a single png file > > within my static folder. > > > The file is being served fine when I set : > > STATIC_ROOT = '' > > STATICFILES_DIRS = ( > > '/Users/guynesher/Work/play/quicktest/testproj/static/', > > ) > > > however I'm geting a 404 error when I set it like this : > > STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/' > > STATICFILES_DIRS = ( > > ) > > > Based on the STATICFILES_DIRS comment (Additional locations of static > > files) I expected I will only need to use it if I have multiple static > > files directory which doesn't seem to be the case. > > > What am I missing here? > > -- > > Philip Mountifield > Formac Electronics Ltd > tel +44 (0) 1225 837333 > fax +44 (0) 1225 430995 > > pmountifi...@formac.netwww.formac.netwww.telgas.net -- 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 static files STATIC_ROOT vs STATICFILES_FINDERS
I'm running manage.py runserver (on the dev environment) the only reason I'm asking this is because I'm quite certain on my previous installs (Django 1.3) it worked fine On Apr 23, 12:54 pm, Philip Mountifield wrote: > It depends how you are running. When using "manage.py runserver" it > serves the static files for you, without even needing to collect them > IIRC. But when deploying, you have to run "manage.py collectstatic" and > Django collects all the files from the other locations for you and puts > them in STATIC_ROOT, which you would configure your webserver to serve > at STATIC_URL. The docs are pretty clear on this: > > https://docs.djangoproject.com/en/1.4/howto/static-files/ > > Regards > Phil > > On 23/04/2012 12:49, gnesher wrote: > > > > > > > > > > > But then shouldn't I expect the files to be served from the > > STATIC_ROOT as well ? > > > On Apr 23, 12:38 pm, Philip Mountifield > > wrote: > >> There is a slight difference: > > >> * STATIC_ROOT is where you would like the files to be collected to > >> when you run "manage.py collectstatic" and should be empty to begin > >> with. > >> * STATICFILES_DIRS is where the actual files are located and they will > >> be automagically servered under the development server. > >> * You can also create a folder called "static" in any app and put > >> files in there. > > >> Regards > >> Phil > > >> On 23/04/2012 12:32, gnesher wrote: > > >>> Hi, > >>> I'm not sure if this is a bug or am I missing something but I've > >>> created a very simple test environment and placed a single png file > >>> within my static folder. > >>> The file is being served fine when I set : > >>> STATIC_ROOT = '' > >>> STATICFILES_DIRS = ( > >>> '/Users/guynesher/Work/play/quicktest/testproj/static/', > >>> ) > >>> however I'm geting a 404 error when I set it like this : > >>> STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/' > >>> STATICFILES_DIRS = ( > >>> ) > >>> Based on the STATICFILES_DIRS comment (Additional locations of static > >>> files) I expected I will only need to use it if I have multiple static > >>> files directory which doesn't seem to be the case. > >>> What am I missing here? > >> -- > > >> Philip Mountifield > >> Formac Electronics Ltd > >> tel +44 (0) 1225 837333 > >> fax +44 (0) 1225 430995 > > >> pmountifi...@formac.netwww.formac.netwww.telgas.net > > -- > > Philip Mountifield > Formac Electronics Ltd > tel +44 (0) 1225 837333 > fax +44 (0) 1225 430995 > > pmountifi...@formac.netwww.formac.netwww.telgas.net -- 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.
Validating a specific form field
I'm trying to catch a specific error for a specific form field. at the moment I'm doing something like this : if form.is_valid(): else: if 'email' in form.errors and form.errors['email'][0] == 'Email address has already entered today': but this seems like a bad way of doing this (error message might change etc.) Is there a better way to run the validation ? Guy -- 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/-/9rz8s5OpqXsJ. 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.