Showing posts with label admin. Show all posts
Showing posts with label admin. Show all posts

Wednesday, February 27, 2013

Django admin staff authentication on your webapp views


Lets say you have certain views you want to control the access and should be only accessible by staff members.

Its two lines of code change and you are done. 

from django.contrib.admin.views.decorators import staff_member_required

in your module’s views.py

@staff_member_required
def staffdashboard(request):
            ….
            ….
            return render_to_response(‘dashboard.html',context_instance=RequestContext(request))

When user tries to access the view, it will check if user is authorized staff member. If not it will prompt for admin login screen.

Sunday, July 15, 2012

Django Application Image issues while running on mac

If you are using django and getting jpg adapter error on image upload or while running the app on rendering the jpeg image, in that case follow below instructions. The error is most likely because of installation of jpeg in environment.


You have to install support for JPEG, for example in mac use homebrew for installation and follow below instructions - 

1. Uninstall PIL
    sudo pip uninstall PIL

2. Install JPEG
    brew install jpeg

3. Install PIL again
    sudo pip install PIL

for ubuntu users use below command -
sudo apt-get install libjpeg62-dev