This file contains 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
class SingleObjectAdminModelMixin(AdminCharCountMixin): | |
list_display = ('page_name',) | |
def has_delete_permission(self, request, obj=None): | |
""" | |
Forbid object deleting | |
""" | |
return True | |
def page_name(self, obj): |
This file contains 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
class SomeModelAdmin(admin.ModelAdmin): | |
class Media: | |
js = ['path/to/script.js'] |
This file contains 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
@echo off | |
cmd /k "cd /d %~dp0\env\Scripts\ & activate & cd /d %~dp0\server\ & set "DJANGO_SETTINGS_MODULE=app.settings" & celery -A app worker -l info" |
This file contains 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
import gulp from 'gulp' | |
import * as stylus from './tasks/stylus' | |
import * as templates from './tasks/templates' | |
import * as pub from './tasks/public' | |
import * as images from './tasks/images' | |
gulp.task('images', images.dev) | |
gulp.task('public', pub.dev) | |
gulp.task('stylus', stylus.dev) |
This file contains 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.utils.functional import curry | |
class DetailsInline(admin.TabularInline): | |
model = Details | |
# formset = DetailsFormset | |
extra = 3 | |
def get_formset(self, request, obj=None, **kwargs): | |
initial = [] | |
if request.method == "GET": |
This file contains 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
class ProductVariantAdminInline(admin.TabularInline): | |
extra = 0 | |
model = ProductVariant | |
def get_parent_object_from_request(self, request): | |
""" | |
Returns the parent object from the request or None. | |
Note that this only works for Inlines, because the `parent_model` | |
is not available in the regular admin.ModelAdmin as an attribute. |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<br> | |
<h2>Thank you for your order {{ order.full_name }}</h2> | |
<h3>Your Order ID: {{ order.short_uuid }}</h3> | |
<h3>Shipping Details:</h3> |
This file contains 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
def estate_gallery_creator(images, base_estate_object): | |
""" | |
Creates BaseEstateGallery objects for BaseEstate instance | |
:param images: list of images urls | |
:param base_estate_object: BaseEstate instance id | |
:return: creates BaseEstateGallery object | |
""" | |
for index, image_url in enumerate(images, 1): | |
# Get the filename from the url, used for saving later | |
file_name = image_url.split('/')[-1] |
This file contains 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.core.validators import RegexValidator | |
class Project(models.Model): | |
color = models.CharField( | |
max_length=7, | |
default="#fff", | |
validators=[RegexValidator( | |
"(^#[0-9a-fA-F]{3}$)|(^#[0-9a-fA-F]{6}$)")], | |
verbose_name=_("color"), |
This file contains 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
$(document).ready(function(){ | |
// using jQuery | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie !== '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { | |
var cookie = jQuery.trim(cookies[i]); | |
// Does this cookie string begin with the name we want? | |
if (cookie.substring(0, name.length + 1) === (name + '=')) { |