Skip to content
Browse files

Task.parent

  • Loading branch information...
1 parent 943e397 commit c87168d80d02f32ea359c53206f11593d45c16b3 @mvasilkov committed
Showing with 3 additions and 1 deletion.
  1. +1 −0 pytodo/main/forms.py
  2. +1 −0 pytodo/main/models.py
  3. +1 −1 pytodo/main/views.py
View
1 pytodo/main/forms.py
@@ -5,3 +5,4 @@
class TaskForm(ModelForm):
class Meta:
model = Task
+ fields = ['name', 'text', 'parent']
View
1 pytodo/main/models.py
@@ -4,6 +4,7 @@
class Task(models.Model):
name = models.CharField(max_length=200)
text = models.TextField()
+ parent = models.ForeignKey('self', related_name='subtasks', null=True, blank=True)
date_added = models.DateTimeField(auto_now_add=True)
is_done = models.BooleanField()
View
2 pytodo/main/views.py
@@ -4,7 +4,7 @@
def home(request):
- return render(request, 'home.html', {'task_list': Task.objects.all()})
+ return render(request, 'home.html', {'task_list': Task.objects.filter(parent=None)})
def new_task(request):

0 comments on commit c87168d

Please sign in to comment.
Something went wrong with that request. Please try again.