Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
(cascade) % ./ syncdb
Creating tables ...
Creating table ticket_a
Creating table ticket_b
Creating table ticket_c
Installing custom SQL ...
Installing indexes ...
No fixtures found.
(cascade) % ./ shell
Python 2.7.2 (default, Jan 17 2012, 23:42:54)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ticket.models import *
>>> a = A.objects.create()
>>> b = B.objects.create(just_a=a)
>>> c = C.objects.create(maybe_b=b)
>>> a = A.objects.all()[0]
>>> a.delete()
>>> c = C.objects.all()
>>> c
from django.db import models
class A(models.Model):
class B(models.Model):
just_a = models.ForeignKey(A)
class C(models.Model):
maybe_b = models.ForeignKey(B, null=True, blank=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.