Django doesn't take Custom password_reset_form.html - django

I used a Custom password_reset_form.html
(My Path: /templates/registration/password_reset_form.html)
But Django takes the Django-Default-Password-Reset-View
Any solution what i could do?
urls.py
from django.contrib.auth import views as auth_views
from django.contrib.auth.forms import AuthenticationForm
from django.template import RequestContext
from django.urls import include, path, re_path
from myapp.CustomForms.appforms import LoginAuthenticationForm
from django.contrib.auth.views import LogoutView
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from myapp.views import (
...
)
from . import views
urlpatterns = [
...
url(r"^$", views.startseite, name="home"),
url(r"^signup/$", views.signup, name="signup"),
url(
r"^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z].
{1,13}-[0-9A-Za-z]{1,20})/",
views.activate, name="activate",),
url('^', include('django.contrib.auth.urls')),
]
settings.py
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.auth',
'myapp',
]
...

The reason why django didn't pick up my custom template cause i have to change the order of my
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'django.contrib.admin',
'django.contrib.auth',
]
myapp has to set before django.contrib.admin and django.contrib.auth

Related

DJ_REST_AUTH Error : NameError: name 'dj_rest_auth' is not defined

I have installed dj-rest-authfor Token Authentication.
My urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('customer/', include('customer.urls')), #new
path('api-auth/', include('rest_framework.urls')), # new
path('customer/dj-rest-auth/', include(dj_rest_auth.urls)),
]
Settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'customer',
'rest_framework.authtoken', # new
'dj_rest_auth',
]
My Requirements.txt:
asgiref==3.4.1
dj-rest-auth==2.1.11
Django==3.2.7
django-rest-auth==0.9.5
djangorestframework==3.12.4
psycopg2-binary==2.9.1
pytz==2021.1
six==1.16.0
sqlparse==0.4.2
But when I am trying to runserver It's giving me
NameError: name 'dj_rest_auth' is not defined
What am I doing wrong?
As documented, you should include it as a string "dj_rest_auth.urls" and not dj_rest_auth.urls from which it fails to find where dj_rest_auth is defined:
path('dj-rest-auth/', include('dj_rest_auth.urls'))
This is aligned with the usage of django.urls.include() which expects it to be the module name.

DoesNotExist at /admin/

DoesNotExist at /admin/
URL matching query does not exist.
I copy code form old study-project and i haven't similar problem in old project.
settings.py INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cutter',
]
admin.py:
from .models import URL
from django.contrib import admin
admin.site.register(URL)
urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('cutter.urls')),
path('admin/', admin.site.urls),
]
All another functions work.

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)

How do I remove 404 error from Django app?

I am trying to create a web app using Django framework. I followed the tutorial and did everything as per the tutorial.
DJANGO_PROJECT:
from django.contrib import admin
from django.urls import include
from django.conf.urls import url
urlpatterns = [
url(r'^dellserver/', include('dellserver.urls')),
url(r'^admin/', admin.site.urls),
]
Settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dellserver'
]
dellserver\urls.py:
from . import views
from django.conf.urls import url
urlpatterns = [
url(r'^dellserver/$', views.index, name="index")
]
views.py:
from django.http import HttpResponse
def index(request):
return HttpResponse("<h1>Hello World</h1>")
Can anybody tell me what I am doing wrong? Why I a getting the **
Page not found (404)
**
You did the mistake in project's url (folder which include settings.py file)
from django.contrib import admin
from django.urls import include
from django.conf.urls import url
urlpatterns = [
url(r'^/', include('dellserver.urls')), # this line you did the Mistake
url(r'^admin/', admin.site.urls),
]
in main urls remove dellserver as shown below.
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('dellserver.urls')),
]
so that you can call your url ../dellserver/, otherwise you have to call it ../dellserver/dellserver twice.

how to use django markdown in my blog

at first I successfully install django markdown
pip install django-markdown
than I add django-markdown in my setting.py file
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'django-markdown',
]
then, I change my urls.py like as:
from django.conf.urls import include, url
from django.contrib import admin
from resume import views
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^home/$', views.home, name='home'),
url(r'^blog/', include('blog.urls',namespace='blog',app_name='blog')),
url('^markdown/', include('django_markdown.urls')),
]
I also change my admin.py file like as:
from django.contrib import admin
from .models import Post
from django_markdown.admin import MarkdownModelAdmin
class PostAdmin(admin.ModelAdmin):
list_display = ('title','slug','author','publish','status')
list_filter = ('status','created','publish','author')
search_fields = ('title','body')
prepopulated_fields = {'slug':('title',)}
raw_id_fields = ('author',)
date_hierarchy = 'publish'
ordering = ['status','publish']
# Register your models here.
admin.site.register(Post,MarkdownModelAdmin, PostAdmin)
but, when I start my runserver, django gives me an error like this:
ModuleNotFoundError: No module named 'django-markdown'
how can i solve my problem?
In installed apps you should add django_markdown instead of django-markdown