These are chat archives for django/django

14th
Sep 2018
Luke-VideoLibre
@LukeVideo
Sep 14 2018 09:59
Hy all. I put some templates in app/templates/app/template and i get a template doesn't exist error when i do a redirection from one view to the other. Any idea ? Should i put all templates in a project level templates folder??
...src/confirmations/templates/account_activation_sent.html (Source does not exist)
Luke-VideoLibre
@LukeVideo
Sep 14 2018 10:12
the thing is i'm using Vitor Freitas simpleisbetterthancomplex blog email confirmation example. But their was a few issues for django2 but that is quite unique. If the template is in the template folder it's ok if it's with the other templates (signup, account_activation_email) it fails. The only thing i can think of is a problem with the redirect called from the signup view when the form passes.
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save(commit=False)
            user.is_active = False
            user.save()
            current_site = get_current_site(request)
            subject = 'Activate Your MySite Account'
            message = render_to_string('account_activation_email.html', {
                'user': user,
                'domain': current_site.domain,
                'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(),
                'token': account_activation_token.make_token(user),
            })
            user.email_user(subject, message)
            return redirect('account_activation_sent') # THIS CAUSES THE ERROR ????
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})


def activate(request, uidb64, token):
    try:
        uid = force_text(urlsafe_base64_decode(uidb64))
        user = User.objects.get(pk=uid)
    except (TypeError, ValueError, OverflowError, User.DoesNotExist):
        user = None

    if user is not None and account_activation_token.check_token(user, token):
        user.is_active = True
        user.profile.email_confirmed = True
        user.save()
        login(request, user)
        return redirect('home')
    else:
        return render(request, 'account_activation_invalid.html')


def account_activation_sent(request):
    print("looking for template")
    return render(request, 'account_activation_sent.html')
Lebzanwa
@Lebzanwa
Sep 14 2018 19:39

Need help..with the following.. can anyone walk me through...?

https://saleor.readthedocs.io/en/latest/gettingstarted/configuration.html#environment-variables
anyone who can walk me through it...

Cristian Samaniego
@chrisRubiano
Sep 14 2018 19:43
is there any way to get the field causing a DataError when trying to save a model instance?
AlejandroMendez
@AlejandroMendez
Sep 14 2018 21:33
Hello, somebody kwnows if i could to send a signal directly to a template? for example i need that every time i save a record in any model to show a modal with the message "saved" :p
AlejandroMendez
@AlejandroMendez
Sep 14 2018 22:44
:eyes: