Skip to content

Instantly share code, notes, and snippets.

View niranjrajasekaran's full-sized avatar

Niranj Rajasekaran niranjrajasekaran

View GitHub Profile
@maurobaraldi
maurobaraldi / tests.py
Created May 24, 2016 17:53
Django unittest view with mock
from django.test import Client, TestCase
from mock import patch
from .views import index
class SimpleTestCase(TestCase):
def setUp(self):
self.client = Client()
@patch('api.views.requests')
@armonge
armonge / admin.py
Created January 13, 2012 04:13
Show an image in django admin list_display, using sorl-thumbnail
class ProductAdmin(admin.ModelAdmin):
list_display = ('name','thumb')
def thumb(self, obj):
return render_to_string('thumb.html',{
'image': obj.image
})
thumb.allow_tags = True