from django.db import models
class Project(models.Model):
name = models.CharField(max_length=140)
parent = models.ForeignKey('self', blank=True, null=True)
class ProjectForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProjectForm, self).__init__(*args, **kwargs)
ordered = []
// ... making ordered list ...
self.fields['parent'].choices = ordered
self.fields['parent'].choices.insert(0, ('', u'------'))
# You can import blanc field from:
# from django.db.models.fields import BLANK_CHOICE_DASH