Re: Index page using flatpages
> It isn't a bug. Read the docs. Create yourself an empty 404.html and > 500.html file in your templates directory and your flatpage will work > with DEBUG=False. You are so right!! :) It worked like a charm! I neglected this box: "Ensure that your 404 template works Note that the FlatpageFallbackMiddleware only steps in once another view has successfully produced a 404 response. If another view or middleware class attempts to produce a 404 but ends up raising an exception instead (such as a TemplateDoesNotExist exception if your site does not have an appropriate template to use for HTTP 404 responses), the response will become an HTTP 500 (“Internal Server Error”) and the FlatpageFallbackMiddleware will not attempt to serve a flat page." I'm a bit ashamed by blaming such an excellent web framework. I've tried RoR (Ruby) and Symfony (PHP), but I think I'll look no further. Many many thanks, Brian! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
On Dec 10, 1:58 pm, Nuno Machado <[EMAIL PROTECTED]> wrote: > Hi Brian. Thank you. > > I've read the documents you pointed out. But the issue is not on > 404/500 html templates, but in the DEBUG setting. No, it isn't. > > I've started a project from scratch to reproduce my error. I used the > instructions provided in the latest documentation to add FlatPages and > an Admin application. > > When I add a FlatPage for my site index page (URL = /) it works fine. > > Then, if I change the DEBUG flag to False in my settings.py, the index > page is replaced by a 500 error. That's because you don't have a 404.html or 500.html template. > I think this is a bug. If someone has the same behaviour it should be > reported. It isn't a bug. Read the docs. Create yourself an empty 404.html and 500.html file in your templates directory and your flatpage will work with DEBUG=False. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Hi Brian. Thank you. I've read the documents you pointed out. But the issue is not on 404/500 html templates, but in the DEBUG setting. I've started a project from scratch to reproduce my error. I used the instructions provided in the latest documentation to add FlatPages and an Admin application. When I add a FlatPage for my site index page (URL = /) it works fine. Then, if I change the DEBUG flag to False in my settings.py, the index page is replaced by a 500 error. I think this is a bug. If someone has the same behaviour it should be reported. On Dec 10, 6:35 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > On Dec 10, 11:48 am, Nuno Machado <[EMAIL PROTECTED]> wrote: > > > > > My urls.py WAS like this: > > > urlpatterns = patterns('', > > (r'^admin/(.*)', admin.site.root), > > (r'', include('django.contrib.flatpages.urls')), > > ) > > This is your problem. Did you read this: > > http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#ref-contr... > > Note the 4 step installation. The docs don't say to add anything to > your URLs. > > > If I hit, localhost:8000 it __works fine__ BUT if I set DEBUG = False > > in settings.py I get a 500 error TemplateDoesNotExist. With DEBUG = > > False, if I type localhost:8000/about it doesn't work either. > > > This is getting worse. > > No, not really. You are now running into another issue when you have > DEBUG=False. Please see this: > > http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-e... > > You need to define your own 404.html and 500.html templates. When > DEBUG=True, django let's you off the hook on this (because it will > display its own error page for you). > > > > > But I'm really thinking in give up from Flat Pages... it's static > > content, why do I want them in a database? Databases are for raw > > content, not html tags. > > Well no, not necessarily. Sometimes you have content that you may want > to edit from time to time without messing with the code and possibly > restarting the server. Or you may have someone who works on the site > who doesn't know HTML and you've given him TinyMCE or another WYSIWYG > editor installed on the flatpages admin. > > > > > There are some fancy options in Flat Pages, like "Enable comments" and > > "Registration Required" but I think I will easily add these features > > in my static pages later, am I wrong? > > Sure you can do it either way. > > BN --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
On Dec 10, 11:48 am, Nuno Machado <[EMAIL PROTECTED]> wrote: > > My urls.py WAS like this: > > urlpatterns = patterns('', > (r'^admin/(.*)', admin.site.root), > (r'', include('django.contrib.flatpages.urls')), > ) This is your problem. Did you read this: http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#ref-contrib-flatpages Note the 4 step installation. The docs don't say to add anything to your URLs. > If I hit, localhost:8000 it __works fine__ BUT if I set DEBUG = False > in settings.py I get a 500 error TemplateDoesNotExist. With DEBUG = > False, if I type localhost:8000/about it doesn't work either. > > This is getting worse. No, not really. You are now running into another issue when you have DEBUG=False. Please see this: http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views You need to define your own 404.html and 500.html templates. When DEBUG=True, django let's you off the hook on this (because it will display its own error page for you). > > But I'm really thinking in give up from Flat Pages... it's static > content, why do I want them in a database? Databases are for raw > content, not html tags. Well no, not necessarily. Sometimes you have content that you may want to edit from time to time without messing with the code and possibly restarting the server. Or you may have someone who works on the site who doesn't know HTML and you've given him TinyMCE or another WYSIWYG editor installed on the flatpages admin. > > There are some fancy options in Flat Pages, like "Enable comments" and > "Registration Required" but I think I will easily add these features > in my static pages later, am I wrong? Sure you can do it either way. BN --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Thanks a lot, Jeff FW and Dmitry Dzhus. I'm using the most recent release version of Django (installed 5 days ago). 'django.contrib.flatpages' and 'django.contrib.sites' are listed in my INSTALLED_APPS. 'middleware.FlatpageFallbackMiddleware' is in my MIDDLEWARE_CLASSES. My urls.py WAS like this: urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), (r'', include('django.contrib.flatpages.urls')), ) If I hit, localhost:8000 I would get: Too many redirects occurred trying to open “http://127.0.0.1:8000/”. If I ask for localhost:8000// I would work fine. NOW, I commented the last line of urls.py: urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), # (r'', include('django.contrib.flatpages.urls')), ) If I hit, localhost:8000 it __works fine__ BUT if I set DEBUG = False in settings.py I get a 500 error TemplateDoesNotExist. With DEBUG = False, if I type localhost:8000/about it doesn't work either. This is getting worse. But I'm really thinking in give up from Flat Pages... it's static content, why do I want them in a database? Databases are for raw content, not html tags. There are some fancy options in Flat Pages, like "Enable comments" and "Registration Required" but I think I will easily add these features in my static pages later, am I wrong? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Nuno Machado wrote: > If I put / in the URL field, I need to write "mysite.com//" to get > access to my index page. This is not good for visitors! It works fine for me when URL of flatpage is just slash, I type in site.com and see my flatpage. Probably your Django installation is a bit old or misconfigured? What is an exact error you get? Have you enabled `FlatpageFallbackMiddleware`? Have you removed default root URL from your `urls.py` (flatpage doesn't show up otherwise)? -- Happy Hacking. http://sphinx.net.ru む --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Nuno, "Yes, I do. It's a default setting." Never hurts to check--just because it's default, doesn't mean you haven't unset it :-) I just ran a very simple test, using a project that I use for testing Django apps--which I had never used flatpages in. I added the FlatpageMiddleware, added flatpages to INSTALLED_APPS, synced the database, then created a page with a URL of just /, and created a default template. It worked fine--I can go to localhost:8000/ and get correct page--and I can also go to localhost:8000 and get redirected to the first URL. Perhaps you have something in your urls.py that's overriding what flatpages should be handling? -Jeff On Dec 10, 5:33 am, Nuno Machado <[EMAIL PROTECTED]> wrote: > Hi Jeff, > > Yes, I do. It's a default setting. > > I've been thinking about the 'django.contrib.flatpages' and the > 'django.contrib.sites' modules and in some cases, they are worse than > good. > > Maybe I'm facing one of those cases, so I should get ride of those > modules and deploy an "extras" application with just views and > templates but no models (no database). > > If someone has some other hints, I'll be glad to listen. Thank you. > > On Dec 10, 4:08 am, Jeff FW <[EMAIL PROTECTED]> wrote: > > > Do you have CommonMiddleware enabled in your settings.py? > > >http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.mi... > > > On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I'm using flatpages to display some static content in a site. The > > > "about" page is working flawlessly (URL = mysite.com/about) but now > > > I'm trying to define the index (URL = mysite.com) using flatpages. > > > > I'm having troubles defining the URL in the administration panel: > > > > If I put / in the URL field, I need to write "mysite.com//" to get > > > access to my index page. This is not good for visitors! > > > > Your help is much appreciated. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Hi Jeff, Yes, I do. It's a default setting. I've been thinking about the 'django.contrib.flatpages' and the 'django.contrib.sites' modules and in some cases, they are worse than good. Maybe I'm facing one of those cases, so I should get ride of those modules and deploy an "extras" application with just views and templates but no models (no database). If someone has some other hints, I'll be glad to listen. Thank you. On Dec 10, 4:08 am, Jeff FW <[EMAIL PROTECTED]> wrote: > Do you have CommonMiddleware enabled in your settings.py? > > http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.mi... > > On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm using flatpages to display some static content in a site. The > > "about" page is working flawlessly (URL = mysite.com/about) but now > > I'm trying to define the index (URL = mysite.com) using flatpages. > > > I'm having troubles defining the URL in the administration panel: > > > If I put / in the URL field, I need to write "mysite.com//" to get > > access to my index page. This is not good for visitors! > > > Your help is much appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Index page using flatpages
Do you have CommonMiddleware enabled in your settings.py? http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using flatpages to display some static content in a site. The > "about" page is working flawlessly (URL = mysite.com/about) but now > I'm trying to define the index (URL = mysite.com) using flatpages. > > I'm having troubles defining the URL in the administration panel: > > If I put / in the URL field, I need to write "mysite.com//" to get > access to my index page. This is not good for visitors! > > Your help is much appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---