Scott Nixon avatar Scott Nixon committed 8abdcff

Added cross domain middleware. Fixed formatting for archive pages. Added links for the archive. Updated blog recipe to show bullet icons. Added several fixed to address problems with topic/category lookups.

Comments (0)

Files changed (13)

article/middleware/django-crossdomainxhr-middleware.py

+import re
+import logging
+
+from django.utils.text import compress_string
+from django.utils.cache import patch_vary_headers
+
+from django import http
+
+try:
+    import settings 
+    XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
+    XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS
+except:
+    XS_SHARING_ALLOWED_ORIGINS = 'http://css.happyherbivore'
+    XS_SHARING_ALLOWED_METHODS = ['POST','GET','OPTIONS', 'PUT', 'DELETE']
+
+#logger = logging.getLogger(__name__)
+
+class XsSharing(object):
+    """
+        This middleware allows cross-domain XHR using the html5 postMessage API.
+         
+
+        Access-Control-Allow-Origin: http://foo.example
+        Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
+    """
+    def process_request(self, request):
+        #logger.info("process request")
+        if 'HTTP_ACCESS_CONTROL_REQUEST_METHOD' in request.META:
+            response = http.HttpResponse()
+            response['Access-Control-Allow-Origin']  = XS_SHARING_ALLOWED_ORIGINS 
+            response['Access-Control-Allow-Methods'] = ",".join( XS_SHARING_ALLOWED_METHODS ) 
+            
+            return response
+
+        return None
+
+    def process_response(self, request, response):
+        # Avoid unnecessary work
+        if response.has_header('Access-Control-Allow-Origin'):
+            return response
+
+        response['Access-Control-Allow-Origin']  = XS_SHARING_ALLOWED_ORIGINS 
+        response['Access-Control-Allow-Methods'] = ",".join( XS_SHARING_ALLOWED_METHODS )
+
+        return response

article/templates/_blog_recipe.html

                   <ul class="ingredients">
                     {% for r in post.post_recipe.get_ingredients %}
 	                <li class="ingredient">
+                      <p>
 	                  <span class="value">
 	                    {% if r.ri_amount %}
 	                    {{ r.ri_amount|html_fraction|safe}}
 		                  {% if r.ri_ingred.affiliate_link %}</a>{% endif %}
 	                  </span> 
 	                  {% if r.ri_optional %}(optional){% endif %}
+                      </p>
 	                </li>
 	                {% endfor %}
                   </ul> 

article/templates/_footer.html

   <div class="span3">
     <h4>Quick Links</h4>
     <ul>
+      <li><a href="{% url blog-archive %}">Blog Archive</a></li>
       <li><a href="/cookbooks/">Cookbooks</a></li>
       <li><a href="//getmealplans.com/">Meal Plans</a></li>
       <li><a href="/recipes/">Recipes</a></li>

article/templates/article/post_archive.html

 {% block title %} Blog Archive {% endblock %}
 
 {% block body %} 
-{% block feeds %}
-<link rel="alternate" type="application/rss+xml" title="Public Feeds" href="/feed/latest/">
-{% endblock feeds%}
+<div id="content">
 
-	<div class="title"><span>Blog Archive</span></div>
+  <!-- breadcrumb -->
+  <div class="container">
+    <div class="row">
+      <div class="span15">
+        <ul class="breadc clearfix">
+          <li><a href="/">Home</a></li>
+          <li><a href="{% url blog-archive %}">Blog Archive</a></li>
+        </ul>
+        <h1 class="page-title">Blog Archive</h1>
+      </div>
+    </div>
+  </div>
 
 
- 	{% for d in date_list %}  
-	  <a href="/{{ d.year }}/">{{ d.year }}</a>
-	  <ul>
-	    {% for m in date_list.month %}
-	    <li>{{ m }}</li>
-	    {% endfor %}
-	  </ul>
-	{% endfor %}
+  <div id="outer-wrapper">
+    <div class="container">
+      <!-- Content -->
+      <div class="row">
+        <div class="wrapper-box">
+          <div class="span7">
 
-	{% for l in latest %}
-	  <h3><a alt="permanent link to {{ l.post_title }}" 
-				    href="{{ l.get_absolute_url }}">
-	      {{ l.post_title }}</a></h3>			
-	<p class="headline">{{ l.post_date_create|date:"F j, Y" }}</p>
+	          <style>
+	            ul.arch_month {
+	            display: block;
+	            clear: both;
+	            }
+	            ul.arch_month li {
+	            display: block;
+	            float: left;
+	            padding: 1em 0.35em;
+	            }
+	          </style>
 
