Ajout de l'objet Game en relation avec Console.
This commit is contained in:
parent
5deacda00b
commit
0e0c695e28
@ -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)
|
||||
|
24
collection/games/migrations/0002_game.py
Normal file
24
collection/games/migrations/0002_game.py
Normal 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')),
|
||||
],
|
||||
),
|
||||
]
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user