Closed 8cylinder closed 9 years ago
Hello @8cylinder,
Could you paste your admin.py file please? If it’s too big or if you want to keep it private, please send it by mail instead.
If you want the model.py I can send that also.
Here is the admin.py:
from django.contrib import admin
import super_inlines.admin as si
from .models import Contact, Project, Server, Database, Website
from django.db import models
import django.forms as df
textarea_css = 'height:50px; width:400px;'
class WebsiteAdmin(si.SuperInlineModelAdmin, admin.StackedInline):
model = Website
extra = 0
fieldsets = [
('General information',
{#'classes': ['collapse'],
'fields':['url', 'title', 'description', 'note']}),
('Admin',
{'classes': ['collapse'],
'fields': ['admin_url', 'admin_username', 'admin_password']}),
]
formfield_overrides = {
models.TextField: {
'widget': df.Textarea(attrs={'style': textarea_css})
}
}
class DatabaseAdmin(si.SuperInlineModelAdmin, admin.StackedInline):
model = Database
extra = 0
formfield_overrides = {
models.TextField: {
'widget': df.Textarea(attrs={'style': textarea_css})
}
}
class ServerAdmin(si.SuperInlineModelAdmin, admin.StackedInline):
model = Server
inlines = (DatabaseAdmin, WebsiteAdmin,)
extra = 0
fieldsets = [
(None,
{'fields':['title', 'description', 'type', 'note']}),
('Upload method',
{#'classes': ['collapse'],
'fields':['access_method', 'access_url', 'username',
'password']}),
('Control panel',
{#'classes': ['collapse'],
'fields':['control_panel_url', 'control_panel_username',
'control_panel_password', 'control_panel_note']}),
('SSH',
{#'classes': ['collapse'],
'fields':['ssh_url', 'ssh_username', 'ssh_password',
'ssh_note']}),
('FTP',
{#'classes': ['collapse'],
'fields':['ftp_url', 'ftp_username', 'ftp_password',
'ftp_client', 'ftp_note']}),
]
formfield_overrides = {
models.TextField: {
'widget': df.Textarea(attrs={'style': textarea_css})
}
}
class ProjectAdmin(si.SuperModelAdmin):
model = Project
inlines = (ServerAdmin,)
list_display = ('title', 'status', 'local_root')
fieldsets = [
(None,
{'fields':['title', 'status', 'note', 'local_root',
'contacts',]}),
('Git information',
{#'classes': ['collapse'],
'fields': ['git_hosting_url', 'git_url', 'git_username',
'git_password']})
]
formfield_overrides = {
models.TextField: {
'widget': df.Textarea(attrs={'style': textarea_css})
}
}
class ContactAdmin(admin.ModelAdmin):
list_display = ('name', 'email', 'phone')
formfield_overrides = {
models.TextField: {
'widget': df.Textarea(attrs={'style': textarea_css})
}
}
admin.site.register(Project, ProjectAdmin)
admin.site.register(Contact, ContactAdmin)
Admin configuration seems correct. However, I can’t reproduce it with my own models, either using Django 1.7.8, 1.8.2, with and without django-grappelli.
Can you also share your models.py? To know which relations these inlines are relying on. I have not tested with GenericForeignKey, so that may be it.
I just put the project on GitHub. Its in a pretty rough state but you can see the models there.
Heres the project: https://github.com/8cylinder/sink And here is the model: https://github.com/8cylinder/sink/blob/master/ui/models.py
Thanks for sharing the whole project! I ran it and could reproduce the bug. I’m working on it.
Fixed by c494168 and pushed to PyPI as 0.1.4!
Thanks, that's awesome!
When saving a form with a third level, and the second level model has a required field but is not filled out, an error is thrown. Validation is being done on the top level model, but not the middle one. This is the exception msg:
In this case "Server:" is the name of my second level model. If you want I can give you the entire debug output but for now here is the traceback:
Cheers!