Thanks Kelvin
Dtb/Gby ======= Mario R. Osorio "... Begin with the end in mind ..." http://www.google.com/profiles/nimbiotics On Sun, Oct 13, 2013 at 12:34 AM, Kelvin Wong <[email protected]> wrote: > You need to understand what ALLOWED_HOSTS does if you want to ever deploy > your app. Please read it. > > https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts > > Check your settings in the shell > > >>> from django.conf import settings as s > >>> s.DEBUG > True > >>> s.ALLOWED_HOSTS > ['.example.com', '192.168.0.2'] > > If your DEBUG is False and your ALLOWED_HOSTS is an empty list [] then you > will not get far. You will get a "SuspiciousOperation: Invalid HTTP_HOST > header (you may need to set ALLOWED_HOSTS)" message. > > You can try putting something like this into the template (pretty much > straight from the Django blog example), and it will tell you nicely when it > has nothing matching your query or if your db is empty: > > {% block featured_posts %} > {% if featured_posts_list %} > {% for blog_post in featured_posts_list %} > <p>{{ blog_post.title }}</p> > <br> > {% endfor %} > {% else %} > <p>No posts found</p> > {% endif %} > {% endblock %} > > You might also want to ensure that your view is rendering the right > template and that the template hierarchy is correct (ie. {% extends > "my_templates/base.html" %} is at the top of your template and it is > correct). If your parent template that you're extending doesn't have a > block named 'featured_posts' then it won't display anywhere. You won't see > the "No posts found" message nor will you see your list of blogs - nada. > > If there is an exception in the shell, it will print out a trace. This is > an actual Dj1.5 trace from a made up exception I planted in the view. You > can also put objects like your queryset into the Exception message and see > if your set is producing what you think it should be. > > >>> from django.test import Client > >>> c = Client() > >>> c.get('/') > > Internal Server Error: / > Traceback (most recent call last): > File > "/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", > line 115, in get_response > response = callback(request, *callback_args, **callback_kwargs) > File > "/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/views/generic/base.py", > line 68, in view > return self.dispatch(request, *args, **kwargs) > File > "/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/views/generic/base.py", > line 86, in dispatch > return handler(request, *args, **kwargs) > File > "/Users/kelvin/repos/myproject_files/myproject_repo/myproject/firstweb/views.py", > line 14, in get > raise Exception("Freek out!") > Exception: Freek out! > > > > On Friday, October 11, 2013 5:25:54 PM UTC-7, Mario Osorio wrote: > >> From the server; I am getting the page I need but the block where the >> data from the view in question is supposed to be comes out empty. >> >> I am indeed geting the ALLOWED_HOSTS warning, which I don't fully >> understand and don't know hoe to fix. I do have ALLOWED_HOSTS = >> ('localhost', '.local') and DEBUG = True as I read in Rod's excellent >> tutorial<http://rodmtech.net/docs/mezzanine/a-mezzanine-tutorial-take-2/>, >> but that did not help. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/jLHmh2-Ami0/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/997818db-a73c-40d2-9e81-386b533609b6%40googlegroups.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAO2PNV42VQXDXYQ3apo3vkpbdNHSnEue9u%3D0BAEo1-J2V4c9Bg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.

