-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting Module 5: Managers and QuerySets
- Loading branch information
1 parent
4f43c35
commit 92897af
Showing
12 changed files
with
131 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Product | ||
|
||
from .models import Product, ProductImage, Category | ||
|
||
admin.site.register(Product) | ||
admin.site.register(ProductImage) | ||
admin.site.register(Category) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.0.2 on 2024-02-21 20:25 | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('store', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='product', | ||
name='description', | ||
field=models.TextField(default='', blank=True), | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
carved_rock/store/migrations/0003_product_sku_alter_product_description_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 5.0.2 on 2024-02-21 21:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('store', '0002_product_description'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='product', | ||
name='sku', | ||
field=models.CharField(default='', max_length=20, unique=True, verbose_name='Stock Keeping Unit'), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name='product', | ||
name='description', | ||
field=models.TextField(blank=True, default=''), | ||
), | ||
migrations.AlterField( | ||
model_name='product', | ||
name='stock_count', | ||
field=models.IntegerField(null=True), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
carved_rock/store/migrations/0004_alter_product_stock_count_productimage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 5.0.2 on 2024-02-22 13:53 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('store', '0003_product_sku_alter_product_description_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='product', | ||
name='stock_count', | ||
field=models.IntegerField(help_text='How many items are currently in stock', null=True), | ||
), | ||
migrations.CreateModel( | ||
name='ProductImage', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('image', models.ImageField(upload_to='')), | ||
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.product')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 5.0.2 on 2024-02-27 20:08 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('store', '0004_alter_product_stock_count_productimage'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Category', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('products', models.ManyToManyField(to='store.product')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
from django.http import HttpResponse | ||
from django.shortcuts import render | ||
|
||
from .models import Product | ||
|
||
|
||
def category_view(request, name): | ||
# products = Product.objects.filter(category__name=name) | ||
# | ||
# return render(request, "store/category.html", | ||
# {'products': products, | ||
# 'category_name': name}) | ||
return HttpResponse("Category model not defined yet - see module 4") | ||
products = Product.objects.filter(category__name=name) | ||
|
||
return render(request, "store/category.html", | ||
{'products': products, | ||
'category_name': name}) |