Flatpages with multiple blocks/sections

2008-08-20 Thread lingrlongr

I have found that the Flatpages application is very useful, especially
in projects where you create a site for someone else and you allow
them to change the content as they need.  The only drawback with the
application, however, is that there's only one block/section of
modifiable content.

My solution was to pretty much copy the django.contrib.flatpages
application into my project and adjust it to conform to my
specifications.  As one would guess, that's not very clean, as I'd
want my copy to change as Django's changed, but I saw no other way as
I could not easily extend what was already there.

For my use, I'll just touch on the basic changes I made.  I left out
any "logical" imports below.  Also note that changed
"django.contrib.flatpages" to "flatpages" where necessary so my
changes did not refer to the original.

# myproject.flatpages.models.py
class Section(models.Model):
slug = models.SlugField(_('slug'), max_length=50)
content = models.TextField(_('content'), blank=True)
flatpage = models.ForeignKey(FlatPage)


# myproject.flatpages.admin.py

class SectionInline(admin.StackedInline):
model = Section

class SectionAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('slug', 'content', 'flatpage')}),
)
list_display = ('slug', 'flatpage',)
list_filter = ('flatpage',)
search_fields = ('slug', 'content')

admin.site.register(Section, SectionAdmin)

(also add inlines = [SectionInline,] to FlatPageAdmin class)


# views.py - before creating Request Context

# Create a dictionary, indexed by section slug, of section content
d = {}
for s in f.section_set.all():
d[s.slug] = mark_safe(s.content)

...etc...

c = RequestContext(request, {
'flatpage': f,
'section': d,
})

So of course, in my templates I could just render a block/section of
content as {{ section.section_1 }}.


Do we think something like this could be useful for the general
population, either as part of flatpages or as a separate app?

Keith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages with multiple blocks/sections

2008-08-20 Thread Justin Lilly

You may want to check out django-chunks. I'm pretty sure it does what  
you are looking for.

  -justin



On Aug 20, 2008, at 4:41 PM, lingrlongr <[EMAIL PROTECTED]> wrote:

>
> I have found that the Flatpages application is very useful, especially
> in projects where you create a site for someone else and you allow
> them to change the content as they need.  The only drawback with the
> application, however, is that there's only one block/section of
> modifiable content.
>
> My solution was to pretty much copy the django.contrib.flatpages
> application into my project and adjust it to conform to my
> specifications.  As one would guess, that's not very clean, as I'd
> want my copy to change as Django's changed, but I saw no other way as
> I could not easily extend what was already there.
>
> For my use, I'll just touch on the basic changes I made.  I left out
> any "logical" imports below.  Also note that changed
> "django.contrib.flatpages" to "flatpages" where necessary so my
> changes did not refer to the original.
>
> # myproject.flatpages.models.py
> class Section(models.Model):
>slug = models.SlugField(_('slug'), max_length=50)
>content = models.TextField(_('content'), blank=True)
>flatpage = models.ForeignKey(FlatPage)
>
>
> # myproject.flatpages.admin.py
>
> class SectionInline(admin.StackedInline):
>model = Section
>
> class SectionAdmin(admin.ModelAdmin):
>fieldsets = (
>(None, {'fields': ('slug', 'content', 'flatpage')}),
>)
>list_display = ('slug', 'flatpage',)
>list_filter = ('flatpage',)
>search_fields = ('slug', 'content')
>
> admin.site.register(Section, SectionAdmin)
>
> (also add inlines = [SectionInline,] to FlatPageAdmin class)
>
>
> # views.py - before creating Request Context
>
># Create a dictionary, indexed by section slug, of section content
>d = {}
>for s in f.section_set.all():
>d[s.slug] = mark_safe(s.content)
>
>...etc...
>
>c = RequestContext(request, {
>'flatpage': f,
>'section': d,
>})
>
> So of course, in my templates I could just render a block/section of
> content as {{ section.section_1 }}.
>
>
> Do we think something like this could be useful for the general
> population, either as part of flatpages or as a separate app?
>
> Keith
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages with multiple blocks/sections

2008-08-20 Thread lingrlongr

