These are chat archives for django/django

Sep 2017
Renjith S Raj
Sep 20 2017 08:48
there is any open source projects? i really intersted to contriburte
Sep 20 2017 09:55
I'm having issues with a login view taht i adapted (copy pasted) from another project where it works fine. It might be obvious but i don't get it
here is the code
from django.shortcuts import render
from django.contrib.auth import authenticate, login, logout

from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required

from django.http import HttpResponseRedirect, HttpResponse
from django.views import generic
from django.shortcuts import redirect

from players.models import UserInfo
from players.forms import UserForm, UserInfoForm


def user_login(request):
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')

        user = authenticate(username=username, password=password)

        if user:
            if user.is_active:
                login(request, user)
                return HttpResponseRedirect(reverse('index'))
                return HttpResponse('account not active')
            return HttpResponse('invalid login or password')
        return render(request, 'players/login.html', {})
{% extends "players/base.html" %}

{% block main %}
  {% include "players/nav.html" %}
  <h1>Please login</h1>

  <form  action="{% url 'user_login' %}" method="post">
    {% csrf_token %}
    <label for="username">username :</label>
    <input type="text" name="username" placeholder="enter username">

    <label for="password">password :</label>
    <input type="password" name="password">

    <input type="submit" name="" value="Login">

  {% endblock %}
app_name = "players"
urlpatterns = [
    url(r'^$', index, name='index'),
    url(r'^register/', register, name='register'),

Sep 20 2017 10:01
error is
NoReverseMatch at /players/user_login/

Reverse for 'user_login' not found. 'user_login' is not a valid view function or pattern name.

Request Method:     GET
Request URL:
Django Version:     1.11.5
Exception Type:     NoReverseMatch
Exception Value:     

Reverse for 'user_login' not found. 'user_login' is not a valid view function or pattern name.

Exception Location:     /home/XXXXXXXXXXXXXXlib64/python3.6/site-packages/django/urls/ in _reverse_with_prefix, line 497
Python Executable:     /home/XXXXXXXXXXXXXX/bin/python
Python Version:     3.6.2
Python Path:     


Server time:     Wed, 20 Sep 2017 10:01:50 +0000
Sep 20 2017 10:16

ok got it :smile:

  <form  action="{% url 'user_login' %}" method="post">

should be :

  <form  action="{% url 'players:user_login' %}" method="post">

Forgot the name space there...

Sep 20 2017 19:37

On another hand i got this error

'utf-8' codec can't decode byte 0xe8 in position 6: invalid continuation byte.

The thing is i am returning bytecode after encrypting a string. So my model had a textfield to enter the text to encrytpt. But my view return cypher Byte code... But if i put a byteField it can't be handled by the So i have to find a solution to have a textfield on my page and pass a string to my view that passes it as byteCode to the model to save. Did anyone experience that or has advise on how to handle that ?