Django-Registration not getting reset email - django

Followed this question:
Django registration email not sending
but realized this is for
https://github.com/macropin/django-registration
not
https://github.com/ubernostrum/django-registration
which is what I need.
Unfortunately, there is nothing about this in their docs about SMTP:
http://django-registration.readthedocs.io
ve is my app and
I've tested my SMTP creds on a 3rd party app and I got an email just fine. Tried on localhost and live site as well.
settings.py
INSTALLED_APPS = [
'registration',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
've',
'widget_tweaks',
]
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = '***'
EMAIL_HOST_PASSWORD = '***'
EMAIL_HOST_USER = '***'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'noreply#***'
urls.py
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'', include('ve.urls', namespace='ve')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

After continuously tinkering with this I decided to switch to the allauth Django package. After setting it up everything worked fine and I got much more desired functionality.
I know this is not the best solution as it does not fully answer the question above. However, it could be sort of an answer because switching to a more documented and current package is could also be the best idea.

Related

No CSS in Admin panel in Azure App Service hosted Django APP

I cant figure out how to make Azure App Service use css for admin panel.
In settings.py I included these:
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
But somehow css is still not working for the admin panel.
How can I fix this? As far as I know Oryx which works under Azure App Service should automatically run
python manage.py collectstatic
Any ideas?
EDIT:
Installed apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'licenses_api',
]
There are something to check might help:
Click F12 on your Admin page to check if it is the 404 Not Found error.
Check the static files exist in your azure web app or not. You could see it in https://{your-web-app}.scm.azurewebsites.net/wwwroot/ site.
Check if your file structure match with the settings.py. Any spell error would make the static file not found.
If your file exists well, you should check if you use them correctly in your code like this answer. Here is how he use:
from django.conf.urls.static import static
urlpatterns = [
path('myapp/', include('myapp.urls')),
path('admin/', admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Firstly try to add these code lines to
settings.py
STATIC_URL = '/static/'
if DEBUG:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
else:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Then import these lines to the
urls.py
from django.conf.urls.static import static
from django.conf import settings
from django.conf.urls import url
from django.views.static import serve
Finaly you have to add these lines to urlpatterns in
urls.py
url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),
(If you have not already created a static file please make sure to create one before you try this)
It's worked severl times for me and hope this will work for you too 😊

Django Oscar Dashboard link not accessible

I have developed oscar /django applications before but I am completely stumped by this issue:
I can see the dashboard url in the supported urls list but I am not able to access it.
404 Page
I have forked a few apps from oscar like voucher, shipping, checkout, reviews and customized them in various ways(None of these are dashboard related) . This is my INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'oscar.config.Shop',
'oscar.apps.analytics.apps.AnalyticsConfig',
'iirns.checkout.apps.CheckoutConfig',
'oscar.apps.address.apps.AddressConfig',
'iirns.shipping.apps.ShippingConfig',
'oscar.apps.catalogue.apps.CatalogueConfig',
'iirns.catalogue.reviews.apps.CatalogueReviewsConfig',
'oscar.apps.communication.apps.CommunicationConfig',
'oscar.apps.partner.apps.PartnerConfig',
'oscar.apps.basket.apps.BasketConfig',
'iirns.payment.apps.PaymentConfig',
'oscar.apps.offer.apps.OfferConfig',
'oscar.apps.order.apps.OrderConfig',
'oscar.apps.customer.apps.CustomerConfig',
'oscar.apps.search.apps.SearchConfig',
'iirns.voucher.apps.VoucherConfig',
'oscar.apps.wishlists.apps.WishlistsConfig',
'oscar.apps.dashboard.apps.DashboardConfig',
'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',
'oscar.apps.dashboard.ranges.apps.RangesDashboardConfig',
'oscar.apps.dashboard.reviews.apps.ReviewsDashboardConfig',
'oscar.apps.dashboard.vouchers.apps.VouchersDashboardConfig',
'oscar.apps.dashboard.communications.apps.CommunicationsDashboardConfig',
'oscar.apps.dashboard.shipping.apps.ShippingDashboardConfig',
# 3rd-party apps that oscar depends on
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
'mailer',
'extra',
]
and this is my root url file:
from django.conf.urls import url
from django.contrib import admin
from django.apps import apps
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('extra.urls')),
path('', include(apps.get_app_config('oscar').urls[0])),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Page not found (404) - Django

