-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Solution #1338
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
base: master
Are you sure you want to change the base?
Solution #1338
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from django.urls import path | ||
|
|
||
| from .views import index | ||
|
|
||
| urlpatterns = [ | ||
| path("", index, name="index") | ||
| ] | ||
|
|
||
| app_name = "taxi" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,15 @@ | ||
| from django.shortcuts import render | ||
| from django.http import HttpResponse, HttpRequest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This violates the checklist requirement to group and separate imports: "Add a blank line between different groups of imports and ensure appropriate ordering of imports." Ensure imports are ordered (standard library, third-party, local) and put a blank line between the third-party (django) imports and local |
||
|
|
||
| # Create your views here. | ||
| from .models import Car, Driver, Manufacturer | ||
|
||
|
|
||
|
|
||
| def index(requests: HttpRequest) -> HttpResponse: | ||
| num_drivers = Driver.objects.count() | ||
| num_manufacturers = Manufacturer.objects.count() | ||
| num_cars = Car.objects.count() | ||
|
|
||
| return render(requests, "taxi/index.html", | ||
| {"num_drivers": num_drivers, | ||
| "num_manufacturers": num_manufacturers, | ||
| "num_cars": num_cars}) | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ | |
| TEMPLATES = [ | ||
| { | ||
| "BACKEND": "django.template.backends.django.DjangoTemplates", | ||
| "DIRS": [], | ||
| "DIRS": ["templates"], | ||
|
||
| "APP_DIRS": True, | ||
| "OPTIONS": { | ||
| "context_processors": [ | ||
|
|
@@ -123,6 +123,9 @@ | |
| # https://docs.djangoproject.com/en/4.0/howto/static-files/ | ||
|
|
||
| STATIC_URL = "static/" | ||
| STATICFILES_DIRS = [ | ||
| BASE_DIR / "static", | ||
|
||
| ] | ||
|
||
|
|
||
| # Default primary key field type | ||
| # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,9 @@ | |
| 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
| """ | ||
| from django.contrib import admin | ||
| from django.urls import path | ||
| from django.urls import path, include | ||
|
|
||
| urlpatterns = [ | ||
| path("admin/", admin.site.urls), | ||
| path("", include("taxi.urls", namespace="taxi"), name="") | ||
|
||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
|
|
||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| {% load static %} | ||
| <link rel="stylesheet" href="{% static 'css/styles.css' %}"> | ||
| <title>{% block title %}{%endblock%}</title> | ||
|
||
| <meta> | ||
| </head> | ||
| <body> | ||
|
|
||
| <div id="sidebar"> | ||
| {% block sidebar %} | ||
| {% include 'includes/sidebar.html' %} | ||
| {% endblock %} | ||
| </div> | ||
|
|
||
| <div id="content"> | ||
| {% block content %} | ||
| {% endblock %} | ||
| </div> | ||
| </body> | ||
| </html> | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <ul> | ||
| <li><a href="{% url 'taxi:index' %}">Home Page</a></li> | ||
| <li><a href="#">Manufacturers</a></li> | ||
| <li><a href="#">Cars</a></li> | ||
| <li><a href="#">Drivers</a></li> | ||
| </ul> | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| {% extends 'base.html' %} | ||
|
|
||
| {% block title %}Home page{% endblock %} | ||
|
|
||
| {% block content %} | ||
| <ul> | ||
| <li>{{num_cars}}</li> | ||
| <li>{{num_drivers}}</li> | ||
| <li>{{num_manufacturers}}</li> | ||
| </ul> | ||
| {% endblock %} | ||
|
||
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.
This violates CHECKLIST ITEM #3: "Use absolute imports instead of relative imports"
You are using a relative import here (
from .views import index). Change it to an absolute import, for example:Using absolute imports is required by the checklist and prevents potential import-resolution issues.