Skip to content

Instantly share code, notes, and snippets.

View anishmenon's full-sized avatar

Anish Menon anishmenon

View GitHub Profile
class Post (models.Model):
content = Txtfld ...
class Visitor(User):
post = models.ForeignKey(Post)
# views when each page loads
@login_required
def delete_videonote(request,id):
"""API: VideoNote delete"""
result = create_result()
v=VideoNote.objects.get(id=id)
form = VideoNoteDeleteApiForm(instance=v,request.POST or None)
if form.is_valid() and form.user==rquest.user:
try:
@anishmenon
anishmenon / gist:6a67654846dcaab736e8
Last active August 29, 2015 14:02
Watermark Image - PIL django python
from PIL import Image
#your views
slider = YourImageModel.objects.get(id=id)
watermark = Image.open("path to your watermark image file")
img = Image.open(slider.image.file)
@anishmenon
anishmenon / django freshdesk integration
Created September 7, 2014 18:39
Freshdesk Django integration
#settings.py
FRESHDESK_URL = 'YOUR FRESHDESK URL'
FRESHDESK_SECRET_KEY = 'YOUR Single Sign On KEY' # you can find admin->security inside freshdesk admin
#views.py
from django.http import Http404
import os
import zipfile
import StringIO
from django.http import HttpResponse
def getfiles(request):
filenames = ["/home/node4/anish/varnan/1.jpg", "/home/node4/anish/varnan/2.jpg"]
import zipfile
import glob, os
#Create a list of integers from 2 to 30, and another list from 3-50
def 2_30():
a = []
return a.append(range(2,33))
def 3_50():
a = []
<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link href="font/fonts.css" rel="stylesheet" type="text/css">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Ammras- Mobile App</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- PAGINATION SECTION START -->
{% if customers %}
<nav>
<ul class="pagination">
{% if customers.has_previous %}
<li> <a href="?{% for key, values in request.GET.iterlists %}{% ifnotequal key "page" %}{% for value in values%}{{key}}={{value}}&amp;{% endfor %}{% endifnotequal %}{% endfor %}page={{customers.previous_page_number}}" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> </a> </li>
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
paginator = Paginator(customers, 30)
page = rg('page')
try:
customers = paginator.page(page)