feat: added competitor inline to team admin view

This commit is contained in:
Rushil Umaretiya 2021-02-08 11:06:49 -05:00
parent 0e0214ebae
commit 0fd8396b36
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
3 changed files with 31 additions and 2 deletions

View File

@ -15,4 +15,14 @@ admin_site.register(User)
admin_site.register(Group) admin_site.register(Group)
admin_site.register(Competitor) admin_site.register(Competitor)
admin_site.register(Team)
class CompetitorInline(admin.TabularInline):
model = Competitor
class TeamAdmin(admin.ModelAdmin):
inlines = [
CompetitorInline,
]
admin_site.register(Team, TeamAdmin)

View File

@ -0,0 +1,19 @@
# Generated by Django 3.1.6 on 2021-02-08 15:49
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('innovate', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='competitor',
name='team',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='competitors', to='innovate.team'),
),
]

View File

@ -25,7 +25,7 @@ class Competitor(models.Model):
email = models.EmailField(max_length = 254) email = models.EmailField(max_length = 254)
is_leader = models.BooleanField(default=False) is_leader = models.BooleanField(default=False)
team = models.ForeignKey(Team, on_delete=models.CASCADE) team = models.ForeignKey(Team, related_name="competitors", on_delete=models.CASCADE)
class Meta: class Meta:
verbose_name = "Competitor" verbose_name = "Competitor"