Ajout de l'objet Game en relation avec Console.

This commit is contained in:
Olivier DOSSMANN 2017-08-16 22:07:40 +02:00
parent 5deacda00b
commit 0e0c695e28
3 changed files with 37 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from django.contrib import admin
from games.models import Console
from games.models import Console, Game
admin.site.register(Console)
admin.site.register(Game)

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-08-16 20:05
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('games', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Game',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=254)),
('console', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='games.Console')),
],
),
]

View File

@ -9,3 +9,14 @@ class Console(models.Model):
def __str__(self):
return '%s' % self.name
class Game(models.Model):
"""
A video game you will use on a specific Console.
"""
name = models.CharField(max_length=254)
console = models.ForeignKey('games.Console')
def __str__(self):
return '%s' % self.name