Re: Django Admin templates not being overwritten by app templates

2019-11-10 Thread Aldian Fazrihady
You need to reorder the app list in INSTALLED_APP setting, so
`django.contrib.admin` is located lower than your app`.

On Mon, Nov 11, 2019 at 3:49 AM Alexander Beach  wrote:

> I am trying to create registration forms using Django's built in auth
> forms.  However, when using the Django admin, the Django admin templates
> are always being used.
>
> My application structure is as follows:
>
> ├── bug
> │   ├── __init__.py
> │   ├── __pycache__
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── db.sqlite3
> ├── manage.py
> └── mysite
> ├── admin.py
> ├── apps.py
> ├── __init__.py
> ├── migrations
> │   └── __init__.py
> ├── models.py
> ├── registration
> ├── templates
> │   └── registration
> │   └── password_reset_form.html
> ├── tests.py
> └── views.py
>
>
>
> My urls.py is the following:
>
>
> from django.contrib import admin
> from django.conf.urls import include, url
> from django.urls import path
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> url(r'^accounts/', include('django.contrib.auth.urls'), name="auth"),
> ]
>
>
>
> The mysite/templates/registration/password_reset_form.html is not being
> rendered.  When I navigate to localhost:8000/accounts/password_reset, i can
> see that its using the Django Admin template. See attached screenshot.  I
> am expecting my custom template for the reset form to be rendered.
>
> I am using Django version 2.2.5 and python 3.7.3
>
> Is this a bug or the expected behavior? I don't want to remove the admin
> app.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c718299d-53f6-4e56-8976-a2040f3449ac%40googlegroups.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAabPjVcLDgou_Ee_aK899E3KiVvxSGSkqA0hqXhDiU1BQ%40mail.gmail.com.


Re: Django Admin templates not being overwritten by app templates

2019-11-10 Thread Alexander Beach
This behavior seems counter intuitive, and contrary to what the 
documentation says

For example: my settings.py file is as follows:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]


According to this documentation, APP_DIR should behave as follows:

https://docs.djangoproject.com/en/2.2/howto/overriding-templates/#overriding-from-an-app-s-template-directory

> With APP_DIRS 

 set 
to True, the template loader will look in the app’s templates directory and 
find the templates.

This isn't the behavior that is happening. djang_admin and mysite are 
technically separate apps, and have seperate template directories. 

On Sunday, November 10, 2019 at 3:49:32 PM UTC-5, Alexander Beach wrote:
>
> I am trying to create registration forms using Django's built in auth 
> forms.  However, when using the Django admin, the Django admin templates 
> are always being used.
>
> My application structure is as follows:
>
> ├── bug
> │   ├── __init__.py
> │   ├── __pycache__
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── db.sqlite3
> ├── manage.py
> └── mysite
> ├── admin.py
> ├── apps.py
> ├── __init__.py
> ├── migrations
> │   └── __init__.py
> ├── models.py
> ├── registration
> ├── templates
> │   └── registration
> │   └── password_reset_form.html
> ├── tests.py
> └── views.py
>
>
>
> My urls.py is the following:
>
>
> from django.contrib import admin
> from django.conf.urls import include, url
> from django.urls import path
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> url(r'^accounts/', include('django.contrib.auth.urls'), name="auth"),
> ]
>
>
>
> The mysite/templates/registration/password_reset_form.html is not being 
> rendered.  When I navigate to localhost:8000/accounts/password_reset, i can 
> see that its using the Django Admin template. See attached screenshot.  I 
> am expecting my custom template for the reset form to be rendered.
>
> I am using Django version 2.2.5 and python 3.7.3
>
> Is this a bug or the expected behavior? I don't want to remove the admin 
> app. 
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0520c4c2-abbb-441c-bd81-1aeeb8c355b8%40googlegroups.com.


Re: Django Admin templates not being overwritten by app templates

2019-11-10 Thread Mike Dewhirst

On 11/11/2019 7:02 am, Alexander Beach wrote:
I am trying to create registration forms using Django's built in auth 
forms.  However, when using the Django admin, the Django admin 
templates are always being used.


My application structure is as follows:

|
├──bug
│├──__init__.py
│├──__pycache__
│├──settings.py
│├──urls.py
│└──wsgi.py
├──db.sqlite3
├──manage.py
└──mysite
├──admin.py
├──apps.py
├──__init__.py
├──migrations
│└──__init__.py
├──models.py
├──registration
├──templates
|

| mysite/templates/admin/password_reset_form.html

Not tested but that's the principle. Django will default to using the 
template from your site rather than its own. The admin is one of your 
apps so it will use any templates it finds (that urls.conf knows about) 
in your main templates directory.


Cheers

Mike

|

|
│└──registration
│└──password_reset_form.html
├──tests.py
└──views.py

|


My urls.py is the following:


|
fromdjango.contrib importadmin
fromdjango.conf.urls importinclude,url
fromdjango.urls importpath


urlpatterns =[
    path('admin/',admin.site.urls),
    url(r'^accounts/',include('django.contrib.auth.urls'),name="auth"),
]

|


The mysite/templates/registration/password_reset_form.html is not 
being rendered.  When I navigate to 
localhost:8000/accounts/password_reset, i can see that its using the 
Django Admin template. See attached screenshot.  I am expecting my 
custom template for the reset form to be rendered.


I am using Django version 2.2.5 and python 3.7.3

Is this a bug or the expected behavior? I don't want to remove the 
admin app.





--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c718299d-53f6-4e56-8976-a2040f3449ac%40googlegroups.com 
.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e77a76e-e6a5-392c-acd9-4694e260a42e%40dewhirst.com.au.


Django Admin templates not being overwritten by app templates

2019-11-10 Thread Alexander Beach
I am trying to create registration forms using Django's built in auth 
forms.  However, when using the Django admin, the Django admin templates 
are always being used.

My application structure is as follows:

├── bug
│   ├── __init__.py
│   ├── __pycache__
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── manage.py
└── mysite
├── admin.py
├── apps.py
├── __init__.py
├── migrations
│   └── __init__.py
├── models.py
├── registration
├── templates
│   └── registration
│   └── password_reset_form.html
├── tests.py
└── views.py



My urls.py is the following:


from django.contrib import admin
from django.conf.urls import include, url
from django.urls import path


urlpatterns = [
path('admin/', admin.site.urls),
url(r'^accounts/', include('django.contrib.auth.urls'), name="auth"),
]



The mysite/templates/registration/password_reset_form.html is not being 
rendered.  When I navigate to localhost:8000/accounts/password_reset, i can 
see that its using the Django Admin template. See attached screenshot.  I 
am expecting my custom template for the reset form to be rendered.

I am using Django version 2.2.5 and python 3.7.3

Is this a bug or the expected behavior? I don't want to remove the admin 
app. 




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c718299d-53f6-4e56-8976-a2040f3449ac%40googlegroups.com.