-	{% empty %}
-		<p>Hmm no data.</p>
-	{% endfor %}
+              <h2>Archive Years</h2>
+              <ul class="arch_month">
+                {% for d in date_list %}  
+	            <li><a href="/{{ d.year }}/">{{ d.year }}</a></li>
+	            {% endfor %}
+	          </ul>            
+
+              <div style="clear:both;">
+                <h2>All Blog Posts</h2>
+	            {% for l in latest %}
+	            <h3><a alt="permanent link to {{ l.post_title }}" 
+				       href="{{ l.get_absolute_url }}">
+	                {{ l.post_title }}</a></h3>			
+	            <p class="headline">{{ l.post_date_create|date:"F j, Y" }}</p>
+            
+	            {% empty %}
+		            <p>Hmm no data.</p>
+	                {% endfor %}
+              </div>
 				
 
+          </div><!-- /span 7 -->
+          <div class="span5">
+
+          </div>
+        
+        </div><!-- /wrapper-box -->
+      </div><!-- /row -->
+
+    </div> <!-- /container -->
+
+  </div><!-- / outer-wrapper -->
+</div><!-- / content -->   
+
 
 {% endblock %} 
 

article/templates/article/post_archive_month.html

 {% extends "theme_base.html" %}
 
-{% block head_title %} Blog Archive {% endblock %}
+{% block head_title %} Blog Archive {{ month|date:"F Y" }}{% endblock %}
 
 {% block body %} 
-{% block feeds %}
-<link rel="alternate" type="application/rss+xml" title="Public Feeds" href="/feed/latest/">
-{% endblock feeds%}
 
+<div id="content">
 
-	<div class="title"><span>Blog Archive {{ month|date:"F Y" }}</span></div>
+  <!-- breadcrumb -->
+  <div class="container">
+    <div class="row">
+      <div class="span15">
+        <ul class="breadc clearfix">
+          <li><a href="/">Home</a></li>
+          <li><a href="{% url blog-archive %}">Blog Archive</a></li>
+          <li><a href="/{{ month|date:'Y' }}/">{{ month|date:"Y" }}</a></li>          
+          <li><a href="/{{ month|date:'Y' }}/{{ month|date:'m' }}/">{{ month|date:"F" }}</a></li>
+        </ul>
+        <h1 class="page-title">Blog Archive {{ month|date:"F Y" }}</h1>
+      </div>
+    </div>
+  </div>
+
+
+  <div id="outer-wrapper">
+    <div class="container">
+      <!-- Content -->
+      <div class="row">
+        <div class="wrapper-box">
+          <div class="span7">
+
+
+
+	<div class="title"><span></span></div>
 
 	  <p class="well"><a style="float:left;" href="/{{ previous_month|date:"Y" }}/{{ previous_month|date:"m" }}/"><< {{ previous_month|date:"F Y" }}</a> {% if next_month %} <a style="float:right;" href="/{{ next_month|date:"Y" }}/{{ next_month|date:"m" }}/">{{ next_month|date:"F Y" }} >></a>{% endif %}</p>
 
 
       <p class="well"><a style="float:left;" href="/{{ previous_month|date:"Y" }}/{{ previous_month|date:"m" }}/"><< {{ previous_month|date:"F Y" }}</a> {% if next_month %} <a style="float:right;" href="/{{ next_month|date:"Y" }}/{{ next_month|date:"m" }}/">{{ next_month|date:"F Y" }} >></a>{% endif %}</p>
 	
+          </div><!-- /span 7 -->
+          <div class="span5">
 
+          </div>
+        
+        </div><!-- /wrapper-box -->
+      </div><!-- /row -->
+
+    </div> <!-- /container -->
+
+  </div><!-- / outer-wrapper -->
+</div><!-- / content -->   
 
 {% endblock %} 
 

article/templates/article/post_archive_year.html

 {% extends "theme_base.html" %}
 
-{% block head_title %} Blog Archive by Year {% endblock %}
+{% block head_title %} Blog Archive {{ year }} {% endblock %}
 
 {% block body %} 
