Skip to content

Conversation

@jdom32
Copy link
Owner

@jdom32 jdom32 commented May 8, 2020

Third module of the tutorial

@jdom32 jdom32 requested a review from TysonRV May 8, 2020 15:26
Copy link
Collaborator

@TysonRV TysonRV left a 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
Copy link
Collaborator

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">
Copy link
Collaborator

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'),
Copy link
Collaborator

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)

Copy link
Collaborator

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! 😄

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.

3 participants