I am working on what, in my opinion, is a pretty standard django site, but I am having trouble getting my admin section to display the correct fields.
Here are my models.py:
class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max_length = 50)
techs = models.ManyToManyField(Tech)
In other words, a project can have different Tech objects, and different technical objects can belong to different projects (Project X was created using Python and Django, Project Y was C # and SQL Server)
However, the admin site does not display any user interface for Tech objects. Here is my admin.py:
class TechInline(admin.TabularInline):
model = Tech
extra = 5
class ProjectAdmin(admin.ModelAdmin):
fields = ['title']
inlines = []
list_display = ('title')
admin.site.register(Project, ProjectAdmin)
I tried to add the class TechInlineto the list inlines, but that calls
<class 'home.projects.models.Tech'> has no ForeignKey to <class 'home.projects.models.Project'>
Error. Also tried adding techsto the list fields, but it gives
no such table: projects_project_techs
. , projects_project_techs, projects_tech. , - syncdb?
Sqlite , .