-{% block feeds %}
-<link rel="alternate" type="application/rss+xml" title="Public Feeds" href="/feed/latest/">
-{% endblock feeds%}
+<div id="content">
 
-	<div class="title"><span>Blog Archive {{ year }}</span></div>
-	<div class="menu_content">
-	  <style>
-	    ul.arch_month {
-	        display: block;
-	        clear: both;
-	    }
-	    ul.arch_month li {
-	        display: block;
-	        float: left;
-	        padding: 1em 0.35em;
-	    }
-	  </style>
+  <!-- breadcrumb -->
+  <div class="container">
+    <div class="row">
+      <div class="span15">
+        <ul class="breadc clearfix">
+          <li><a href="/">Home</a></li>
+          <li><a href="{% url blog-archive %}">Blog Archive</a></li>
+          <li><a href="{% url archive-year year %}">{{ year }}</a></li>
+        </ul>
+        <h1 class="page-title">Blog Archive {{ year }}</h1>
+      </div>
+    </div>
+  </div>
 
-	<ul class="arch_month"> 
-	{% for d in date_list %}  
-	   <li><a href="/{{d.year}}/{{ d|date:'m' }}/">{{ d|date:"N" }}</a></li>
-	{% endfor %}
-	</ul>
 
-	<div style="clear:both;">
-	{% for i in object_list %}
-	    <h3><a alt="permanent link to {{ i.post_title }}" 
-			href="{{ i.get_absolute_url }}">
-			{{ i.post_title }}</a></h3>			
-			<p class="headline">{{ i.post_date_create|date:"F j, Y" }}</p>
-	{% endfor %}				
-	</div>
+  <div id="outer-wrapper">
+    <div class="container">
+      <!-- Content -->
+      <div class="row">
+        <div class="wrapper-box">
+          <div class="span7">
+
+	          <style>
+	            ul.arch_month {
+	            display: block;
+	            clear: both;
+	            }
+	            ul.arch_month li {
+	            display: block;
+	            float: left;
+	            padding: 1em 0.35em;
+	            }
+	          </style>
+              
+	          <ul class="arch_month"> 
+	            {% for d in date_list %}  
+	            <li><a href="/{{d.year}}/{{ d|date:'m' }}/">{{ d|date:"N" }}</a></li>
+	            {% endfor %}
+	          </ul>
+
+              <div style="clear:both;">
+	            {% for i in object_list %}
+	            <h3><a alt="permanent link to {{ i.post_title }}" 
+			           href="{{ i.get_absolute_url }}">
+			        {{ i.post_title }}</a></h3>			
+			    <p>{{ i.post_date_create|date:"F j, Y" }}</p>
+	            {% endfor %}				
+              </div>
+
+          </div><!-- /span 7 -->
+          <div class="span5">
+
+          </div>
+        
+        </div><!-- /wrapper-box -->
+      </div><!-- /row -->
+
+    </div> <!-- /container -->
+
+  </div><!-- / outer-wrapper -->
+</div><!-- / content -->   
+
 
 {% endblock %} 
 

article/templates/homepage.html

 
     <meta property="og:title" content="LEAF: Low Fat, Everyday, Affordable & Fast Recipes | Happy Herbivore"/>
     <meta property="og:type" content="website"/>
-    <meta property="og:image" content="//photos.happyherbivore.com/logos/Big-Baby-Elephant.png"/>
+    <meta property="og:image" content="http://photos.happyherbivore.com/logos/Big-Baby-Elephant.png"/>
     <meta property="og:description"
           content="Lindsay S. Nixon's cookbooks will save you money by using 'everyday' inexpensive ingredients, save you time with easy, no fuss recipes and improve your health with each nutritional bite. Over 70,000 cookbooks."/>
     <link rel="alternate" type="application/rss+xml" title="Public Feeds" href="http://feeds.feedburner.com/HappyHerbivore-Blog">
             </div>
           </div><!-- / intro-container-->
           <div class="span5 offset1">
+            <a href="/get-started/">
             <div class="intro2 hidden-phone">
               <h2>Happy Herbivore recipes are...</h2>
                <div class="home-rec-box">
                 <p class="hidden-tablet">Uncomplicated recipes using normal "everyday" ingredients. No fuss!</p>
                </div> 
              </div><!-- / intro2 -->       
