更新
This commit is contained in:
11
Python-100-Days/Day41-55/shop_origin/cart/admin.py
Normal file
11
Python-100-Days/Day41-55/shop_origin/cart/admin.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from cart.models import Goods
|
||||
|
||||
|
||||
class GoodsAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('id', 'name', 'price', 'image')
|
||||
|
||||
|
||||
admin.site.register(Goods, GoodsAdmin)
|
||||
5
Python-100-Days/Day41-55/shop_origin/cart/apps.py
Normal file
5
Python-100-Days/Day41-55/shop_origin/cart/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CartConfig(AppConfig):
|
||||
name = 'cart'
|
||||
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 2.0.5 on 2018-05-25 05:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Goods',
|
||||
fields=[
|
||||
('id', models.AutoField(db_column='gid', primary_key=True, serialize=False)),
|
||||
('name', models.CharField(db_column='gname', max_length=50)),
|
||||
('price', models.DecimalField(db_column='gprice', decimal_places=2, max_digits=10)),
|
||||
('image', models.CharField(db_column='gimage', max_length=255)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'tb_goods',
|
||||
'ordering': ('id',),
|
||||
},
|
||||
),
|
||||
]
|
||||
13
Python-100-Days/Day41-55/shop_origin/cart/models.py
Normal file
13
Python-100-Days/Day41-55/shop_origin/cart/models.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Goods(models.Model):
|
||||
|
||||
id = models.AutoField(primary_key=True, db_column='gid')
|
||||
name = models.CharField(max_length=50, db_column='gname')
|
||||
price = models.DecimalField(max_digits=10, decimal_places=2, db_column='gprice')
|
||||
image = models.CharField(max_length=255, db_column='gimage')
|
||||
|
||||
class Meta:
|
||||
db_table = 'tb_goods'
|
||||
ordering = ('id',)
|
||||
3
Python-100-Days/Day41-55/shop_origin/cart/tests.py
Normal file
3
Python-100-Days/Day41-55/shop_origin/cart/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
16
Python-100-Days/Day41-55/shop_origin/cart/views.py
Normal file
16
Python-100-Days/Day41-55/shop_origin/cart/views.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
from cart.models import Goods
|
||||
|
||||
|
||||
def index(request):
|
||||
goods_list = list(Goods.objects.all())
|
||||
return render(request, 'goods.html', {'goods_list': goods_list})
|
||||
|
||||
|
||||
def show_cart(request):
|
||||
return render(request, 'cart.html')
|
||||
|
||||
|
||||
def add_to_cart(request, no):
|
||||
pass
|
||||
Reference in New Issue
Block a user