1

I am not quite sure if my directory structure has the correct hierarchy and I decided to stop the development unless I will have it good. I have order, customers, users .

So what I have is:

myproj
   |-myproj
   |-web_app
   |---orders (with views.py, ajax.py)
   |----templatetags 
   |---users
   |---customers
   |---search
   |---static
   |-----app
   |-------_base
   |---------css
   |---------images
   |---------js
   |-------orders
   |---------css
   |---------images
   |---------js
   |-------customers
   |---------css
   |---------images
   |---------js
   |-------users
   |---------css
   |---------images
   |---------js
   |-----bootbox
   |-----bootstrap
   |-------css
   |-------fonts
   |-------js
   |-----dajax
   |---templates

models.py is in web_app directory, there are models common for all modules. My questions are:

1) What changes would you do in this structure? (static files for every module should be where?) 2) I have problem of inserting custom template tag defined in orders/templatetags/orders_extras.py from users template. How can I make some common templatetags for every "module" ?

Thank you.

2 Answers 2

1

This is explained in Django documentation very well. The good approach is:

Project
   - App1
     (Put app specfic templates to the app templates/App1/templates/App1/template files
   - App2
   - App3
   - template for project (templates/ files)

Now, if you want template tags only for specific app create /templatetag directory under that app and do that.

For universal template tag do this:

Project
   - templatetags
      - __init__.py (Make sure it contains __init__.py)
      - polltag.py 

Explained here: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

0

How can I make some common templatetags for every "module" ?

You should place it near the templates directory

myproj
   |-myproj
   |-web_app
   |---templates 
   |---templatetags 
   |---orders (with views.py, ajax.py)
   |----static
   |-----static_files_here

dajax

Is this about dajax? If you are new to django, I recommend to get away from this stuff. You can just watch the issues list of this project to decide whether you should use it or not. The problem not only about that dajax is bad or good, but that these issues are being made by newbies that don't understand how ajax works, what are csrf tokens and so on.

When I started to learn django, I tried dajax too, but finally I have realized that you should understand how ajax and django works by their own and then try to combine them.

1
  • Ah .. I already have undergone the battle with dajax, it really sucks in documentation and I have found some issues, but after all, when you know how to workaround all the nasty bugs, it's quite nice. But it absolutely cannot be compared with any ajax library of any framework.. It's pity...
    – Ladiko
    Sep 17, 2013 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.