+            </a>
           </div>
         </div>
 

article/templates/new_here.html

           <h3>About Lindsay</h3>
           <p>Hi! I'm Lindsay and Happy Herbivore is my recipe website, home to more than 140 fat-free and low fat healthy vegan recipes! I cook with no added fats and mostly whole, unprocessed food. You won't find processed flour, refined sugars and oil or margarine in my recipes. What you will find, however, is food that is good for you and tastes great!</p>
           <img src="http://photos.happyherbivore.com/img/lindsay.jpg" alt="Lindsay S. Nixon in the kitchen." title="Lindsay Nixon" class="lindsay">
-          <p>I'm the author of <a href="/cookbook/happy-herbivore-cookbook/">The Happy Herbivore Cookbook</a> and <a href="/cookbook/everyday-happy-herbivore/">Everyday Happy Herbivore</a>. I write doable recipes that are quick and easy, you could cook from scratch three meals and day with whatever ingredients you have on hand. I take care to write most of my  recipes so they can come together in twenty minutes, my recipes are no-fuss so you can save time and still improve your health while eating a delicious meal.</p>
+          <p>I'm the author of <a href="/cookbook/happy-herbivore-cookbook/">The Happy Herbivore Cookbook</a>, <a href="/cookbook/everyday-happy-herbivore/">Everyday Happy Herbivore</a>, and <a href="http://www.amazon.com/Happy-Herbivore-Abroad-Travelogue-Fat-Free/dp/1937856046/?tag=happyherbi-20">Happy Herbivore Abroad</a> available December 4, 2012. I write doable recipes that are quick and easy, you could cook from scratch three meals and day with whatever ingredients you have on hand. I take care to write most of my  recipes so they can come together in twenty minutes, my recipes are no-fuss so you can save time and still improve your health while eating a delicious meal.</p>
           <h3>Why Plant Based?</h3>
           <p>Eating a plant-based diet is the nation’s fastest-growing food trend, and for good reason. The more plant-based meals we eat, the more benefits we will feel and bestow. Whenever someone asks me why I’m a vegan, I reply, “For my health, my pocketbook, the animals, the environment…and for you.” Here’s my post on what <a href="http://happyherbivore.com/2011/09/what-is-vegan/">veganism means to me.</a></p>
  

article/templates/post_detail.html

                   <p class="post-date">{{ post.published_on|naturalday:"N j, Y"|capfirst }}</p>
                 </div>
                 <h1 class="title">{{ post.post_title }}</h1>
-                <p class="meta">Posted by: <a href="#">Lindsay Nixon</a> | <a alt="link to {{ post.post_title }} Comments" 
-			href="#disqus_thread">{% disqus_num_replies %}</a></p>
-                {% if post.post_tags %}<p class="meta">Category: {% for p in post.get_tag_list %}<a href="{% url category p %}">{{ p }}</a> {% endfor %}</p>{% endif %}
+                <p class="meta">Posted by: <a href="/get-started/">{{ post.post_author.get_full_name }}</a> | <a alt="link to {{ post.post_title }} Comments" href="#disqus_thread">{% disqus_num_replies %}</a> </p>
+                {% if post.post_tags %}<p class="meta">Category: {% for p in post.get_tag_list %}<a href="{% url category p %}">{{ p }}</a> {% endfor %}{% endif %}</p>
+                
                 <div class="content">
                   {{ post.post_content|safe|linebreaks }}
                 </div>
                 {% gblock 6 for "gblocks.TitleAndText" into "FeedBurner" %}
                 {{ FeedBurner.text|safe }}
 
+                <div class="categories-box">
+                  <h4>Topics</h4>
+                  <ul>
+                    {% load tagging_tags %}
+                    {% tags_for_model article.Post as tag_list %}
+                    {% for t in tag_list %}
+                    <li><a {% if tag_obj == t.name %}class="label-green"{% else %}class="label-orange"{% endif %} href="{% url category t.name %}">{{t.name}}</a></li>
+                    {% endfor %}
+                  </ul>
+                </div><!-- / categories-box -->
 
                 <hr class="separator" />
 

article/templates/post_list.html

                   <a alt="permanent link to {{ post.post_title }}" href="{{ post.get_absolute_url }}">
 			        {{ post.post_title }}</a>
                 </h2>
