These are chat archives for django/django

4th
Apr 2018
djangoReactGuy
@SanskarSans
Apr 04 2018 03:23 UTC
anyone has idea on this?
Prateek Dabas
@dprateek11
Apr 04 2018 04:06 UTC
i want to become a django developer
i am currently reading Test-Driven Development with python by Harry J.W. Percival
is this a right track
i have done django official tutorial
Luke-VideoLibre
@LukeVideo
Apr 04 2018 07:52 UTC
@dprateek11 sounds good. almost everyone here sends newbies to the documentation. So yeah the official tutorial is a good start. I only saw videos of J.W Percival on Youtube, seams more than decent. Keep it up and ask any questions here, don't forget to paste some code so we can help you.
:]
@elcolie
Apr 04 2018 08:38 UTC
@dprateek11 I started with https://www.codingforentrepreneurs.com/ He also has free class in YouTube. TDD is good. I also practice it. It does answer many future questions from my colleagues.
Prateek Dabas
@dprateek11
Apr 04 2018 10:01 UTC
@elcolie is TDD will limit me to testing or i can go into development also??
@LukeVideo is TDD will limit me to testing or i can go into development also??
Sirius Dely
@siriusdely
Apr 04 2018 11:05 UTC
@dprateek11 as the term suggests, test driven development is actually development safe-guarded by testing. so it is both testing and developing, and the main purpose is indeed on the development part
Nitesh Tosniwal
@sudonitesh
Apr 04 2018 17:16 UTC
Can I ask you why you chose django instead nodejs though nodejs has more job opportunities..? I'm asking because after completing front_end I want to dive into backend and couldn't decide between django and nodejs... Actually In India most of the internships are for nodejs.. And only few for Django... Please suggest 🙏
Rafa Huelin
@rafahuelin
Apr 04 2018 20:56 UTC

Hi everybody,
I´m doing an exercise that involves user authentication. Everything works smooth, but when I logout the app goes into a loop with this message on the console:

[04/Apr/2018 22:44:14] "GET /account/logged_out/ HTTP/1.1" 302 0
[04/Apr/2018 22:44:14] "GET /account/logged_out/ HTTP/1.1" 302 0
[04/Apr/2018 22:44:14] "GET /account/logged_out/ HTTP/1.1" 302 0

part of the settings.py

from django.urls import reverse_lazy

LOGIN_REDIRECT_URL = reverse_lazy('account:dashboard')
LOGIN_URL = reverse_lazy('account:login')
LOGOUT_REDIRECT_URL = reverse_lazy('account:logged_out')

app/urls.py

from django.conf import settings
from django.contrib.auth import views as auth_views
from django.urls import path
from . import views

app_name = 'account'

urlpatterns = [
    # path('login/', views.user_login, name='login'),
    path('', views.dashboard, name='dashboard'),

    # login / logout urls
    path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
    path('logout/', auth_views.LogoutView.as_view(template_name='registration/logged_out.html'), name='logout'),

    # path('logout-then-login/', auth_views.logout_then_login, name='logout_then_login'),
]

How would you handle this routing to be redirected to the logged_out.html template?
Thanks!

I´m using Django 2.0.4
django_social_tree.png
Project structure
Abhijeet Kumar
@arcticOak2
Apr 04 2018 23:10 UTC
d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}} this line of code is working in python 2.7 can anyone suggest me its 2.6 version?
It's urgent. I got stuck here and I have deadline after 2 hrs.
def etree_to_dict(t):
    d = {t.tag: {} if t.attrib else None}
    children = list(t)
    if children:
        dd = defaultdict(list)
        for dc in map(etree_to_dict, children):
            for k, v in dc.items():
                dd[k].append(v)
        d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}
    if t.attrib:
        d[t.tag].update(('@' + k, v) for k, v in t.attrib.items())
    if t.text:
        text = t.text.strip()
        if children or t.attrib:
            if text:
              d[t.tag]['#text'] = text
        else:
            d[t.tag] = text
    return d
this is full code