Skip to content

Commit

Permalink
perbaikan views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
fathonidf committed Sep 19, 2023
1 parent b38a895 commit 494bde1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PBP E`

## Tautan Aplikasi
[Link to Adventurer's Inventory](https://adventurers-inventory.adaptable.app/main)
(*sebelum deactivated*)

## Tugas 2
<details>
Expand All @@ -18,6 +19,8 @@ Saya membuat direktori lokal dan repo baru di Github bernama ***Adventurer's Inv
Pada proyek ***Adventurer's Inventory*** ini terdapat suatu aplikasi bernama `main` yang memiliki model, tampilan, dan URL khusus dengan rute `/main`. Inisiasi aplikasi `main` saya lakukan dengan perintah `python manage.py startapp main` hingga terbentuk direktori baru pada projek/direktori utama. Tak lupa saya daftarkan aplikasi ini ke `INSTALLED APPS` di `settings.py` seperti berikut,

```
.python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
Expand Down Expand Up @@ -156,6 +159,17 @@ Membuat aplikasi tanpa *virtual environment* tetap dapat dijalankan namun lebih
<details>
<summary>1. Apa perbedaan antara form POST dan form GET dalam Django?</summary>

* GET dan POST merupakan sebuah form HTTP Requests, yaitu sebuah jalur komunikasi antar client dan web server di World Wide Web

| GET | POST |
| --- | --- |
| Meminta untuk menerima data dari web server| Meminta untuk mengirimkan data ke web server|
| Mengembalikan kode status HTTP 200 jika data sukses diterima | Mengembalikan kode status HTTP 201 jika sukses *created*|
</details>

<details>
<summary>1. Apa perbedaan antara form POST dan form GET dalam Django?</summary>

</details>

<details>
Expand Down
16 changes: 8 additions & 8 deletions main/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ <h5>Class:</h5>
<th>Use</th>
</tr>

{% comment %} Berikut cara memperlihatkan data produk di bawah baris ini {% endcomment %}
{% comment %} Berikut cara memperlihatkan data item di bawah baris ini {% endcomment %}

{% for product in products %}
{% for item in items %}
<tr>
<td>{{product.name}}</td>
<td>{{product.amount}}</td>
<td>{{product.description}}</td>
<td>{{product.price}}</td>
<td>{{product.item_level}}</td>
<td>{{product.use}}</td>
<td>{{item.name}}</td>
<td>{{item.amount}}</td>
<td>{{item.description}}</td>
<td>{{item.price}}</td>
<td>{{item.item_level}}</td>
<td>{{item.use}}</td>
</tr>
{% endfor %}
</table>
Expand Down
2 changes: 0 additions & 2 deletions main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from main.views import show_main, create_item, show_xml, show_json, show_xml_by_id, show_json_by_id




app_name = 'main'

urlpatterns = [
Expand Down
4 changes: 2 additions & 2 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

# Create your views here.
def show_main(request):
item = Item.objects.all()
items = Item.objects.all()

context = {
'app_name': 'Adventurer\'s Inventory',
'name': 'Daffa Mohamad Fathoni',
'class': 'PBP E',
'Item': item
'items': items
}

return render(request, "main.html", context)
Expand Down

0 comments on commit 494bde1

Please sign in to comment.