-                <p class="meta">Posted by: <a href="/about/">{{ post.post_author.get_full_name }}</a> | <a alt="permanent link to {{ post.post_title }}" href="{{ post.get_absolute_url }}#disqus_thread">{% disqus_num_replies %}</a></p>
+                <p class="meta">Posted by: <a href="/get-started/">{{ post.post_author.get_full_name }}</a> | <a alt="permanent link to {{ post.post_title }}" href="{{ post.get_absolute_url }}#disqus_thread">{% disqus_num_replies %}</a></p>
                 {% if post.post_tags %}<p class="meta">Category: {% for p in post.get_tag_list %}<a href="{% url category p %}">{{ p }}</a> {% endfor %}</p>{% endif %}
 
                 <div class="content">
                 {% gblock 6 for "gblocks.TitleAndText" into "FeedBurner" %}
                 {{ FeedBurner.text|safe }}                
 
+                <div class="categories-box">
+                  <h4>Topics</h4>
+                  <ul>
+                    {% load tagging_tags %}
+                    {% tags_for_model article.Post as tag_list %}
+                    {% for t in tag_list %}
+                    <li><a {% if tag_obj == t.name %}class="label-green"{% else %}class="label-orange"{% endif %} href="{% url category t.name %}">{{t.name}}</a></li>
+                    {% endfor %}
+                  </ul>
+
+                </div><!-- / categories-box -->
 
                 <hr class="separator" />
 
+                <div class="archive-box">
+                  <h4><a href="{% url blog-archive %}">Blog Archive</a></h4>
+                  <ul>
+                    <li><a href="{% url archive-year 2012 %}">2012</a></li>
+                    <li><a href="{% url archive-year 2011 %}">2011</a></li>
+                    <li><a href="{% url archive-year 2010 %}">2010</a></li>
+                    <li><a href="{% url archive-year 2009 %}">2009</a></li>
+                    <li><a href="{% url archive-year 2008 %}">2008</a></li>
+                  </ul>
+                </div>
+
+
                 {% gblock 8 for "gblocks.TitleAndText" into "BlogFavorites" %}
                 {{ BlogFavorites.text|safe }}
 

article/templates/theme_base.html

 {% spaceless %}
 <!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:og="http://ogp.me/ns#"
-      xmlns:fb="https://www.facebook.com/2008/fbml" lang="en">
-  <head>
+<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
+  <head prefix="og: http://ogp.me/ns#">
     <meta charset="utf-8" />
     <title>{% block head_title_base %}{% block head_title %}{% endblock %}{% endblock %} | Happy Herbivore</title>
 
         
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <meta property="fb:app_id" content="133322466769084" />
-        <meta property="fb:page_id" content="57667278481" />
         <meta property="og:locale" content="en_US"/>
         <meta property="og:url" content="http://happyherbivore.com{{ request.path_info }}"/>
         <meta property="og:site_name" content="Happy Herbivore"/>
-        <meta property="og:admins" content="741909528,199000214"/>
         {% block meta %}
         {% endblock %}
     {% endblock %}
     url(r'^faq/$', 'faq_index'),
     url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<post_slug>[-\w]+)/$',
         'post_detail', name="post-detail-url"),
-    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/$', MonthArchiveView.as_view(model=Post, month_format='%m', date_field="published_on")),
-    url(r'^(?P<year>\d{4})/$', YearArchiveView.as_view()),
-    url(r'^blog/archive/$', ArchiveIndexView.as_view(model=Post, date_field="published_on")),
+    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/$', MonthArchiveView.as_view(model=Post, month_format='%m', date_field="published_on"), name="archive-month"),
+    url(r'^(?P<year>\d{4})/$', YearArchiveView.as_view(), name="archive-year"),
+    url(r'^blog/archive/$', ArchiveIndexView.as_view(model=Post, date_field="published_on"), name="blog-archive"),
     url(r'^blog/$', 'post_index', name="blog-url"),
     url(r'^topic/(?P<category>[-\w]+)/$', 'post_category_index', name="category"),
     url(r'^get-started/$', TemplateView.as_view(template_name='new_here.html'), name="new_here"),
                                    post_type__in=[1,4]).order_by(
                                    '-published_on')
     type_of_posts = 0
