File tree Expand file tree Collapse file tree 6 files changed +31
-16
lines changed Expand file tree Collapse file tree 6 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 1414 "django.contrib.sessions" ,
1515 "django.contrib.messages" ,
1616 "django.contrib.staticfiles" ,
17+ # Internal apps
1718 "books" ,
1819 "coffee" ,
20+ "todos" ,
1921 "www" ,
2022 # Include django-unicorn package
2123 "django_unicorn" ,
Original file line number Diff line number Diff line change 1+ default_app_config = "todos.apps.Config"
Original file line number Diff line number Diff line change 1+ from django .apps import AppConfig
2+
3+
4+ class Config (AppConfig ):
5+ name = "example.todos"
Original file line number Diff line number Diff line change @@ -5,6 +5,3 @@ class Todo(models.Model):
55 description = models .CharField (max_length = 50 )
66 is_completed = models .BooleanField (default = False , blank = True )
77 due_date = models .DateField (null = True , blank = True )
8-
9- class Meta :
10- app_label = "todos"
Original file line number Diff line number Diff line change 44
55
66class AddTodoTestView (UnicornView ):
7- class Meta :
8- db_models = [DbModel ("todo" , Todo )]
7+ todos = Todo .objects .none ()
8+
9+ def hydrate (self ):
10+ self .todos = Todo .objects .all ()
911
1012 def save (self ):
11- print ("A new book will be created automatically" )
12- pass
13+ print ("A new todo will be created automatically" )
14+
15+ class Meta :
16+ db_models = [DbModel ("todo" , Todo )]
Original file line number Diff line number Diff line change 1- < div unicorn:db ="todo ">
1+ < div unicorn:db ="todo " unicorn:pk ="">
2+ < div >
3+ < input unicorn:field.defer ="description " type ="text " id ="description " />
4+ </ div >
5+ < div >
6+ < input unicorn:field.defer ="due_date " type ="text " id ="due_date " />
7+ </ div >
8+ < button unicorn:click ="save "> Save</ button >
9+
10+ < div >
11+ {% for todo in todos %}
212 < div >
3- < input unicorn:field.defer ="description " type ="text " id ="description " />
4- {{ todo.description }}
13+ {{ todo.id }}
514 </ div >
6- < div >
7- < input unicorn:field.defer ="due_date " type ="text " id ="due_date " />
8- {{ todo.due_date }}
9- </ div >
10- < button unicorn:click ="save "> Save</ button >
11- </ div >
15+ {% endfor %}
16+ </ div >
17+ </ div >
You can’t perform that action at this time.
0 commit comments