Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 407403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:35:28+00:00 2026-05-12T17:35:28+00:00

I am currently writing a few custom template tags but for some reason they

  • 0

I am currently writing a few custom template tags but for some reason they will not load. My directory structure is as follows:

MyProj
 |
 ----MyApp
     |
     |----templatetags
          |
          |----myapp_tags.py
          |----__init__.py

In myapp_tags.py

from django.template import Library, Node
from myproj.myapp.models import Product

register = Library()

class LatestProductsNode(Node):
    def render(self, context):
        context['recent_products'] = Product.objects.all()[:5]
        return ''

def get_latest_products(parser, token):
    return LatestProductsNode()

get_latest_products = register.tag(get_latest_products)

In settings.py

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'myproj.myapp',
)

In the Template

{% load myapp_tags %}

The error i get when trying to load the page:

Exception Type:     TemplateSyntaxError Exception Value:    

'myapp_tags' is not a valid tag library: Could not load template library from django.templatetags.myapp_tags, No module named myapp_tags
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:35:28+00:00Added an answer on May 12, 2026 at 5:35 pm

    in settings.py, you should never name the project ‘myproj’ explicitely. In INSTALLED_APPS, just use ‘myapp’. Also, you should have this :

    TEMPLATE_LOADERS = (
        'django.template.loaders.app_directories.load_template_source',
    )
    

    And be sure to have an __init__.py in the myapp folder as well as in templatetags.

    Use manage.py shell then from myapp.templatetags import myapp_tags to find out if theres any python error in the myapp_tags.py file.

    Also, be sure that myapp_tags.py file name doesnt conflicts with another folder/file in your project.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing a application that will eventually be going to market, but
I'm currently writing a function what would create a zip file, which will be
I'm currently writing several Python modules which perform some I/O. Thoses modules can be
I'm currently writing some update polling stuff. I try to avoid writing even a
I'm currently writing a PHP script that 3rd party clients will be able to
I am writing a few algorithms to build random forests, each forest will be
I am currently running Tridion 2011 SP1. I am writing some code that runs
I am currently developing a theme for a homepage but ran into a few
I'm currently writing a big project in java, with numerous classes, some classes are
I'm currently writing some php code to convert dates from the Gregorian Calendar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.