inlines

Making inlines conditional in the Django admin

孤街醉人 提交于 2019-12-03 05:51:42
I have a model that I want staff to be able to edit up to the date for the event. Like this: class ThingAdmin(admin.ModelAdmin): model = Thing if obj.date < today: #Something like that inlines = [MyInline,] The problem is, I don't have access to the obj instance at this level. I've tried overriding get_formset(), but didn't get anywhere. Please advise? Thanks to the comments for a change in 1.4. My implementation here wasn't thread safe either, so it really should have been deleted. Since get_formsets is passed the object and calls get_inline_instances , we can modify both functions to act on

Django admin different inlines for change and add view

删除回忆录丶 提交于 2019-11-28 17:39:27
I need separate views for add and change page. In add page I'd like to exclude some fields from inline formset. I've prepared two TabularInline classes, one of them contains property 'exclude'. I tried to use them as follows: class BoxAdmin(admin.ModelAdmin): def change_view(self, request, obj_id): self.inlines=[ItemChangeInline,] return super(BoxAdmin, self).change_view(self.request, obj_id) def add_view(self, request): self.inlines=[ItemAddInline,] return super(BoxAdmin, self).add_view(self, request) with no effect (no inline is shown at all). It works with Django 1.5+ and seems fine &

Django admin - inline inlines (or, three model editing at once)

泄露秘密 提交于 2019-11-27 02:44:22
I've got a set of models that look like this: class Page(models.Model): title = models.CharField(max_length=255) class LinkSection(models.Model): page = models.ForeignKey(Page) title = models.CharField(max_length=255) class Link(models.Model): linksection = models.ForeignKey(LinkSection) text = models.CharField(max_length=255) url = models.URLField() and an admin.py that looks like this: class LinkInline(admin.TabularInline): model = Link class LinkSectionInline(admin.TabularInline): model = LinkSection inlines = [ LinkInline, ] class PageAdmin(admin.ModelAdmin): inlines = [ LinkSectionInline,

Data binding the TextBlock.Inlines

拈花ヽ惹草 提交于 2019-11-26 17:53:59
My WPF App receives a stream of messages from a backend service that I need to display in the UI. These messages vary widely and I want to have different visual layout (string formats, colors, Fonts, icons, whatever etc.) for each message. I was hoping to just be able to create an inline (Run, TextBlock, Italic etc) for each message then somehow put them all in a ObservableCollection<> and using he magic of WPF Data Binding on my TextBlock.Inlines in the UI. I couldn't find how to do this, is this possible? itowlson This is not possible because the TextBlock.Inlines property is not a

Django admin - inline inlines (or, three model editing at once)

五迷三道 提交于 2019-11-26 10:09:05
问题 I\'ve got a set of models that look like this: class Page(models.Model): title = models.CharField(max_length=255) class LinkSection(models.Model): page = models.ForeignKey(Page) title = models.CharField(max_length=255) class Link(models.Model): linksection = models.ForeignKey(LinkSection) text = models.CharField(max_length=255) url = models.URLField() and an admin.py that looks like this: class LinkInline(admin.TabularInline): model = Link class LinkSectionInline(admin.TabularInline): model =

Data binding the TextBlock.Inlines

两盒软妹~` 提交于 2019-11-26 06:02:59
问题 My WPF App receives a stream of messages from a backend service that I need to display in the UI. These messages vary widely and I want to have different visual layout (string formats, colors, Fonts, icons, whatever etc.) for each message. I was hoping to just be able to create an inline (Run, TextBlock, Italic etc) for each message then somehow put them all in a ObservableCollection<> and using he magic of WPF Data Binding on my TextBlock.Inlines in the UI. I couldn\'t find how to do this,