On 21/06/06, djx <[EMAIL PROTECTED]> wrote:
*snip*

Okay, so my original post was a bit vague, but I'll have another stab
at explaining.

------ Start example code

--- /blogs/models.py
...
class Blog(Model):
    title = CharField(maxlength=60, core=True, unique=True)
    tagline = CharField(maxlength=250, blank=True)
    theme = CharField(maxlength=len("antidisestablishmentarianism"))
    slug = SlugField(prepopulate_from=("title",), core=True, unique=True)
    def __str__(self):
        return self.title+": "+self.subtitle
    class Admin:
        pass
...

--- /urls.py ---
from django.conf.urls.defaults import *
from django.conf import settings

urlpatterns = patterns('',
    (r'^admin/', include('django.contrib.admin.urls')),
    (r'^blogs/([_A-Za-z0-9-]+)/', include('bloghost.blogs.urls')),
)

--- /blogs/urls.py ---
from django.conf.urls.defaults import *
from discussium.forum.models import *

urlpatterns += patterns('bloghost.blog.views',
    *bunch of views*
)

--- /templates/blogs/base.html ---

{% extends "base.html" %}

{% block head %}
    <link rel="stylesheet" type="text/css" href="/styles/{{ blog_theme
}}/ie.css" />
{% endblock %}
{% block title %}{{ blog_name }} - {% block title2 %}{% endblock %}{%
endblock %}


------ End example code

So now every template needs to have blog_theme and blog_name passed to
it. This is fair enough for views, which just take blog_slug and then
pass it to a function like this at the end:

def response_with_blog_info(blog_slug, template, context):
    blog = get_object_or_404(Blog, slug__exact=blog_slug)
    context = context + {
        "blog_name": blog.name,
        "blog_theme": blog.theme,
    }
    render_to_response(template, context)

Fair enough, there's no real repetition there. However, what about
when I want to use generic views? I could use extra_context, couldn't
I? Well, no, because extra_context doesn't know about the blog_slug,
so it doesn't know which blog it's on.

Sorry for the vague first post, I hope this helps people understand my problem.

Thanks,
Frankie.

(All the code here is merely example code to illustrate my point and
is probably riddled with errors.)
(Incidentally blog_slug sounds kind of disgusting, seriously, just try
saying it.)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to