I think that will work well.  Thanks! =)

On Aug 20, 10:40 pm, Justin Lilly <[EMAIL PROTECTED]> wrote:
> You may want to check out django-chunks. I'm pretty sure it does what  
> you are looking for.
>
>   -justin
>
> On Aug 20, 2008, at 4:41 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have found that the Flatpages application is very useful, especially
> > in projects where you create a site for someone else and you allow
> > them to change the content as they need.  The only drawback with the
> > application, however, is that there's only one block/section of
> > modifiable content.
>
> > My solution was to pretty much copy the django.contrib.flatpages
> > application into my project and adjust it to conform to my
> > specifications.  As one would guess, that's not very clean, as I'd
> > want my copy to change as Django's changed, but I saw no other way as
> > I could not easily extend what was already there.
>
> > For my use, I'll just touch on the basic changes I made.  I left out
> > any "logical" imports below.  Also note that changed
> > "django.contrib.flatpages" to "flatpages" where necessary so my
> > changes did not refer to the original.
>
> > # myproject.flatpages.models.py
> > class Section(models.Model):
> >    slug = models.SlugField(_('slug'), max_length=50)
> >    content = models.TextField(_('content'), blank=True)
> >    flatpage = models.ForeignKey(FlatPage)
>
> > # myproject.flatpages.admin.py
>
> > class SectionInline(admin.StackedInline):
> >    model = Section
>
> > class SectionAdmin(admin.ModelAdmin):
> >    fieldsets = (
> >        (None, {'fields': ('slug', 'content', 'flatpage')}),
> >    )
> >    list_display = ('slug', 'flatpage',)
> >    list_filter = ('flatpage',)
> >    search_fields = ('slug', 'content')
>
> > admin.site.register(Section, SectionAdmin)
>
> > (also add inlines = [SectionInline,] to FlatPageAdmin class)
>
> > # views.py - before creating Request Context
>
> >    # Create a dictionary, indexed by section slug, of section content
> >    d = {}
> >    for s in f.section_set.all():
> >        d[s.slug] = mark_safe(s.content)
>
> >    ...etc...
>
> >    c = RequestContext(request, {
> >        'flatpage': f,
> >        'section': d,
> >    })
>
> > So of course, in my templates I could just render a block/section of
> > content as {{ section.section_1 }}.
>
> > Do we think something like this could be useful for the general
> > population, either as part of flatpages or as a separate app?
>
> > Keith
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages with multiple blocks/sections

2008-08-20 Thread Jeremy Dunck

Also django-assets



On Aug 20, 2008, at 21:57, lingrlongr <[EMAIL PROTECTED]> wrote:

>
> I think that will work well.  Thanks! =)
>
> On Aug 20, 10:40 pm, Justin Lilly <[EMAIL PROTECTED]> wrote:
>> You may want to check out django-chunks. I'm pretty sure it does what
>> you are looking for.
>>
>>   -justin
>>
>> On Aug 20, 2008, at 4:41 PM, lingrlongr <[EMAIL PROTECTED]>  
>> wrote:
>>
>>
>>
>>> I have found that the Flatpages application is very useful,  
>>> especially
>>> in projects where you create a site for someone else and you allow
>>> them to change the content as they need.  The only drawback with the
>>> application, however, is that there's only one block/section of
>>> modifiable content.
>>
>>> My solution was to pretty much copy the django.contrib.flatpages
>>> application into my project and adjust it to conform to my
>>> specifications.  As one would guess, that's not very clean, as I'd
>>> want my copy to change as Django's changed, but I saw no other way  
>>> as
>>> I could not easily extend what was already there.
>>
>>> For my use, I'll just touch on the basic changes I made.  I left out
>>> any "logical" imports below.  Also note that changed
>>> "django.contrib.flatpages" to "flatpages" where necessary so my
>>> changes did not refer to the original.
>>
>>> # myproject.flatpages.models.py
>>> class Section(models.Model):
>>>slug = models.SlugField(_('slug'), max_length=50)
>>>content = models.TextField(_('content'), blank=True)
>>>flatpage = models.ForeignKey(FlatPage)
>>
>>> # myproject.flatpages.admin.py
>>
>>> class SectionInline(admin.StackedInline):
>>>model = Section
>>
>>> class SectionAdmin(admin.ModelAdmin):
>>>fieldsets = (
>>>(None, {'fields': ('slug', 'content', 'flatpage')}),
>>>)
>>>list_display = ('slug', 'flatpage',)
>>>list_filter = ('flatpage',)
>>>search_fields = ('slug', 'content')
>>
>>> admin.site.register(Section, SectionAdmin)
>>
>>> (also add inlines = [SectionInline,] to FlatPageAdmin class)
>>
>>> # views.py - before creating Request Context
>>
>>># Create a dictionary, indexed by section slug, of section  
>>> content
>>>d = {}
>>>for s in f.section_set.all():
>>>d[s.slug] = mark_safe(s.content)
>>
>>>...etc...
>>
>>>c = RequestContext(request, {
>>>'flatpage': f,
>>>'section': d,
>>>})
>>
>>> So of course, in my templates I could just render a block/section of
>>> content as {{ section.section_1 }}.
>>
>>> Do we think something like this could be useful for the general
>>> population, either as part of flatpages or as a separate app?
>>
>>> Keith
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages with multiple blocks/sections

