What do you want to save?
Add Code snippet
New code examples
-
Python 2022-01-22 14:50:19
keep the user logged in even though user changes password django
from django.contrib.auth import authenticate, login, update_session_auth_hash ###after changing password in view update_session_auth_hash(request, form.user) ###form.user is currentuser also can be accesed from request.user Add solution -
Python 2021-11-19 12:31:07
create django group
from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType from api.models import Project new_group, created = Group.objects.get_or_create(name='new_group') # Code to add permission to group ??? ct ... Add solution -
Python 2021-11-19 02:34:21
django httpresponseredirect
from django.http import HttpResponseRedirect Add solution -
Python 2021-11-18 08:45:18
how to add decorators with class in django
from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required #AS example class ProfileView(View): @method_decorator(login_required(login_url='login')) def get(self, request): ....... Add solution -
Python 2021-11-17 04:16:18
django file field from base64
import base64 from django.core.files.base import ContentFile format, imgstr = data.split(';base64,') ext = format.split('/')[-1] data = ContentFile(base64.b64decode(imgstr), name='temp.' + ext) # You can save this as file instance. Add solution