Contenido del Curso
Django: Build Your First Website
Django: Build Your First Website
Dynamic URL
Description
.get(pk=note_id)
: This get method is used to retrieve a single object from the database that matches certain criteria. In this case, the criteria is the identifier of the record (pk=note_id
), which is passed as the note_id
parameter.
note = ...
: The result of the call to Note.objects.get(pk=note_id)
is assigned to the variable note. Therefore, the variable note now contains an object of type Note
from the database that corresponds to the identifier passed in note_id
.
path('note/<int:note_id>/', ...)
: This part defines a URL pattern using the path
function. It indicates that the URL should start with 'note/' followed by an integer (<int:note_id>
). The angle brackets < >
are used to capture the value and pass it as a parameter to the associated view function (note_detail
).
index
index
index
value="{{ note.title }}"
: The value
attribute is set using jinja syntax within double curly braces. This means that the value of the title
attribute of the note
object will be inserted into this input field.
<textarea>
: This is an HTML tag that defines a multiline text input control, often used for larger amounts of text, such as comments or descriptions.
{{ note.content }}
: The content of the textarea
is set using jinja syntax within double curly braces. This means that the value of the content
attribute of the note
object will be inserted into the textarea.
¡Gracias por tus comentarios!