This is how I've defined my models:
class Technology(models.Model):
title = models.CharField(max_length=10)
class Meta:
verbose_name_plural = 'Technologies'
def __str__(self):
return self.title
class Project(models.Model):
title = models.CharField(max_length=100)
description = HTMLField()
technology = models.ManyToManyField(Technology, related_name='projects')
image = models.ImageField(upload_to='projects/')
def __str__(self):
return self.title
And this is how I've defined the models in admin.py
:
class TechnologyInline(admin.StackedInline):
model = Project.technology.through
@admin.register(Technology)
class TechnologyAdmin(admin.ModelAdmin):
pass
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
inlines = [
TechnologyInline,
]
exclude = [
'technology',
]
This is exactly what I need, but it's very ugly. Is it possible to customize the strings such as "Project-technology relationship: #1" and others?