I installed askbot through pip into my existing local Django project. I merged the askbot settings & Uls files with my existing files. When I go to 127.0.0.1:8000/ its getting redirected to 127.0.0.1:8000/questions. And I can see all my existing users but no sign in is available.
I see a lot of Url redirects not working because of reverse, like Reverse for 'home' with arguments '()' and keyword arguments '{}' not found. In my backend database all the tables are looking fine. But users are not integrated with askbot, also there is AttributeError with context_processor.py.
How to allow my existing and future users, who are authenticated by my existing django project use askbot seamlessly?
How does the askbot admin integrates with my existing admin site?
Can we convert Jinja2 template to Django tempalte?
This is my template context tuple
TEMPLATE_CONTEXT_PROCESSORS = (
#askbot
#'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
#"allauth.context_processors.allauth",
#"allauth.account.context_processors.account",
'askbot.context.application_settings',
#'django.core.context_processors.i18n',
'askbot.user_messages.context_processors.user_messages',#must be before auth
'django.contrib.auth.context_processors.auth', #this is required for admin
'django.core.context_processors.csrf', #necessary for csrf protection
###############askbot ended###########
#"django.contrib.auth.context_processors.auth",
"django.core.context_processors.media",
'django.core.context_processors.static',
#"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
"apps.common.utils.context_processors.app_wide_vars",
"apps.common.context_processors.feedback_questions",
"allauth.context_processors.allauth",
"allauth.account.context_processors.account",
#"allauth.socialaccount.context_processors.socialaccount",
#'cms.context_processors.media',
'sekizai.context_processors.sekizai',
#'admintools_bootstrap.context_processors.site',
)
Related
I am using allauth with wagtail. I have name my site 'mysite' in the wagtail admin, but when sign up emails refer to 'example.com'
My settings.py has apps in the following order
[ ...
'django.contrib.auth',
'django.contrib.sites',
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.account",
"allauth.socialaccount",
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
]
It sounds as though this might be related to the conflict between django and wagtail described here https://github.com/wagtail/wagtail/issues/2840. However it looks as though that issue has been closed and I am using recent version (Django==3.2.11, django-allauth==0.47.0, wagtail==2.15.1)
This is the expected behaviour - django-allauth is a Django package, not a Wagtail-specific one, and always uses Django's site model even when Wagtail is active. To update the site name, log in to the Django admin backend (as distinct from the Wagtail one - this can be found at http://localhost:8000/django-admin/ if you set up your project with the wagtail start command) and go to the Sites item.
The issue being fixed in https://github.com/wagtail/wagtail/issues/2840 was that Wagtail and django-allauth could not coexist at all, due to both of them trying to set a conflicting request.site variable.
I am relatively new to iFrame, and what I try to do is to load project A in an iframe that is in project B. Project A is running as a Django project on localhost:8000, and project B as a separate Django project on localhost:8001. Inside the project B, I have a Django template with the following content:
<iframe src="http://127.0.0.1:8000" height="500px" width="500px"></iframe>
The problem is that instead of seeing the content of project A home page, I see error message stating that:
127.0.0.1 refused to connect
Is there anything I am terribly missing?
This is the default Clickjacking Protection [Django docs] by Django kicking into action (Great for us!), but this is preventing you from loading the iframe in your other project. There are various options to solve this issue:
If you want all your pages from your project to be put inside an iframe then you can remove 'django.middleware.clickjacking.XFrameOptionsMiddleware' from your MIDDLEWARE settings:
MIDDLEWARE = [
...
'django.middleware.clickjacking.XFrameOptionsMiddleware',
...
]
If this is for only specific views you can use the xframe_options_exempt decorator:
from django.views.decorators.clickjacking import xframe_options_exempt
#xframe_options_exempt
def some_view(request):
...
I noticed that this question was repeated few times, but still, from all the resources, I couldn't manage to make it work properly.
I'm simply trying to use Azure Active Directory authentication with my Django app.
I am using this module, and I configured everything as noted in the docs.
The thing is - I can't figure out where should user enter the credentials - since the module has only
one url ('auth-callback/'). I can't find out how to jump to Microsoft login html page. Should I use my login.html or?
Also, I guess that 'auth-callback/' url is obviously a callback URL, which comes after the login page.
I am using django auth.views LoginView for login, and custom login.html page.
In terms of Redirect URI's I configured redirect URI to match directly the 'http://localhost:8000/microsoft/auth-callback/' url, which is also how it needs to be I guess.
Main problem is - where can I enter the credentials for login? :)
Also, when I try this - I get invalid credentials error on my Admin login page :
Start site and go to /admin and logout if you are logged in.
Login as Microsoft/Office 365/Xbox Live user. It will fail. This will automatically create your new user.
Login as a Password user with access to change user accounts.
Quick Edit :
I noticed that when i go to django/admin page '..../admin/login' inside the console i have this error :
https://static/microsoft/css/login.css Failed to load resource (404)
https://static/microsoft/js/login.js Failed to load resource (404)
Where can i get those files?
Let's jump to my code :
settings.py
INSTALLED_APPS = [
...
'django.contrib.sites',
'microsoft_auth',
...
]
#Choped from templates
'context_processors': [
...
'microsoft_auth.context_processors.microsoft',
],
AUTHENTICATION_BACKENDS = [
'microsoft_auth.backends.MicrosoftAuthenticationBackend',
'django.contrib.auth.backends.ModelBackend',
]
SITE_ID = 1
LOGIN_REDIRECT_URL = 'main:index'
LOGOUT_REDIRECT_URL = 'main:index'
LOGIN_URL = '/'
LOGOUT_URL = '/'
# AZURE AUTH CONFIG
MICROSOFT_AUTH_CLIENT_ID = 'THIS IS MY CLIENT KEY'
MICROSOFT_AUTH_CLIENT_SECRET = 'THIS IS MY SECRET KEY'
MICROSOFT_AUTH_TENANT_ID = 'THIS IS MY TENANT KEY'
# include Microsoft Accounts, Office 365 Enterpirse and Azure AD accounts
MICROSOFT_AUTH_LOGIN_TYPE = 'ma'
And my urls.py
...
path('microsoft/', include('microsoft_auth.urls', namespace='microsoft')),
...
Thank you all in advance.
django-microsoft-auth uses the standard django login page and extends that. My guess is that your custom login page is interfering with that. You could try removing that view and test again to see if the login appears at /admin.
The files should be coming from the django-microsoft-auth package. You could try uninstalling and reinstalling it again with pip
Hey guys I am new to django , I am learning to build some application using it , so I am following some example instructions of some blog. In that there is need of configuring an social authentication django package with my app.
I am not getting where to add this line please point out.
Add social_django to INSTALLED_APPS Add
social_core.backends.yammer.YammerOAuth2 to AUTHENTICATION_BACKENDS
Set LOGIN_REDIRECT_URL = ‘/badges/’ Set LOGIN_URL = ‘/login/yammer’
I am trying to namespace Flatpages in Django. I included /pages/ in URLConf and added one URL /help/ in Django Admin Sites module. However, the page is loading with '/help/' and '/pages/help/' both URLs. I am trying to stop this behaviour and only load the page with /pages/help/. How is this possible?
urlpatterns = [
...
url(r'^pages/', include('django.contrib.flatpages.urls')),
]
You must have the fallback middleware installed in your MIDDLEWARE_CLASSES setting:
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
Remove it, and then it will only work on the prefix you have specified.