문제

Here's some easy karma for somebody. I just completed the django introductory tutorial with the intent of applying it to the Zinnia blogging platform. I have it serving up just fine, but would like to customize zinnia and am not sure how to do it. Actually that's a lie, I sort of know, but I have no idea what that link is actually doing.

Since completing the tutorial I am accustomed to a nice folder in my djo project housing poll apps, customizable url/models/settings/templates in this poll directory, and so forth. But zinnia has none of this, or is storing all of these things in an obscure directory:

/usr/local/lib/python2.7/dist-packages/django_blog_zinnia-0.12.3-py2.7.egg/zinnia

Can someone explain to me what is going on, and how I can learn to customize the zinnia platform?

Say I wanted to change the background, title, static content, models, or url file for zinnia. How!?! Does one change any of these files directly, or do you copy the lot (there's way more than /templates/ in here) to a django project folder (i.e., maybe /djo/zinnia/template would work?)? What would happen if I copied something other than the template directory into my djo/zinnia/ folder; would this override the /usr files (contents below)?

admin/                  fixtures/     managers.py*   ping.pyc      sitemaps.py*   testsettings.py*
comparison.py*          flags.py*     managers.pyc   search.py*    sitemaps.pyc   testsettings.pyc
comparison.pyc          flags.pyc     migrations/    search.pyc    spam_checker/  urls/
context_processors.py*  __init__.py*  models/        settings.py*  static/        url_shortener/
context_processors.pyc  __init__.pyc  moderator.py*  settings.pyc  templates/     views/
feeds.py*               locale/       moderator.pyc  signals.py*   templatetags/  xmlrpc/
feeds.pyc               management/   ping.py*       signals.pyc   tests/
도움이 되었습니까?

해결책

다른 팁

You can copy the templates folder inside the Zinnia folder -- if you installed in a virtual environment, any app you install will be housed in the site-packages folder inside your virtual environment -- and paste it inside of and paste it in your project folder so that it's in the same directory as your manage.py file. In your settings.py file, do something like this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.i18n',
                'django.template.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'zinnia.context_processors.version',
            ],
            'debug': DEBUG
        }
    }
]

The important part here, for easily making changes to the templates, and seeing those changes when you refresh your site running on your local server, is this part 'DIRS': [os.path.join(BASE_DIR, 'templates')], , which will look inside the templates folder you copy/pasted for any changes.

Running python manage.py collectstatic should gather a CSS folder that you can make changes to, which, when combined with adjusting the templates, should give you a lot of room to customize the blog layout.

In terms of changing the templates to "fit your skin," that's passed off as being a bit (well, a lot) easier than it is. That's where I'm currently at in developing a page powered by Zinnia, and I think the best approach is probably to start from scratch with your templates, while having the original Zinnia templates at your disposal to reference.

Maybe there's a better method than starting from scratch, but I found that applying a framework like Materialize of Bootstrap (by adding the css/javascript files in the skeleton.html file) pretty much caused the original Zinnia layout to a)Look a lot better, but b)Pretty much break entirely, too.

If the default layout is generally acceptable for your needs, you can always just bypass implementing a new CSS framework, and just tweak the CSS files found in zinnia/CSS to get the colors/fonts/etc. that you're looking for.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top