Skip to content

Commit

Permalink
new app restaurant
Browse files Browse the repository at this point in the history
  • Loading branch information
kanu committed May 30, 2022
1 parent 16da6a7 commit 00c218b
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions django_poetry_example/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"django.contrib.staticfiles",
"django_extensions",
"pizza",
"restaurant",
]

MIDDLEWARE = [
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions django_poetry_example/restaurant/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions django_poetry_example/restaurant/apps.py
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 django_poetry_example/restaurant/migrations/0001_initial.py
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.
19 changes: 19 additions & 0 deletions django_poetry_example/restaurant/models.py
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)
3 changes: 3 additions & 0 deletions django_poetry_example/restaurant/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions django_poetry_example/restaurant/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.

0 comments on commit 00c218b

Please sign in to comment.