Django: get_FOO_display seems cool

get_FOO_display

from django.db import models

class Person(models.Model):
    SHIRT_SIZES = (
        ('S', 'Small'),
        ('M', 'Medium'),
        ('L', 'Large'),
    )
    name = models.CharField(max_length=60)
    shirt_size = models.CharField(max_length=2, choices=SHIRT_SIZES)
>>> p = Person(name="Fred Flintstone", shirt_size="L")
>>> p.save()
>>> p.shirt_size
'L'
>>> p.get_shirt_size_display()
'Large'

could not connect to server: Connection refused

psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host “127.0.0.1” and accepting
TCP/IP connections on port 57359?

Ran into this error at work. It turns out the user had deleted their known_hosts file. All that was required to fix it was to tunnel out to the ec2 instance and accept that ssh address.