-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
100 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
"django.contrib.staticfiles", | ||
"django_extensions", | ||
"pizza", | ||
"restaurant", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class RestaurantConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "restaurant" |
65 changes: 65 additions & 0 deletions
65
django_poetry_example/restaurant/migrations/0001_initial.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,65 @@ | ||
# Generated by Django 4.0.4 on 2022-05-30 13:42 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("pizza", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="MenuEntry", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("price", models.IntegerField()), | ||
( | ||
"pizza", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="pizza.pizza" | ||
), | ||
), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="Restaurant", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("name", models.CharField(max_length=32)), | ||
( | ||
"pizzas", | ||
models.ManyToManyField( | ||
through="restaurant.MenuEntry", to="pizza.pizza" | ||
), | ||
), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="menuentry", | ||
name="restaurant", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="restaurant.restaurant" | ||
), | ||
), | ||
] |
Empty file.
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,19 @@ | ||
from django.db import models | ||
|
||
from pizza.models import Pizza | ||
|
||
|
||
class Restaurant(models.Model): | ||
|
||
name = models.CharField(max_length=32) | ||
|
||
pizzas = models.ManyToManyField(Pizza, through="MenuEntry") | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
class MenuEntry(models.Model): | ||
restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE) | ||
pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE) | ||
price = models.IntegerField(null=False) |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |