GithubHelp home page GithubHelp logo

Comments (18)

bradleyayers avatar bradleyayers commented on August 29, 2024

I'm not sure why you had a problem. Did you add 'django_tables2' to INSTALLED_APPS in your settings.py?

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

Yes, I followed the instructions verbatim and the error went away only after I copied the egg's contents to my template path.

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

I figured this was intended functionality, since as I said in the first post, the Django tutorial had me edit my TEMPLATE_DIRS entry. I reproduce it here by renaming my dt2 template folder to something else, and trying to load the page. I can provide more details on my project if you need. The error is listed:

Environment:

Request Method: GET
Request URL: http://192.168.1.101:8000/records/all/

Django Version: 1.3.1
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'marketanalyzer',
'django_tables2']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Template error:
In template l:\django\templates\records\all.html, error at line 3
Caught TemplateDoesNotExist while rendering: django_tables2/table.html
1 :

2 : {% load django_tables2 %}

3 : {% render_table table %}

Traceback:
File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\core\handlers\base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "L:\django\ELC\marketanalyzer\views.py" in all
  2.                           context_instance=RequestContext(request))
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\shortcuts__init__.py" in render_to_response
  3. return HttpResponse(loader.render_to_string(_args, *_kwargs), **httpresponse_kwargs)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\loader.py" in render_to_string
  4.     return t.render(context_instance)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\base.py" in render
  5.         return self._render(context)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\base.py" in _render
  6.     return self.nodelist.render(context)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\base.py" in render
  7.             bits.append(self.render_node(node, context))
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\debug.py" in render_node
  8.         result = node.render(context)
    
    File "build\bdist.win32\egg\django_tables2\templatetags\django_tables2.py" in render
  9.             template = get_template(template)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\loader.py" in get_template
  10. template, origin = find_template(template_name)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\loader.py" in find_template
  11. raise TemplateDoesNotExist(name)
    

Exception Type: TemplateSyntaxError at /records/all/
Exception Value: Caught TemplateDoesNotExist while rendering: django_tables2/table.html

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

That's very strange. You shouldn't need to copy anything to your templates directory, because the django.template.loaders.app_directories.Loader template loader searches app directories.

Does your TEMPLATE_LOADERS setting look like this?

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

Yes. It is untouched since the project was setup as per Django's tutorial using django-admin.py startproject

Is there perhaps some other way to test whether the resolving of paths is working, in case my being a novice is causing me to overlook some detail?

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

I've just tested this and it works for me. Could you download this test project and see if it works for you? http://dl.dropbox.com/u/33499139/testtest.zip

I did get the TemplateDoesNotExist error, but only when I hadn't added 'django_tables2' to INSTALLED_APPS.

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

Just to make sure I'm doing this right:
Copied contents to a drive, ran "python manage.py runserver" in testtest folder, went to 127.0.0.1:8000, and got an error.

When I added the entry for TEMPLATE_DIRS that I am using in my original project, it works, but as you sent it to me, it prints the following error:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.3.1
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_tables2']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:

Traceback:
File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\core\handlers\base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "L:\testtest..\testtest\views.py" in home
  2. return HttpResponse(table.as_html())
    
    File "build\bdist.win32\egg\django_tables2\tables.py" in as_html
  3.     template = get_template(self.template)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\loader.py" in get_template
  4. template, origin = find_template(template_name)
    
    File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\template\loader.py" in find_template
  5. raise TemplateDoesNotExist(name)
    

Exception Type: TemplateDoesNotExist at /
Exception Value: django_tables2/table.html

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

That all sounds correct. How did you install django-tables2 this time? Did you have it installed globally from when you installed it for your other project? or are you using virtualenv? If you installed it globally, did you perhaps move the templates out of the egg directory, rather than copy?

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

I didn't have to install it a second time. I am on a win7 box and ran "easy_install django-tables2" the other day. I think EasyInstall comes with SetupTools? And no, the egg is intact as far as I can tell b/c the file I had to copy to my template dir is still there (django_tables2-0.8.1-py2.7.egg/django_tables2/templates/django_tables2/table.html).

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

I thought perhaps this might be a windows only bug, so I tested it on a windows box I have and it worked fine. Perhaps try re-installed django-tables2? I'd also recommend using pip. (easy_install pip; pip install django-tables2) pip lets you uninstall too, pip uninstall django-tables2

from django-tables2.

chenwardT avatar chenwardT commented on August 29, 2024

Grabbed pip, tried "pip install django-tables2", which noticed it was already installed, so I uninstalled dt2 via pip, then installed it again via pip, which worked.

Ran the dev server for your test project and it rendered the page properly. My TEMPLATE_DIRS for that project was empty. So I guess it has something to do with easy_setup?

Edit: I also just realized that I have new directories in my "...\Python27\Lib\site-packages" for django_tables2 and django_tables2-0.8.1-py2.7.egg-info which weren't there when I had it installed via easy_setup.

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

It's very strange. I tried it installing it with easy_install and it worked as well. You can give it a go yourself too if you like (pip uninstall django-tables2; easy_install django-tables2). I'm really baffled why it didn't work originally for you :( I'll close this for now.

from django-tables2.

ngkabra avatar ngkabra commented on August 29, 2024

Add 'django.template.loaders.eggs.Loader' to TEMPLATE_LOADERS to fix this.

I ran into this issue today and figured out the problem. Giving the solution here in case someone else runs faces this.

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

ngkabra I don't understand why it would be getting installed as an egg. What's platform are you on?

from django-tables2.

ngkabra avatar ngkabra commented on August 29, 2024

I ran into this problem when using django-tables2 on my webfaction account.
On my development machine (Ubuntu Linux, python-2.7.2) everything worked
fine, but on webfaction "easy_install-2.7 django-tables2" installed as an
egg, and the problem obviously went away when I added the egg loader to my
settings.

On Mon, Mar 12, 2012 at 10:43 AM, Bradley Ayers <
[email protected]

wrote:

ngkabra I don't understand why it would be getting installed as an egg.
What's platform are you on?


Reply to this email directly or view it on GitHub:

#44 (comment)

from django-tables2.

bradleyayers avatar bradleyayers commented on August 29, 2024

Very interesting, thanks for the info!

from django-tables2.

davidswelt avatar davidswelt commented on August 29, 2024

Thank you @ngkabra - adding django.template.loaders.eggs.Loader helps. It was commented out.
(Installed django-tables2 with easy_install.)

from django-tables2.

e3krisztian avatar e3krisztian commented on August 29, 2024

Thanks @ngkabra, uncommenting the line also fixed the problem for me.
Ubuntu 13.10 Saucy, PIP 1.4.1, Django 1.3.1

from django-tables2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.