-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1
base: main
Are you sure you want to change the base?
solution #1
Conversation
tags = models.ManyToManyField(to=Tag, related_name="tasks") | ||
|
||
class Meta: | ||
ordering = ["created_at", "is_done"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the task requirements, the ordering must be from "not done" to "done" and from newest to oldest.
class Task(models.Model): | ||
content = models.CharField(blank=True, max_length=15) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
deadline = models.DateTimeField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to requirements deadline field must be optional
@@ -0,0 +1,22 @@ | |||
from django import forms | |||
from django.core.exceptions import ValidationError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import
widget=forms.CheckboxSelectMultiple, | ||
required=False | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would be great to define 'SelectDateWidget' for deadline field
<td>{{ tag.name }}</td> | ||
<td> | ||
<button style="background: gray" class="btn"><a role="button" style="color: white" | ||
href="{% url 'todo:task_change_status' pk=tag.id %}">Update</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect url. Must be 'todo:tag-update'
|
||
{% block content %} | ||
<h1>Tags</h1> | ||
<button style="float: right; margin-right: 25px; bottom: 50px; position:relative;" class="btn btn-primary"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's recommended to have styles in a css file
</table> | ||
|
||
{% else %} | ||
<p>There are no todos</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to 'tags'
|
||
class TaskListView(generic.ListView): | ||
model = Task | ||
context_object_name = "task_list" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessary to define 'context_object_name' as the default is 'task_list'.
class TaskListView(generic.ListView): | ||
model = Task | ||
context_object_name = "task_list" | ||
template_name = "todo/task_list.html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same applies to 'template_name' as mentioned above.
|
||
class TaskDeleteView(generic.DeleteView): | ||
model = Task | ||
fields = "__all__" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The good practice is to define only those fields which you need to work with, instead of defining all of them.
No description provided.