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 #859

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #859

wants to merge 2 commits into from

Conversation

vladyslav-tmf
Copy link

@vladyslav-tmf vladyslav-tmf commented Oct 31, 2024

Home Page:

Screenshot_1

/manufacturers:

Screenshot_3

/cars:

Screenshot_4

/drivers:

Screenshot_5

/cars/{id}:

Screenshot_5

/drivers/{id}:

Screenshot_6

Copy link

@Arsen-hrynevych Arsen-hrynevych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly correct. Thanks


class ManufacturerListView(generic.ListView):
model = Manufacturer
queryset = Manufacturer.objects.all().order_by("name")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you use order_by, it by default returns all objects that satisfy the rule. Therefore, you don't need to explicitly use objects.all().

</tr>
{% for car in car_list %}
<tr>
<th><a href="{% url 'taxi:car-detail' car.id %}">{{ car.id }}</a></th>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {% url %} template tag generates URLs dynamically using the URL name defined in your urls.py file. The parameters you pass must match the named parameters expected by the URL pattern.


Example:

<a href="{% url 'taxi:car-update' car.id %}" class="btn btn-primary btn-sm">Update</a>

Since your URL pattern uses int:pk, you should use pk= in the template tag:

<a href="{% url 'taxi:car-update' pk=car.id %}" class="btn btn-primary btn-sm">Update</a>

Ensure that the href in your template matches the URL pattern, or update the URL pattern to match the parameters used in your template.

</tr>
{% for driver in driver_list %}
<tr>
<th><a href="{% url 'taxi:driver-detail' driver.id %}">{{ driver.username }}</a></th>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {% url %} template tag generates URLs dynamically using the URL name defined in your urls.py file. The parameters you pass must match the named parameters expected by the URL pattern.


Example:

<a href="{% url 'taxi:car-update' car.id %}" class="btn btn-primary btn-sm">Update</a>

Since your URL pattern uses int:pk, you should use pk= in the template tag:

<a href="{% url 'taxi:car-update' pk=car.id %}" class="btn btn-primary btn-sm">Update</a>

Ensure that the href in your template matches the URL pattern, or update the URL pattern to match the parameters used in your template.

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