so I have a problem when ever I go to /manage/ it takes me to index and im 
not sure why.

Urls.py
url(r'^', views.IndexView.as_view(), name='index'),
url(r'^manage/$', views.ManageView.as_view(), name='manage'),



Views.py

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.views import generic
from portal.models import Customer
from django.views.generic import TemplateView

class IndexView(generic.ListView):
      model = Customer
      template_name = 'index.html'
      context_object_name = 'Customer'

class ManageView(TemplateView):
  
      template_name = 'manage.html'
      context_object_name = 'form'
      
     @login_required(login_url='/manage/')
      def my_view(request):
         username = request.POST['username']
         password = request.POST['password']
         user = authenticate(username=username, password=password)
       
         if user is not None:
            if user.is_active:
               
               login(request, user)
               return redirect('index.html' % request.path)         
                
            else:
              return HttpResponse("Your, Account is Disabled.")
         
      def logout_view(request):
         logout(request)


manage.html

{% block content %}

{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post" action="{% url 'django.contrib.auth.views.login' %}">
{% csrf_token %}
<table>
<tr>
    <td>{{ form.username.label_tag }}</td>
    <td>{{ form.username }}</td>
</tr>
<tr>
    <td>{{ form.password.label_tag }}</td>
    <td>{{ form.password }}</td>
</tr>
</table>

<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}



index.html
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'customer/style.css' 
%}" />
{% if Customer %}
    <ul>
    {% for Customer in Customer %}
      
       <li>{{ Customer.customer_name }}</li>
    {% endfor %}
    </ul>
{% else %}
    <p>No customers are available.</p>
{% endif %}

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3ac31dd2-af6b-4559-8148-a33bb0911182%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to