Re: A Few Questions with How to Work With Views

2007-05-23 Thread Tim Chase

>> (1) I'd like to include little snippets from each app on
>> another app's pages.  For instance, a little "widget" in a
>> sidebar of my blog software that has some random pictures
>> from the photo management.  Is there any suggestion on how
>> to do this?
> 
> Template Tags!
> 
> http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags

I second David's recommendation.  In particular, I suggest 
skimming down from there to

http://www.djangoproject.com/documentation/templates_python/#inclusion-tags

which makes it fairly easy to separate the presentation (stashed 
in a template, where editing the HTML becomes fairly easy) from 
the data view.

As a side question:
Is there any convention used by the Django overlords for storing 
inclusion-tag templates?  Just toss all the inclusion-tag 
templates in the projname/appname/templates/ with the full page 
templates?  Or cordon them off in a separate sub-directory?  And 
if using a separate sub-directory, is there a preferred naming 
convention (such as "templates/tags/")?  Or shove them in some 
place outside of the projname/appname/templates/ directory?

-tim







--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: A Few Questions with How to Work With Views

2007-05-23 Thread David Reynolds


On 23 May 2007, at 4:23 pm, rockstar_ wrote:



Hi guys-

  I'm not new to Python, or to web development, but I am new to web
development with python and new to Django.  I've been reading about
Django, and been dabbling with it for about six months.  It's about
time I crap or get off the pot.  And, well, Django has been fun so
far, so I'm gonna crap...  :)

  I've been using Django to design a new iteration of my website, and
replace all the third party software I've been using because either I
can't customize that software, or I'm sure I could write something
much better.  So far, I've created two different apps in my project, a
blog software and a photo manager.  I've got all the logic working,
and I'm really liking how it works.  The only problem is, now I've got
to get into how the templates work.  So here are my questions:

  (1) I'd like to include little snippets from each app on another
app's pages.  For instance, a little "widget" in a sidebar of my blog
software that has some random pictures from the photo management.  Is
there any suggestion on how to do this?


Template Tags!

http://www.djangoproject.com/documentation/templates_python/#writing- 
custom-template-tags



  (2) I'd like to create a global header and footer, which will apply
to all pages, and have in abstracted into their own template files.
That way, if I need to add a new javascript file, or make a change to
a meta tag, I can do that without having to write some mad crazy sed
scripts.


You can do this pretty easily using the {% block thing %}{% endblock  
%} tags. There is also the {% include %} tag, if you need it.


http://www.djangoproject.com/documentation/templates/


  (3) I'd like to create a tagging app that allows tags for blog posts
and for photos.  I know how the database model for this might look,
and I've read a bit on the many-to-many relationship in Django, but
does anyone have any pointers here?


Someone has made a fairly generic tagging application:

http://code.google.com/p/django-tagging/

Hope that helps!

Dave
--
David Reynolds
[EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature


A Few Questions with How to Work With Views

2007-05-23 Thread rockstar_

Hi guys-

  I'm not new to Python, or to web development, but I am new to web
development with python and new to Django.  I've been reading about
Django, and been dabbling with it for about six months.  It's about
time I crap or get off the pot.  And, well, Django has been fun so
far, so I'm gonna crap...  :)

  I've been using Django to design a new iteration of my website, and
replace all the third party software I've been using because either I
can't customize that software, or I'm sure I could write something
much better.  So far, I've created two different apps in my project, a
blog software and a photo manager.  I've got all the logic working,
and I'm really liking how it works.  The only problem is, now I've got
to get into how the templates work.  So here are my questions:

  (1) I'd like to include little snippets from each app on another
app's pages.  For instance, a little "widget" in a sidebar of my blog
software that has some random pictures from the photo management.  Is
there any suggestion on how to do this?
  (2) I'd like to create a global header and footer, which will apply
to all pages, and have in abstracted into their own template files.
That way, if I need to add a new javascript file, or make a change to
a meta tag, I can do that without having to write some mad crazy sed
scripts.
  (3) I'd like to create a tagging app that allows tags for blog posts
and for photos.  I know how the database model for this might look,
and I've read a bit on the many-to-many relationship in Django, but
does anyone have any pointers here?

  I'm excited to actually finish and deploy some Django code!

rockstar_


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---