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

  • Home
  • SEARCH
  • 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 984293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:59:32+00:00 2026-05-16T04:59:32+00:00

I get: TemplateSyntaxError at /blog/post/test Caught NameError while rendering: global name ‘forms’ is not

  • 0

I get:

TemplateSyntaxError at /blog/post/test
Caught NameError while rendering:
global name ‘forms’ is not defined

for this code:
forms.py

from dojango.forms import widgets
from django.contrib.comments.forms import CommentForm
from Website.Comments.models import PageComment

class PageCommentForm(CommentForm):
    title = widgets.TextInput()
    rating = widgets.RatingInput()

    def get_comment_model(self):
        return PageComment

    def get_comment_create_data(self):
        # Use the data of the superclass, and add in the title field
        data = super(PageComment, self).get_comment_create_data()
        data['title'] = self.cleaned_data['title']
        return data

models.py

from Website.CMS.models import Author, Rating
from django.db.models import CharField, ForeignKey
from django.contrib.comments.models import Comment

class PageComment(Comment):
    title = CharField(max_length=300)
    parent = ForeignKey(Author, related_name='parent_id', null=True)
    author = ForeignKey(Author, related_name='author_id')

    def __unicode__(self):
        return self.title

class CommentRating(Rating):
    comment = ForeignKey(PageComment)

__init__.py

from Website.Comments import *

def get_model():
    return models.PageComment

def get_form():
    return forms.PageCommentForm #error here

importing form directly inside init.py results in:

AttributeError: ‘module’ object has no
attribute ‘Comments’

Here’s the stack trace, the error appears to be coming from dojango but that doesn’t really make sense:

File
“I:\wamp\www\Website\Comments__init__.py”,
line 1, in
from Website.Comments import models, forms File
“I:\wamp\www\Website\Comments\forms.py”,
line 1, in
from dojango import forms File “C:\Python26\lib\site-packages\dojango\forms__init__.py”,
line 2, in
from widgets import * File “C:\Python26\lib\site-packages\dojango\forms\widgets.py”,
line 11, in
from dojango.util.config import Config File
“C:\Python26\lib\site-packages\dojango\util\config.py”,
line 3, in
from dojango.util import media File
“C:\Python26\lib\site-packages\dojango\util\media.py”,
line 49, in
for app in settings.INSTALLED_APPS) File
“C:\Python26\lib\site-packages\dojango\util\media.py”,
line 49, in
for app in settings.INSTALLED_APPS) File
“C:\Python26\lib\site-packages\dojango\util\media.py”,
line 38, in find_ pp_dojo_dir_and_url
media_dir = find_app_dojo_dir(app_name) File
“C:\Python26\lib\site-packages\dojango\util\media.py”,
line 27, in find_ pp_dojo_dir
base = find_app_dir(app_name) File
“C:\Python26\lib\site-packages\dojango\util\media.py”,
line 20, in find_ pp_dir
mod = getattr(import(m, {}, {}, [a]), a)

The Comments app is in the installed apps.
What should I do?

EDIT:
If I try to include forms directly with import forms I get this:

Traceback (most recent call last):
File “I:\wamp\www\Website\manage.py”, line 11, in
execute_manager(settings)
File “C:\Python26\lib\site-packages\django\core\management__init__.py”, line
438, in execute_manager
utility.execute()
File “C:\Python26\lib\site-packages\django\core\management__init__.py”, line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “C:\Python26\lib\site-packages\django\core\management\base.py”, line 191,
in run_from_argv
self.execute(*args, **options.dict)
File “C:\Python26\lib\site-packages\django\core\management\base.py”, line 209,
in execute
translation.activate(‘en-us’)
File “C:\Python26\lib\site-packages\django\utils\translation__init__.py”, lin
e 66, in activate
return real_activate(language)
File “C:\Python26\lib\site-packages\django\utils\functional.py”, line 55, in _
curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File “C:\Python26\lib\site-packages\django\utils\translation__init__.py”, lin
e 36, in delayed_loader
return getattr(trans, real_name)(*args, **kwargs)
File “C:\Python26\lib\site-packages\django\utils\translation\trans_real.py”, l
ine 193, in activate
_active[currentThread()] = translation(language)
File “C:\Python26\lib\site-packages\django\utils\translation\trans_real.py”, l
ine 176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File “C:\Python26\lib\site-packages\django\utils\translation\trans_real.py”, l
ine 159, in _fetch
app = import_module(appname)
File “C:\Python26\lib\site-packages\django\utils\importlib.py”, line 35, in im
port_module
import(name)
File “I:\wamp\www\Website\Comments__init__.py”, line 2, in
import forms
File “I:\wamp\www\Website\Comments\forms.py”, line 3, in
from dojango.forms import fields, widgets
File “C:\Python26\lib\site-packages\dojango\forms__init__.py”, line 2, in
from widgets import *
File “C:\Python26\lib\site-packages\dojango\forms\widgets.py”, line 11, in
from dojango.util.config import Config
File “C:\Python26\lib\site-packages\dojango\util\config.py”, line 3, in
from dojango.util import media
File “C:\Python26\lib\site-packages\dojango\util\media.py”, line 49, in
for app in settings.INSTALLED_APPS)
File “C:\Python26\lib\site-packages\dojango\util\media.py”, line 49, in
for app in settings.INSTALLED_APPS)
File “C:\Python26\lib\site-packages\dojango\util\media.py”, line 38, in find_a
pp_dojo_dir_and_url
media_dir = find_app_dojo_dir(app_name)
File “C:\Python26\lib\site-packages\dojango\util\media.py”, line 27, in find_a
pp_dojo_dir
base = find_app_dir(app_name)
File “C:\Python26\lib\site-packages\dojango\util\media.py”, line 20, in find_a
pp_dir
mod = getattr(import(m, {}, {}, [a]), a)
AttributeError: ‘module’ object has no attribute ‘Comments’

Removing any reference for dojango solves the problem.

  • 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-16T04:59:32+00:00Added an answer on May 16, 2026 at 4:59 am

    This is a bug in dojango.
    I will report it.

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

Sidebar

Related Questions

I've got the following error: TemplateSyntaxError at /admin/results_cop/copsegmentresult/ Caught an exception while rendering: ('ascii',
The get works fine and able to post to the database with a test
The full text of the error is: TemplateSyntaxError at / Caught an exception while
I am getting the following error in my error logs: TemplateSyntaxError: Caught ImportError while
GET Method, it works fine. url: http://myurl.com/test.html?query=id=123&name=kkk I do not have concepts of POST
GET is a convenient method to post the form id, post the website id
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
GET : $.get(..) POST : $.post().. What about PUT/DELETE ?
Get all elements like this without jQuery <input type=checkbox name=IB_PROPERTY_415_DEL id=IB_PROPERTY_415_DEL value=Y> <input type=checkbox
Get the following error while linking my project in Delphi XE2. Recreating of .dproj

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.