I have a strange behavior when I try to test my Django on the webpage.
I see what is the error, but I have no clue from where it comes.
What I try to do is :
I have project called stockmarket
I have application called stockanalysis
the problem is :
when I try to open 'domain/stockmarket I get this:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8888//
When I try to open 'domain/stockmarket/stockanalysis'
I get this:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8888//stockanalysis/
The issue is clear to me. In both cases I have two slashes (//) instead of one (/).
The issue is - I do not know from where it comes.
Any ideas?
here some files:
urls.py (project folder)
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^stockanalysis/', include('stockanalysis.urls')),
url(r'^admin/', admin.site.urls),
]
urls.py (app. folder)
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
views.py (app folder)
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the index.")
setting.py (project folder)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = '****************************************'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'stockanalysis.apps.StockanalysisConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
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',
)
ROOT_URLCONF = 'stockmarket.urls'
WSGI_APPLICATION = 'stockmarket.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
Issue is solved.
As I expected nothing wrong was with the files itself (like urls.py or settings.py).
The company which hosts the files did a mistake in vhosts entries in Apache. That's what they told me.
After I created my first Django project I was asked to provide some details, so they could do some adjustments on server side. While doing this they did mistake.

Django 1.5 and Heroku: My admin main has no links to anything

As I said above, I'm using Django 1.5 and Heroku. Everything works fine locally, but in the Heroku admin I just get the main page and that's it. There are no links to my app or anything in the "auth" category or ANYTHING. The image below is what comes up.
As you can see, no links, no buttons, nothing but text.
Has anyone experienced before or have any ideas? I would be happy to post my code, but I don't want to overload this with useless junk so ask and I'll be happy to add whatever info you might want to see.
Some basic things:
Settings.py snippets:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#'gunicorn',
#'django_evolution',
#Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'CRM',
)
urls.py snippet:
urlpatterns = patterns('',
#Uncomment the next line to enable the admin:
url(r'^/', include('CRM.urls')),
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
admin.autodiscover()
Everything is registered in my admin.py
admin.site.register(Client, ClientAdmin)
admin.site.register(Project, ProjectAdmin)
Thanks!
I figured it out! Yay! For those of you in the near or distant future that suffer from this, you need admin.autodiscover() at the TOP of your urls.py file.

allauth issue: providers list is empty in admin

I've setup allauth according to the readme. syncdb'ed etc.
However when i try to setup a social app in admin the Provider dropdown is empty.
I've tried to print get_list() in the providers/init.py file (which I assume is the method being used by models.py & the as_choices() method.
Do you have any pointers as to where I'm doing wrong? :)
Any help is greatly appreciated.
Kind regards,
pete
my settings file(well most of it):
from os.path import abspath, basename, dirname, join, normpath
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
SITE_NAME = basename(DJANGO_ROOT)
SITE_ROOT = dirname(DJANGO_ROOT)
sys.path.append(SITE_ROOT)
sys.path.append(normpath(join(DJANGO_ROOT, 'apps')))
sys.path.append(normpath(join(DJANGO_ROOT, 'libs')))
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#Authentication/signup backend
'project.apps.allauth',
'project.apps.allauth.account',
'project.apps.allauth.socialaccount',
'project.apps.allauth.socialaccount.providers.facebook',
'django.contrib.admin',
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
'project.apps.allauth.account.context_processors.account',
'project.apps.allauth.socialaccount.context_processors.socialaccount',
)
ACCOUNT_ADAPTER = 'project.apps.allauth.account.adapter.DefaultAccountAdapter'
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_PASSWORD_MIN_LENGTH = 8
ACCOUNT_SIGNUP_PASSWORD_VERIFICATION = False
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
SOCIALACCOUNT_PROVIDERS = {'facebook': {'SCOPE': ['email'], 'AUTH_PARAMS': {'auth_type': 'reauthenticate'}, 'METHOD': 'js_sdk', 'LOCALE_FUNC': 'path.to.callable'}}
my urls file:
urlpatterns = patterns('',
#(r'^/$', include('project.apps.main.urls')),
#(r'^account/$', include('project.apps.account.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^registration/', include('project.apps.allauth.urls')),
)
I am not sure if this is the cause of your problem, but you appear to be running with a manually tweaked Python path: you placed allauth below project.apps. This may introduce weirdness, for example, think about what happens when allauth starts importing itself: "from allauth import ...". In your case, the same module/code is reachable via project.apps and via allauth directly. Please try "normalizing" your installation, preferably using a tool like virtualenv.