Ershadul Hoque

Django, Zend, MongoDB and Scale

Django apps that I've been using for any django project

I've been using Django for 3+ years. But I learnt django-cms app few months ago. I found very well designed as it follows also django conventions and best practices. Here is my list:

 

1. cms

2. south

3. haystack

4. mptt

5. filebrowser

6. tinymce

7. cms_search

8. sorl.thumbnail

9. menus

....

+ project's own apps

 

Right way to check authenticated user in Django

I’m assuming that you’ve added these two middlewares in your settings.py as follows:

 MIDDLEWARE_CLASSES = ( 

... 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) 

Then you’ll be able to user object using request object like this: user = request.user

If you want to check whether the user is authenticated or not, then the wrong way to do this:

 # Do not use

 if request.user:

This will be true for both authenticated and anonymous user

Because request.user is not None or empty.

You can check this following any one of the two ways:

 if request.user.id:

// recommended

 if request.user.is_authenticated():

How to install Mongo.so in Mac OSX Snow Leopard

Follow the following steps to install PHP MongoDB driver on Mac OSX Snow Leopard

1. Go to /usr/local directory: 

cd /usr/local

2. Download the following file:

curl http://pear.php.net/go-pear.phar

3. Install pear:

sudo php go-pear.phar

4. Install mongo driver: 

sudo pecl install mongo

5. Copy php.ini: 

sudo /etc/php.ini.default /etc/php.ini

6. Open your php.ini file and add to it:

extension=mongo.so