Mailgun for emails in docker

| Comments

Usually, even a small web application should send some emails: errors, registration, restore password, invitations, etc.

There are 3 solutions:

  • use an existing account, like gmail: the main problem - you don’t know how many emails you can send before being marked as spam
  • use own mail server: need to install, configure and support
  • use email service, like sendgrid, mailgun: easy to configure, provide statistics and logs, can use default http port.

For some my small projects i choosed mailgun, it provides 10000 emails in month for free, for my needs it’s more than enough and after that it’s also not expensive. For django there is a email backend django-mailgun and it takes two minutes to switch to it.

Interesting articles

| Comments

Several interesting articles I found recently. Some of them I think from Dan Bader twitter.

Django vs Flask - a detailed comparison Django vs Flask.

In most cases I preferer Django.

  • It has better documentation
  • There are better apps in core, with Flask you need to search for an app, compare alternatives and sometimes they are not updated for a long time
  • You can choose which core apps to use
  • I think it’s better developed and supported

How the heck does async/await work in Python 3.5? - a long read about async in python

Using Docker for Flask Application Development (not just Production!) - i use it the same way, the only problem I have with Python development in Docker is debugging in Intellij Idea. There is a remote interpreter, but it does not work well for me, will try it again with the latest version.

Test django view with cookies

| Comments

To test some view which use cookies:

from Cookie import SimpleCookie
from django import test

class SomeTest(test.TestCase):

    def test_some_view(self):
        self.client.cookies = SimpleCookie({'test_cookie': 'test_value'})
        response = self.client.get('/some-url/')

        self.assertEqual(response.client.cookies['test_cookie'].value, 'test_value')

Installing Django on Ubuntu memo

| Comments

Here are a few notes and links after moving to the new Ubuntu server on

Some steps for security: My First 5 Minutes On A Server

Install packages:

apt-get install apache2 libapache2-mod-wsgi
apt-get install postgresql postgresql-server-dev-9.1 python-dev
apt-get install mysql-server mysql-common mysql-client libmysqlclient-dev 
apt-get install git git-core

Setup virtualenv:

apt-get install python-setuptools
apt-get install python-pip
pip install virtualenv
virtualenv --no-site-packages /path/to/venv

Install PIL in virtualenv:

apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
ln -s /usr/lib/`uname -i`-linux-gnu/ /usr/lib/
ln -s /usr/lib/`uname -i`-linux-gnu/ /usr/lib/
ln -s /usr/lib/`uname -i`-linux-gnu/ /usr/lib/
pip install PIL

My version of django boilerplate

| Comments

django_boilerplate - it’s a template to fast start new Django project.

Based on:

Used apps:

It also includes example app with List, Create, Update, Delete views.


pip install -r requirements.txt
python syncdb

A simple CRUD app with Django and Mongoengine

| Comments

There are several possibilities to use MongoDB in Django:

Django MongoDB uses django-nonrel, which is a fork based on Django 1.3.
I don’t like this idea, because now Django 1.5 is ready to out. Beetween Mongoengine and MongoKit, I like more Mongoengine. There are several comparative articles:

So I created a simple CRUD app using Mongoengine. The model definition in Mongoengine looks like in Django.