This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
import os | |
from celery import Celery | |
from django.conf import settings | |
from robot.config import ROBOT_CELERY_BEAT_SCHEDULE | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test.settings') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from example.models import Example | |
class ExampleAdmin(admin.ModelAdmin): | |
""" | |
Don't allow addition of more than one model instance in Django admin | |
See: http://stackoverflow.com/a/12469482 | |
""" | |
def has_add_permission(self, request): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install celery | |
heroku addons:add cloudamqp | |
heroku config | grep CLOUDAMQP_URL | |
^^ that is the URL to put in celeryconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Only useful in changelist pages when the ModelAdmin displayed has | |
* "list_editable" (https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable) | |
* configured. | |
* | |
* When one of the input/select/textarea value is changed, automatically submit | |
* the form using ajax. | |
* | |
* Only form fields relevant to the "list_editable" will trigger a form submit. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Useage '''' | |
# Declare our item | |
store = Store.objects.get(pk=pk) | |
# Define our models | |
stores = Store.objects.all() | |
# Ask for the next item | |
new_store = get_next_or_prev(stores, store, 'next') | |
# If there is a next item | |
if new_store: | |
# Replace our item with the next one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myConfObj = { | |
iframeMouseOver : false | |
} | |
window.addEventListener('blur',function(){ | |
if(myConfObj.iframeMouseOver){ | |
console.log('Wow! Iframe Click!'); | |
} | |
}); | |
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#views.py | |
def events_index(request, year): | |
selected_year = Year.objects.get(title=year) | |
events_list = Event.objects.filter(year = selected_year.id).order_by('category','start_date') | |
return render_to_response('events_list.html', {"events_list": events_list}) | |
#events_list.html | |
{% regroup events_list by category.title as events_list_by_category %} |