You Are What You Decide: A Journey in Automation of Our Selves. |
Here you can find some useful IPython Notebook extensions. For example, Django ORM Magic (pip install django-orm-magic
) lets you construct and query a Django database as follows:
[In] 1:
%load_ext django_orm_magic
[In] 2:
%%django_orm from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0)
[In] 3:
Poll.objects.all()
[Out] 3:
[]
[In] 4:
from django.utils import timezone p = Poll(question="What's new?", pub_date=timezone.now()) p.save()
[In] 5:
Poll.objects.all()
[Out] 5:
[<Poll: Poll object>]
Note that db.sqlite was generated.
[In] 6:
!ls
[Out] 6:
db.sqlite DjangoORM-Magic.ipynb