'WSGIRequest' object has no attribute 'session'
See original GitHub issueRunning python manage.py distill-local site-export
produces the response CommandError: Failed to render view "/": 'WSGIRequest' object has no attribute 'session'
URLs.py config:
from django.urls import path
from django.contrib.auth.views import LoginView, LogoutView
from . import views
from django_distill import distill_path
def get_index():
return None
def get_ageVerification():
return None
def get_register():
return None
def get_login():
return None
def get_profile():
return None
def get_message():
return None
def get_messages():
return None
def get_faq():
return None
def get_legal():
return None
urlpatterns = [
distill_path('', views.index, name='index', distill_func=get_index, distill_file="index.html"),
distill_path('ageVerification', views.ageVerification, name='ageVerification', distill_func=get_ageVerification),
distill_path('register', views.register, name="register", distill_func=get_register),
distill_path('login', LoginView.as_view(template_name='user/login.html'), name='login', distill_func=get_login),
path('logout', LogoutView.as_view(), name='logout'),
distill_path('accounts/profile/', views.profile, name="profileUser", distill_func=get_profile),
distill_path('message/<str:username>', views.message, name="message", distill_func=get_message),
distill_path('messages', views.messages, name="messages", distill_func=get_messages),
distill_path('faq', views.faq, name="faq", distill_func=get_faq),
distill_path('legal', views.legal, name="legal", distill_func=get_legal)
]
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
python - 'WSGIRequest' object has no attribute 'session' while ...
But my MIDDLEWARE classes are in the correct order. INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib ...
Read more >AttributeError at / 'WSGIRequest' object has no attribute 'session'
locally I was using python 3.5 no virtualenv. Ohhhh. It's because you were using django 1.10 locally and 1.9 on pythonanywhere. One is ......
Read more >'WSGIRequest' object has no attribute 'session'
Hi,all. I often meet this problem recently while I run the django project. How to fix it? Thanks. Traceback (most recent call last):...
Read more >'WSGIRequest' object has no attribute 'session' (in webpay)
[traceback] AttributeError: 'WSGIRequest' object has no attribute 'session' (in webpay) · Categories · Tracking · People · References · Details · Crash Data...
Read more >'WSGIRequest' object has no attribute 'session' #1 - GitHub
I can't reproduce this in development, but in production I get this error when using PinningSessionMiddleware: 'WSGIRequest' object has no attribute ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You do not need to pass in a custom requests object, this is handled for you. However, this view, I suspect, when run via
distill
won’t do anything. It’ll return a redirect, and probably throw an error for not returning a 200 status code. You can’tdistill
dynamic actions (decision based redirects, forms, etc.) only static content. For example this will work fine:But this will not:
During building the static site it will always trigger the redirect and result in trying to render a redirect and throwing an error. To make a flat, static site you can only render static views which return HTML and 200 HTTP status code, and it is advisable the views are consistent so always return the same thing when they are called. Obviously a static site can’t support any database or session features at all as no code executes anywhere when looking at a static HTML page.
As for your
session
error, looks like it could be related to the order of your middleware, does this site work normally withoutdistill
under./manage.py runserver
? I’m guessing yourageCheck
function tries to set some sort of session variable?As you’ve not replied for a week I’ll assume this has resolved your issue and close it. Feel free to open another issue if you encounter any more problems.