-    paginator = Paginator(post_list, 5) # Show 5 posts per page
+    paginator = Paginator(post_list, 3) # Show 5 posts per page
 	
     try:
         page = int(request.GET.get('page', '1'))
     '''
     current_site = Site.objects.get_current() 
 
-    tag_obj = Tag.objects.get(name=category)
-    tagged_items = TaggedItem.objects.get_by_model(Post, tag_obj)
-    post_list = tagged_items.filter(sites=current_site.id,
+    try:
+        tag_obj = Tag.objects.get(name=category)
+        tagged_items = TaggedItem.objects.get_by_model(Post, tag_obj)
+        post_list = tagged_items.filter(sites=current_site.id,
                                     is_published=1,published_on__lt=datetime.now(),
                                     post_type__in=[1,4]).order_by('-published_on')
+    except (Tag.DoesNotExist, TaggedItem.DoesNotExist, Post.DoesNotExist):
+        raise Http404
 
     type_of_posts = 0
-    paginator = Paginator(post_list, 10) # Show 5 posts per page
+    paginator = Paginator(post_list, 5) # Show 5 posts per page
 	
     try:
         page = int(request.GET.get('page', '1'))
     post_list = Post.active.filter(sites=current_site.id, 
                                    post_type=4).order_by('-published_on')
     type_of_posts = 1
-    paginator = Paginator(post_list, 5) # Show 8 posts per page
+    paginator = Paginator(post_list, 3) # Show 8 posts per page
 	
     try:
         page = int(request.GET.get('page', '1'))
     '''
     This view will handle all recipe details pages.
     '''
-    current_site = Site.objects.get_current()
-    recipe = Recipe.objects.filter(is_published=1, published_on__lt=datetime.now()).get(recipe_slug=recipe_slug)
-    recipephotos = RecipePhotos.objects.filter(recipe=recipe,type=1)
-
+    try:
+        current_site = Site.objects.get_current()
+        recipe = Recipe.objects.filter(is_published=1, published_on__lt=datetime.now()).get(recipe_slug=recipe_slug)
+        recipephotos = RecipePhotos.objects.filter(recipe=recipe,type=1)
+    except Recipe.DoesNotExist:
+        raise Http404
     return render_to_response('recipe_detail.html', locals(),
                                   context_instance=RequestContext(request))
 
         queryparams = clean_params(reqparams)
 
     if tag:
-        tag_obj = Tag.objects.get(name=tag)
-        recipes_list = TaggedItem.objects.get_by_model(Recipe, tag_obj)
-        if not recipes_list:
-            errormsg = "No Tag matches <strong>{0}</strong>.".format(tag) 
+        try:
+            tag_obj = Tag.objects.get(name=tag)
+            recipes_list = TaggedItem.objects.get_by_model(Recipe, tag_obj)
+            if not recipes_list:
+                errormsg = "No Tag matches <strong>{0}</strong>.".format(tag) 
+        except (Tag.DoesNotExist, TaggedItem.DoesNotExist):
+            raise Http404
     elif qname:
-        recipes_list = Recipe.active.filter(sites=current_site.id).filter(recipe_name__icontains=qname).order_by('recipe_name')
-        if not recipes_list:
-            errormsg = "No Recipe Name matches <strong>{0}</strong>.".format(qname)
+        try:
+            recipes_list = Recipe.active.filter(sites=current_site.id).filter(recipe_name__icontains=qname).order_by('recipe_name')
+            if not recipes_list:
+                errormsg = "No Recipe Name matches <strong>{0}</strong>.".format(qname)
+        except Recipe.DoesNotExist:
+            raise Http404
     elif ingred1:
-        recipes_list = Recipe.active.filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred1).filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred2).filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred3).distinct().order_by('recipe_name')
-        if not recipes_list:
-            errormsg = "<h2>No ingredient matches <strong>{0} {1} {2}</strong></h2>".format(ingred1, ingred2, ingred3)
+        try:
+            recipes_list = Recipe.active.filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred1).filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred2).filter(recipe_ingred__ri_ingred__ingred_name__icontains=ingred3).distinct().order_by('recipe_name')
+            if not recipes_list:
+                errormsg = "<h2>No ingredient matches <strong>{0} {1} {2}</strong></h2>".format(ingred1, ingred2, ingred3)
+        except Recipe.DoesNotExist:
+            raise Http404
     else:
         recipes_list = Recipe.active.filter(sites=current_site.id).order_by('recipe_name')
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.