Re: Customizing Django built-in views such as LoginView

2020-05-30 Thread 'László Hegedűs' via Django users
I was a Django fan since I am freelancer, and introduced to Flask.
The best is in Django is 2 thing:
First, easy to use.
Second: consitent. So I think each of the solution is good if not have side 
effect to the other.

On Friday, May 29, 2020 at 2:31:17 PM UTC+2, Uri wrote:
>
> Django users,
>
> Which way is preferred to customize Django built-in views such as 
> LoginView:
>
> - Define a line in urls.py:
>
> path(route='login/', view=views.django_auth_views.LoginView.as_view(
> template_name='accounts/login.html', authentication_form=forms.LoginForm, 
> extra_context=None, redirect_authenticated_user=True), name='login'),
>
> Where, views.py contains:
>
> from django.contrib.auth import views as django_auth_views
>
>
> *Or:*
>
> In views.py, define a new class:
>
> class LoginView(django_auth_views.LoginView):
> template_name = 'accounts/login.html'
> authentication_form = LoginForm
> extra_context = None
> redirect_authenticated_user = True
>
> And then, define in urls.py:
>
> path(route='login/', view=views.LoginView.as_view(), name='login'),
>
>
> Will both ways work the same, and is one of them preferred from a software 
> engineering / programming perspective?
>
> Thanks,
> Uri.
> אורי
> u...@speedy.net 
>

-- 
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/d0d6f677-4317-462e-bd6a-e48a06757077%40googlegroups.com.


Re: Customizing Django built-in views such as LoginView

2020-05-29 Thread אורי
Thank you.
אורי
u...@speedy.net


On Fri, May 29, 2020 at 3:57 PM Augusto Destrero 
wrote:

> I would choose the second option and define a LoginView subclass in the
> views.py module.
> The outcome is exactly the same, but I'd prefer to have my views all
> defined in views.py file.
> Adding too much logic in the urls.py module IMHO is not a good idea and it
> makes the view less extendable in the future.
>
> Augusto
> www.guguweb.com
>
> On Friday, May 29, 2020 at 2:31:17 PM UTC+2, Uri wrote:
>>
>> Django users,
>>
>> Which way is preferred to customize Django built-in views such as
>> LoginView:
>>
>> - Define a line in urls.py:
>>
>> path(route='login/', view=views.django_auth_views.LoginView.as_view(
>> template_name='accounts/login.html', authentication_form=forms.LoginForm,
>> extra_context=None, redirect_authenticated_user=True), name='login'),
>>
>> Where, views.py contains:
>>
>> from django.contrib.auth import views as django_auth_views
>>
>>
>> *Or:*
>>
>> In views.py, define a new class:
>>
>> class LoginView(django_auth_views.LoginView):
>> template_name = 'accounts/login.html'
>> authentication_form = LoginForm
>> extra_context = None
>> redirect_authenticated_user = True
>>
>> And then, define in urls.py:
>>
>> path(route='login/', view=views.LoginView.as_view(), name='login'),
>>
>>
>> Will both ways work the same, and is one of them preferred from a
>> software engineering / programming perspective?
>>
>> Thanks,
>> Uri.
>> אורי
>> u...@speedy.net
>>
> --
> 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/8b10a5cf-5f33-4035-98b2-54ac0b84f25e%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/CABD5YeHUGHNrm2jEEKqrj%2BBo2ygd_jr%3DZqqoPy02ZFE3AU0qvA%40mail.gmail.com.


Re: Customizing Django built-in views such as LoginView

2020-05-29 Thread Augusto Destrero
I would choose the second option and define a LoginView subclass in the 
views.py module.
The outcome is exactly the same, but I'd prefer to have my views all 
defined in views.py file.
Adding too much logic in the urls.py module IMHO is not a good idea and it 
makes the view less extendable in the future.

Augusto
www.guguweb.com

On Friday, May 29, 2020 at 2:31:17 PM UTC+2, Uri wrote:
>
> Django users,
>
> Which way is preferred to customize Django built-in views such as 
> LoginView:
>
> - Define a line in urls.py:
>
> path(route='login/', view=views.django_auth_views.LoginView.as_view(
> template_name='accounts/login.html', authentication_form=forms.LoginForm, 
> extra_context=None, redirect_authenticated_user=True), name='login'),
>
> Where, views.py contains:
>
> from django.contrib.auth import views as django_auth_views
>
>
> *Or:*
>
> In views.py, define a new class:
>
> class LoginView(django_auth_views.LoginView):
> template_name = 'accounts/login.html'
> authentication_form = LoginForm
> extra_context = None
> redirect_authenticated_user = True
>
> And then, define in urls.py:
>
> path(route='login/', view=views.LoginView.as_view(), name='login'),
>
>
> Will both ways work the same, and is one of them preferred from a software 
> engineering / programming perspective?
>
> Thanks,
> Uri.
> אורי
> u...@speedy.net 
>

-- 
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/8b10a5cf-5f33-4035-98b2-54ac0b84f25e%40googlegroups.com.