wlanslovenija/django-missing

docs(readme): add minimal requirements

Closed this issue · 9 comments

I installed the 0.1.13 but got forrowing error. My project require Django 1.6.5 is it compatible with active_url() ?

KeyError at /legal_framework/

'request'

Request Method:     GET
Request URL:    http://localhost:8000/legal_framework/
Django Version:     1.6.5
Exception Type:     KeyError
Exception Value:    

'request'

Exception Location:     /home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/context.py in __getitem__, line 56
Python Executable:  /home/elopez/.env/evrpa/bin/python
Python Version:     2.7.6
Python Path:    

['/mnt/data/projects/EVRPA',
 '/home/elopez/.env/evrpa/lib/python2.7',
 '/home/elopez/.env/evrpa/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/elopez/.env/evrpa/lib/python2.7/lib-tk',
 '/home/elopez/.env/evrpa/lib/python2.7/lib-old',
 '/home/elopez/.env/evrpa/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/elopez/.env/evrpa/local/lib/python2.7/site-packages']

Server time:    Thu, 16 Oct 2014 15:11:13 +0000

Error is on

 <li class="{% active_url 'core:view_legal_framework' %}"><a href="{% url 'core:view_legal_framework' %}" class="">
{% trans "Cadre de l'EVRP" %}</a></li>

What is stack trace?

Here it is:

Environment:


Request Method: GET
Request URL: http://localhost:8000/units/

Django Version: 1.6.5
Python Version: 2.7.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_extensions',
 'core',
 'south',
 'bootstrapform',
 'missing']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Template error:
In template /mnt/data/projects/EVRPA/evrpa/templates/base.html, error at line 64
   request
   54 : 


   55 : {% block main %}


   56 :     <div class="container-fluid">


   57 :         <div class="row">


   58 :             {% block sidebar %}


   59 :                 <div class="col-sm-3 col-md-2 sidebar">


   60 :                     <ul class="nav nav-sidebar">


   61 :                         <li><a href="{% url 'core:view_site_infos' %}" class="">


   62 :                             {% trans "Accueil" %}</a>


   63 :                         </li>


   64 :                         <li class=" {% active_url 'core:view_legal_framework' %} "><a href="{% url 'core:view_legal_framework' %}" class="">


   65 : {#                        <li><a href="{% url 'core:view_legal_framework' %}" class="">#}


   66 :                             {% trans "Cadre de l'EVRP" %}</a></li>


   67 :                         <li><a href="{% url 'core:list_internal_groups' %}" class="">


   68 :                             {% trans "Acteurs internes" %}</a></li>


   69 :                         <li><a href="{% url 'core:list_external_actors' %}" class="">


   70 :                             {% trans "Intervenants externes" %}</a></li>


   71 :                         <li><a href="{% url 'core:list_work_units' %}" class="">


   72 :                             {% trans "Unités de travail" %}</a></li>


   73 :                         <li><a href="{% url 'core:roadmap' %}" class="">


   74 :                             {% trans "Planification/suivi" %}</a></li>


Traceback:
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "/mnt/data/projects/EVRPA/core/views.py" in list_work_units
  191.     return render(request, 'frontend/list_work_units.html', context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render
  53.     return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  169.         return t.render(context_instance)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  78.             return node.render(context)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/base.py" in render
  1125.                     return func(*resolved_args, **resolved_kwargs)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/missing/templatetags/url_tags.py" in active_url
  365.                 current_url = context['request'].build_absolute_uri(context['request'].path)
File "/home/elopez/.env/evrpa/local/lib/python2.7/site-packages/django/template/context.py" in __getitem__
  56.         raise KeyError(key)

Exception Type: KeyError at /units/
Exception Value: 'request'

Do you have request middleware enabled?

I reckon I don't, here is what I got in my settings.py:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

You should have it.

I'm sorry if the question seems trivial but what the middleware name, I can't find it in the doc.

Sorry, my mistake, confused things. Request context process is what you need.

indeed I added this to get it works in my settings.py

TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
        'django.core.context_processors.request',
)

Great!