django-sessions

User authentication with mobile number and OTP in Django 1.7

走远了吗. 提交于 2019-12-13 00:42:07
问题 I have two types of users. - Customer. - Vendor. For Customers, I've already created custom user class where login happens through email and password. But, Vendors do not have email id and password. All vendor accounts are manually created by the django admin. Vendor class looks like this. class Vendor(): phone = models.CharField(max_length=12, unique=True, required=True) name = models.CharField() . . What's the best way to implement OTP login for Vendors? Vendors usually login through an

Django: Session created in database when login page loaded

[亡魂溺海] 提交于 2019-12-12 04:47:17
问题 My django_session table was growing very large and it seems to be due to a pingdom bot that I set-up hitting my login page. I tried creating a brand new django 1.4 app and the behaviour is replicated on any page that uses the django.contrib.auth.views.login page, including the default admin login page. This surely can't be the desired behaviour. Is it a bug? Is there a fix? (I have redirected the pingdom bot to another page that doesn't cause a new session to be created but I'd like to solve

Jquery Ajax post to update django sessions in views

柔情痞子 提交于 2019-12-11 16:14:47
问题 I am sending the values from my form fields , so as to store them in sessions in django. I am doing the following, but it does not receive the data in POST in django. <script type="text/javascript"> var eventID = $('#id_eventID').val(); var start = $('#id_start').val(); $('a').click(function () { console.log("Inside click"); $.post({ url: "/update_session/", type: "POST", data: {eventID: eventID, start: start}, success: function(response){}, complete: function(){}, error: function (xhr,

django session_key different on each ajax call

余生颓废 提交于 2019-12-10 18:26:35
问题 I've got a django application that I am accessing only over AJAX. My main problem is I want to get a unique ID which pairs to a particular browser instance making the request. To try to do this, I'm trying to access the session_key that django creates, but it's sometimes coming back as None . Here's how I'm creating the JSON response in django: def get(self, request, pk, format=None): resp_obj = {} ... resp_obj['csrftoken'] = csrftoken # shouldn't need the next two lines, but request.session

Django: session database table cleanup

心已入冬 提交于 2019-12-09 05:02:40
问题 Does this table need to be purged or is it taken care automatically by Django? 回答1: Django does NOT provide automatic purging. There is however a handy command available to help you do it manually: https://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-store python manage.py clearsessions 回答2: Django 1.6 or Above python manage.py clearsessions Django 1.5 or lower python manage.py cleanup From Django Shell from django.contrib.sessions.models import Session Session

How to handle multiple user type in Django

谁说我不能喝 提交于 2019-12-08 08:52:22
问题 I'm trying to make a small website which has three types of users ["client" , "volunteer" , "coordinator"] . Each type of user has restrictions on what views it can access. All three users have different login pages. Approach 1 : To achieve this, I've added a key to the session category , assign one of the above given userTypes during login and, whenever a view is called, check whether that user can access that view. login.html: {% extends "base.html" %} {% block content %} {% if form.errors

different values of a django session variable in different tabs

ⅰ亾dé卋堺 提交于 2019-12-08 01:10:57
问题 Consider the following scenario: User searches for something and a list (request.session['List']) is created User can filter this list via an ajax call Now the user opens up a new tab, does another search, so now the session variable List is set to the new list for the other search User goes back to the first tab and filters the results again. This time, the filter results come from the new list in the other tab as the session variable has changed Is there a way to set different values for a

Disadvantages of sharing Django sessions on multiple subdomains

旧时模样 提交于 2019-12-07 11:30:32
问题 I have built a Django site using the Sites Framework and have four sites on different subdomains. Lets call them one.mydomain.com; two.mydomain.com ... etc. Three of the sites are product sites and one is a store. I want to be able to share sessions across the sites so a user doesn't have to login again when moving from any of the product sites to the store. I realize I could use cas to achieve the single login but I don't think that meets all my purposes. I have read this post and this post

Django Session Persistent but Losing Data

♀尐吖头ヾ 提交于 2019-12-07 05:54:01
问题 I have been working for hours trying to understand the following problem: I have a user send an Ajax request to dynamically send a form and record that the number of forms to read on submission has increased. Toward this end I use request.session['editing_foo'] = { 'prefix_of_form_elements' : pkey } so that I can associate them with the database for saving and loading (-1 is for new forms that haven't been saved yet). However, when I use the following code (see bottom) I get the following

Sometimes request.session.session_key is None

给你一囗甜甜゛ 提交于 2019-12-07 01:16:58
问题 I hit a problem when get session_key from request.session . I am using Django1.8 and Python2.7.10 to set up a RESTful service. Here is snippet of my login view: user = authenticate(username=userName, password=passWord) if user is not None: # the password verified for the user if user.is_active: # app_logger.debug("User is valid, active and authenticated") if hasattr(user, 'parent') : login(request, user) request.session['ut'] = 4 # user type 1 means admin, 2 for teacher, 3 for student, 4 for