Skip to content

Instantly share code, notes, and snippets.

<img id="teal" src="{% static 'img/teal_circle.png' %}" alt="teal circle">
@kshepp
kshepp / Simplified_base.html
Last active February 19, 2016 14:55
This is a simplified version of a base.html file in Django
{% load staticfiles %}
<!--Load static files will bring in all the css, images, and js files-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--This is where you can input all the css files. The files are in Django format and following the path from the 'static' file -->
<link href="{% static 'bootstrap/css/bootstrap-theme.css' %}"
@kshepp
kshepp / leaflet.html
Last active January 18, 2016 18:48
Example of Leaflet map
{% load staticfiles %}
{% block content %}
<div class="spacer2"></div>
<div class="container_special">
<div class="jumbotron specialjum">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" media="screen, print" rel="stylesheet">
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<body>
<!--This is the open street map that's being used from Leaflet-->
@kshepp
kshepp / exhibit_gallery.html
Last active January 18, 2016 18:41
This is code to implement an exhibit gallery
@kshepp
kshepp / cafes_all.html
Last active January 18, 2016 18:25
cafes_all.html
<!--Use the 'if' statement to call the class in the model you'd like to display-->
{% if cafes %}
<!--Use the 'for' statement to iterate through the model-->
{% for cafe in cafes %}
<div class = "col-xs-12">
<!--This line of code creates multiple rows.-->
<div class="{% cycle 'row1' 'row2' %}">
<div class="item">
<div align="center">
<img class="cafe_thumbnail" src="/media/{{cafe.file_up}}"/>
@kshepp
kshepp / admin.py
Last active January 18, 2016 18:17
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django.contrib.admin import AdminSite
from .models import Map, City, Cafe, Person, Item, CafeExhibit
admin.site.register(Map)
admin.site.register(City)
admin.site.register(Cafe, CafeAdmin)
@kshepp
kshepp / cafe.model
Last active January 18, 2016 18:15
class Cafe(models.Model):
cafe = models.TextField()
<!--Below is where the image upload is located in the model-->
file_up = models.FileField(blank=True)
url = AutoSlugField(populate_from='cafe', editable=True,unique=True, blank=True)
cityName = models.ForeignKey(City)
established = models.CharField(max_length=10, blank=True)
latitude = models.DecimalField(max_digits= 7, decimal_places=4)
@kshepp
kshepp / cycle_through_code
Created December 11, 2015 15:17
This code is to cycle through model information
<div class="{% cycle 'row1' 'row2' %}">
#Put the code you want to iterate through here
</div>
<div align="center">
<img class="cafe_thumbnail" src="/media/{{cafe.file_up}}"/>
</div>
def cafe(request, location):
city = City.objects.get(cafe__url=location)
exhibits = CafeExhibit.objects.filter(cafeName__url=location)
cafe = Cafe.objects.get(url=location)
Context = {'exhibits':exhibits,'cafe':cafe, 'city':city}
return render(request,'jewish_cafes/cafe.html', Context)