Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

solution #1

wants to merge 1 commit into from

Conversation

pavlopro
Copy link
Owner

No description provided.

tags = models.ManyToManyField(to=Tag, related_name="tasks")

class Meta:
ordering = ["created_at", "is_done"]
Copy link
Owner Author

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()
Copy link
Owner Author

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
Copy link
Owner Author

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
)

Copy link
Owner Author

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>
Copy link
Owner Author

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">
Copy link
Owner Author

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>
Copy link
Owner Author

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"
Copy link
Owner Author

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"
Copy link
Owner Author

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__"
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants