URLs all read from urls.py file now, no hardcoded URLs
authorKriti Godey <kriti.godey@gmail.com>
Mon, 8 Mar 2010 21:44:07 +0000 (16:44 -0500)
committerKriti Godey <kriti.godey@gmail.com>
Mon, 8 Mar 2010 21:44:07 +0000 (16:44 -0500)
templates/base.html
templates/ingredient.html
templates/login.html
templates/newuser.html
templates/sandwich.html
urls.py

index a910bb1..e7a0140 100644 (file)
                                <h3 class="navtitle">Account</h3>
                                <ul class="nav">
                                        {% if user.is_authenticated %}
                                <h3 class="navtitle">Account</h3>
                                <ul class="nav">
                                        {% if user.is_authenticated %}
-                                               <li><a href="http://127.0.0.1:8000/sandwich/add/" class="navlink">Add sandwich</a></li>
-                                               <li><a href="http://127.0.0.1:8000/logout/" class="navlink">Logout</a></li>
+                                               <li><a href="{% url add_sandwich %}" class="navlink">Add sandwich</a></li>
+                                               <li><a href="{% url logout %}" class="navlink">Logout</a></li>
                                        {% else %}
                                        {% else %}
-                                               <li><a href="http://127.0.0.1:8000/login/" class="navlink">Login</a></li>
-                                               <li><a href="http://127.0.0.1:8000/signup/" class="navlink">Signup</a></li>
+                                               <li><a href="{% url login %}" class="navlink">Login</a></li>
+                                               <li><a href="{% url signup %}" class="navlink">Signup</a></li>
                                        {% endif %}
                                </ul>
                                <h3 class="navtitle">Newest</h3>
                                        {% endif %}
                                </ul>
                                <h3 class="navtitle">Newest</h3>
                                <h3 class="navtitle">Sandwiches</h3>
                                <ul class="newest">
                                        {% for m in monthly %}
                                <h3 class="navtitle">Sandwiches</h3>
                                <ul class="newest">
                                        {% for m in monthly %}
-                                       <li><a href="http://127.0.0.1:8000/sandwich/{{ m.year }}/{{ m.month }}/"> {{ m|date:"F" }} {{m.year}} </a></li>
+                                       <li><a href="{% url sandwich_by_month year=m.year, month=m.month %}"> {{ m|date:"F" }} {{m.year}} </a></li>
                                        {% endfor %}
                                </ul>
                                <ul class="newest">
                                        {% endfor %}
                                </ul>
                                <ul class="newest">
-                                       <li><a href="http://127.0.0.1:8000/sandwich/all/" class="navlink">All sandwiches</a></li>
+                                       <li><a href="{% url all_sandwiches %}" class="navlink">All sandwiches</a></li>
                                </ul>
                        </div>
                        <div id="content">
                                </ul>
                        </div>
                        <div id="content">
index 23be3a0..2758320 100644 (file)
@@ -3,7 +3,7 @@
 {% block title %}Add an ingredient{% endblock %}
 {% block content %}
        <h1 class="pagetitle">Add a new ingredient</h1>
 {% block title %}Add an ingredient{% endblock %}
 {% block content %}
        <h1 class="pagetitle">Add a new ingredient</h1>
-       <form enctype="multipart/form-data" action="/sandwich/addingredient/" method="post">
+       <form enctype="multipart/form-data" action="{% url add_ingredient %}" method="post">
        {{ iform.as_p }}
        <input type="submit" value="Submit" />
        </form>
        {{ iform.as_p }}
        <input type="submit" value="Submit" />
        </form>
index c92d7cf..aba342a 100644 (file)
@@ -2,7 +2,7 @@
 
 {% block content %}
        <h1 class="pagetitle">Login</h1>
 
 {% block content %}
        <h1 class="pagetitle">Login</h1>
-       <form enctype="multipart/form-data" action="/login/" method="post">
+       <form enctype="multipart/form-data" action="{% url login %}" method="post">
        {{ aform.as_p }}
        <input type="submit" value="Submit" />
        </form>
        {{ aform.as_p }}
        <input type="submit" value="Submit" />
        </form>
index fcba9c3..41eaa0e 100644 (file)
@@ -2,7 +2,7 @@
 
 {% block content %}
        <h1 class="pagetitle">Create account</h1>
 
 {% block content %}
        <h1 class="pagetitle">Create account</h1>
-       <form enctype="multipart/form-data" action="/newuser/" method="post">
+       <form enctype="multipart/form-data" action="{% url signup %}" method="post">
        {{ cform.as_p }}
        <input type="submit" value="Submit" />
        </form>
        {{ cform.as_p }}
        <input type="submit" value="Submit" />
        </form>
index d87265e..09d2a9a 100644 (file)
@@ -3,7 +3,7 @@
 {% block title %}Add a sandwich{% endblock %}
 {% block content %}
        <h1 class="pagetitle">Add a new sandwich</h1>
 {% block title %}Add a sandwich{% endblock %}
 {% block content %}
        <h1 class="pagetitle">Add a new sandwich</h1>
-       <form enctype="multipart/form-data" action="/sandwich/add/" method="post">
+       <form enctype="multipart/form-data" action="{% url add_sandwich %}" method="post">
        {{ sform.as_p }}
        <input type="submit" value="Submit" />
        </form>
        {{ sform.as_p }}
        <input type="submit" value="Submit" />
        </form>
diff --git a/urls.py b/urls.py
index 08e08e5..8f48e0f 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -3,13 +3,13 @@ import views
 from django.shortcuts import render_to_response
 
 urlpatterns = patterns('',
 from django.shortcuts import render_to_response
 
 urlpatterns = patterns('',
-       (r'^sandwich/add/$', views.add_sandwich),
-       (r'^sandwich/addingredient/$', views.add_ingredient),
-       (r'^sandwich/all/$', views.all_sandwich),
-       (r'^sandwich/(?P<year>[-\w]+)/(?P<month>[-\w]+)/$', views.sandwich_month),
+       url(r'^sandwich/add/$', views.add_sandwich, name='add_sandwich'),
+       url(r'^sandwich/addingredient/$', views.add_ingredient, name='add_ingredient'),
+       url(r'^sandwich/all/$', views.all_sandwich, name='all_sandwiches'),
+       url(r'^sandwich/(?P<year>[-\w]+)/(?P<month>[-\w]+)/$', views.sandwich_month, name='sandwich_by_month'),
        url(r'^sandwich/(?P<slug>[-\w]+)/$', views.specific_sandwich, name='sandwich_by_slug'),
        url(r'^sandwich/(?P<slug>[-\w]+)/$', views.specific_sandwich, name='sandwich_by_slug'),
-       (r'^login/$', views.login_view),
-       (r'^logout/$', views.logout_view),
-       (r'^signup/$', views.create_user),
-       (r'', views.current_home),
+       url(r'^login/$', views.login_view, name='login'),
+       url(r'^logout/$', views.logout_view, name='logout'),
+       url(r'^signup/$', views.create_user, name='signup'),
+       url(r'', views.current_home, name='index'),
 )
 )