-
Notifications
You must be signed in to change notification settings - Fork 0
Jdom/josepost #2
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?
Conversation
TysonRV
left a comment
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 is pretty good, made some comments but it can be merged in
| # python manage.py migrate No newline at end of file | ||
| # python manage.py migrate | ||
|
|
||
| #DOUBT: tests.py -> 'href="{0}"'.format(homepage_url) what does "{0}" mean? No newline at end of file |
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.
{0} is the placeholder for the first variable (hence 0, for variable 0) that goes in the format function. In that case, you only have one variable: homepage_url.
If homepage_url="https://pipetilla.com" then the result would be:
'href="https://pipetilla.com"'
That sintax is also equivalent to:
'href="{}"'.format(homepage_url)
or
'href="{homepage_url}"'.format({'homepage_url': homepage_url})
From Python 3.6 onwards, you can use also f-strings:
f'href="{homepage_url}"'
There is more interesting info here:
https://realpython.com/python-f-strings/
| </ol> | ||
| <table border="1"> | ||
| <thead> | ||
| <table class="table"> |
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.
Element table with class table... That's either redundant or not very descriptive, as you want classes for specific things like: boardsTable or pipetasTableBlue and then apply css to them. I know you were following the tutorial, but I thought it was worth it mentioning it.
In CSS, you can apply the style to the element, in this case table:
table {
border=1;
}
or the class, in this case..... table again.....(you see why it is confusing?):
.table {
border=1;
}
First one applies to all elements table, second one applies to all elements with class="table". 😄
| urlpatterns = [ | ||
| url(r'^homepage/$',views.home,name='home'), | ||
| url(r'^homepage/$', views.home, name='home'), | ||
| url(r'^boards/(?P<pk>\d+)/$', views.board_topics, name='board_topics'), |
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 actually comes from an old django version, <3.0 for sure. The syntax changes a bit to path instead of url
| from .models import Board | ||
|
|
||
| admin.site.register(Board) | ||
|
|
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.
Maybe, you haven't reach that yet, but you can also configure your own admin classes. I.e.:
class BoardAdmin(admin.AdminModel):
list_display = [.....] -> display them in the list view, on the admin
list_editable = [.....] -> for the ones displayed, the ones on this list will be editable from the list view
list_filter = [.....] -> creates a filter on the side panel with occurrences. Useful for booleans and choice fields
search_fields = [....] -> creates a search bar and you will be able to search for the fields on this list. I.e put `name` and look for a name you know, it will filter results based on that
......
admin.site.register(Board, BoardAdmin)
This is actually very easy to use and extremely useful. Try including Board attributes on the list_display, etc.
Like:
list_display = ["name", "description]
etc
You can also build admins for the rest of the models! Don't forget to register them! 😄
Third module of the tutorial