-
Notifications
You must be signed in to change notification settings - Fork 831
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
base: master
Are you sure you want to change the base?
Solution #859
Conversation
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.
Mostly correct. Thanks
|
||
class ManufacturerListView(generic.ListView): | ||
model = Manufacturer | ||
queryset = Manufacturer.objects.all().order_by("name") |
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.
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> |
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 {% 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> |
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 {% 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.
Home Page:
/manufacturers:
/cars:
/drivers:
/cars/{id}:
/drivers/{id}: