Skip to content

Instantly share code, notes, and snippets.

import csv
ifile = open('test.csv', "rb")
reader = csv.reader(ifile)
rownum = 0
for row in reader:
# Save header row.
if rownum == 0:
header = row
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
from apps.consumer_end.models import RestaurantMenuCategory, RestaurantMenuItem
ifile = open('/Users/salvarez/desktop/Menu_Categories_New.csv', "rU")
reader = csv.DictReader(ifile)
for row in reader:
rmc = RestaurantMenuCategory(title=row['Restaurant'], slug='sunils-place', type='0')
rmc.save()
rmi = RestaurantMenuItem(restaurant=row['Restaurant'], name=row['Item'], price=row['Price'], description=row['Description'])
from apps.consumer_end.models import Restaurant, RestaurantMenuCategory, RestaurantMenuItem
ifile = open('/Users/salvarez/desktop/Menu_Categories_New.csv', "rU")
reader = csv.DictReader(ifile)
for row in reader:
Restaurant.objects.filter(name=row['Restaurant'])
RestaurantMenuItem.objects.filter(restaurant=row['Restaurant'], name=row['Item'], price=row['Price'], category=row['Category'], description=row['Description'])
# rmc = RestaurantMenuCategory(title=row['Restaurant'])
{% block top_content %}
<br/>
<div id="order_notification" class="left rg_font">
<div class="title">Here is what your user ordered:</div>
<div class="table_headers">
<div class="header quantity_col">Quantity</div>
<div class="header desc_col">Item Description</div>
<div class="header amount_col">Amount</div>
{% block body_content %}
<div id="order_notification" class="left rg_font">
<div class="title">Here is what your user ordered:</div>
<div class="table_headers">
<div class="header username_col">User Name: Sunil Alvarez</div>
<div class="header userphone_col">User Phone: 954-663-4554</div>
<div class="header useraddress_col">User Address: 1319 nw 113th terrace, coral springs, fl, 33071</div>
<div class="header userinstruct_col">Delivery Instructions: Please call cell phone instead of knocking.</div>
</div>
import re
from django.http import HttpResponsePermanentRedirect
from django.conf import settings
class UrlRedirectMiddleware:
"""
This middleware lets you match a specific url and redirect the request to a
new url.