Hello, Thank you, must have thought about it... Probably need some rest, now it seems so obvious a solution. Eugene
On 4 июл, 15:56, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2007-07-04 at 04:34 -0700, Eugene Morozov wrote: > > Hello, > > I have two projects, they were developed independently. They will be > > run on the same server and have many things in common (notably some > > models and templatetags). > > > While I can import models from another project if it is on PYTHONPATH, > > I cannot find a way to share templatetags. I don't want to copy them, > > because maintaining costs would become higher (need to remember to > > apply bug fixes in both places, for example). > > > Is there a way to import templatetags from another project? > > Reuse is much easier once you think in terms of applications, rather > than projects. A project is just a collection of applications (really, > it's just a settings file and maybe a root URLConf). So you can easily > share an application in two projects, since applications can be imported > from anywhere on your Python path, as you've noted. > > So, if you *only* want to share the template tags and nothing else from > their current application, make a new application that only contains > those template tags. Then you can install that application into both > projects (by including the import path in INSTALLED_APPS in each > project's settings file) and the code will be shared as you would > expect. As mentioned in a thread earlier today on this list, loading a > template tag in a template will cause all the installed apps to be > searched for that template tag file, so you don't need to worry about > keeping the tags right next to the templates they are used in. > > > Django is really great framework, but I have a gut feeling that Django > > support for code reuse is significantly worse, than, say, in Plone/ > > Zope 3. Though it might be because of my relative inexpirience in > > Django. > > It's due to your inexperience, I suspect. Almost everything in Django > operates through normal Python imports, so you can share any code that > is on your Python path. The only real constraints are that template tags > are loaded from a directory called templatetags/ that must live in an > application directory and models must live in a module called "models". > Everything else is free-form and entirely under your control. > > Regards, > Malcolm > > -- > Depression is merely anger without > enthusiasm.http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---