2008-08-20 Thread lingrlongr

However, it'd still be nice to see these chunks be somehow related to
a flatpage.  Maybe one day the we'll have a "chunky-flatpages" app so
they can share some sort of relation...

On Aug 20, 10:57 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I think that will work well.  Thanks! =)
>
> On Aug 20, 10:40 pm, Justin Lilly <[EMAIL PROTECTED]> wrote:
>
> > You may want to check out django-chunks. I'm pretty sure it does what  
> > you are looking for.
>
> >   -justin
>
> > On Aug 20, 2008, at 4:41 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > I have found that the Flatpages application is very useful, especially
> > > in projects where you create a site for someone else and you allow
> > > them to change the content as they need.  The only drawback with the
> > > application, however, is that there's only one block/section of
> > > modifiable content.
>
> > > My solution was to pretty much copy the django.contrib.flatpages
> > > application into my project and adjust it to conform to my
> > > specifications.  As one would guess, that's not very clean, as I'd
> > > want my copy to change as Django's changed, but I saw no other way as
> > > I could not easily extend what was already there.
>
> > > For my use, I'll just touch on the basic changes I made.  I left out
> > > any "logical" imports below.  Also note that changed
> > > "django.contrib.flatpages" to "flatpages" where necessary so my
> > > changes did not refer to the original.
>
> > > # myproject.flatpages.models.py
> > > class Section(models.Model):
> > >    slug = models.SlugField(_('slug'), max_length=50)
> > >    content = models.TextField(_('content'), blank=True)
> > >    flatpage = models.ForeignKey(FlatPage)
>
> > > # myproject.flatpages.admin.py
>
> > > class SectionInline(admin.StackedInline):
> > >    model = Section
>
> > > class SectionAdmin(admin.ModelAdmin):
> > >    fieldsets = (
> > >        (None, {'fields': ('slug', 'content', 'flatpage')}),
> > >    )
> > >    list_display = ('slug', 'flatpage',)
> > >    list_filter = ('flatpage',)
> > >    search_fields = ('slug', 'content')
>
> > > admin.site.register(Section, SectionAdmin)
>
> > > (also add inlines = [SectionInline,] to FlatPageAdmin class)
>
> > > # views.py - before creating Request Context
>
> > >    # Create a dictionary, indexed by section slug, of section content
> > >    d = {}
> > >    for s in f.section_set.all():
> > >        d[s.slug] = mark_safe(s.content)
>
> > >    ...etc...
>
> > >    c = RequestContext(request, {
> > >        'flatpage': f,
> > >        'section': d,
> > >    })
>
> > > So of course, in my templates I could just render a block/section of
> > > content as {{ section.section_1 }}.
>
> > > Do we think something like this could be useful for the general
> > > population, either as part of flatpages or as a separate app?
>
> > > Keith
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---