Skip to content

Commit 3426052

Browse files
committed
Inserindo conteúdo e aprendendo funcionalidades do BD
1 parent 6da1777 commit 3426052

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

catalog/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config = 'catalog.apps.CatalogConfig'

catalog/admin.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
from django.contrib import admin
22

33
# Register your models here.
4+
5+
from .models import Category, Product
6+
7+
class CategoryAdmin(admin.ModelAdmin):
8+
9+
list_display = ['name', 'slug', 'created', 'modified']
10+
search_fields = ['name', 'slug']
11+
list_filter = ['created','modified']
12+
13+
class ProductAdmin(admin.ModelAdmin):
14+
15+
list_display = ['name', 'slug','category' ,'created', 'modified']
16+
search_fields = ['name', 'slug', 'category__name']
17+
list_filter = ['created','modified']
18+
19+
20+
21+
admin.site.register(Category, CategoryAdmin)
22+
admin.site.register(Product, ProductAdmin)

catalog/apps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
class CatalogConfig(AppConfig):
55
name = 'catalog'
6+
verbose_name = 'Catálogo'

catalog/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class Meta:
1313
verbose_name_plural = 'Categorias'
1414
ordering = ['name']
1515

16+
def __str__(self):
17+
return self.name
18+
1619
class Product(models.Model):
1720

1821
name = models.CharField('Nome', max_length=100)
@@ -29,6 +32,9 @@ class Meta:
2932
verbose_name_plural = 'Produtos'
3033
ordering = ['name']
3134

35+
def __str__(self):
36+
return self.name
37+
3238

3339

3440

db.sqlite3

0 Bytes
Binary file not shown.

db.sqlite3.sqbpro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="/home/ruyb/Documentos/Bacharelado em Sistemas de Informação/Projeto-Django/venv/src/db.sqlite3" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="2"/><attached/><window><current_tab id="1"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="2859"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="catalog_product"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="auth_group" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><display_formats/><hidden_columns/><plot_y_axes/></table><table schema="main" name="catalog_category" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><display_formats/><hidden_columns/><plot_y_axes/></table><table schema="main" name="catalog_product" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><display_formats/><hidden_columns/><plot_y_axes/></table></browse_table_settings></tab_browse><tab_sql><sql name="SQL 1"></sql><current_tab id="0"/></tab_sql></sqlb_project>

0 commit comments

Comments
 (0)