django-messages

How to send Json or “dict” using Django Messages Framework

我的梦境 提交于 2019-12-11 13:42:50
问题 I'm using Django Messaging framework to send additional data on the validation error: def clean_X(self): xuser_id = self.cleaned_data['xuser_id'] if xuser.objects.filter(xuser_id=xuser_id).exists(): available_now = {"available" : ["example","hello","ahc","sdcsd"]} messages.error(self.request, message = available_now,extra_tags="available_ids") raise forms.ValidationError('Sorry! User ID "%(xuser_id)s" is already taken, Please try another or chose one from following:', params={"xuser_id" :

Delete all django.contrib.messages

余生长醉 提交于 2019-12-11 08:15:35
问题 I recently realized that a module in our Django web app was using django.contrib.messages. However, the template's context processor did not have the django.contrib.messages.context_processors.messages processor added. I'm worried that when I push this to production, users will see all their old messages for all pages that had generated them. Is there a way to clear these messages for all users from the django shell ? 回答1: Messages will be shown for those users whose sessions already contain

RuntimeError: Model class django_messages.models.Message doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

心不动则不痛 提交于 2019-12-11 02:03:03
问题 I am trying to use https://github.com/arneb/django-messages package for my messaging stuff and tried the following pip install git+https://github.com/arneb/django-messages.git INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'rest_framework', 'rest_framework.authtoken', 'oauth2_provider', 'api', 'localflavor', 'django_localflavor_us',

Django: Remove duplicate messages from storage

时光总嘲笑我的痴心妄想 提交于 2019-12-07 19:34:42
问题 I'm using messages to add flash messages to the template (just as you'd expect). The problem I have is that if you double click a link to a page that generates a message then the message appears twice. I am using the message to tell the user I have redirected them from where they were expecting to go. They don;t need the same message twice. I understand the logic here but am wondering how I can remove duplicated messages. click url message generated, saved in storage click url again before

Django messages not showing after HttpResponseRedirect

ⅰ亾dé卋堺 提交于 2019-11-30 07:30:12
Tried tonnes of stuff out there but none of them really helped. I have a URL for example: http://localhost:8000/user/edit-transaction/?object_id=23a959d0561711e59e36acd1b8679265&type=grossary which calls the below view : def edit_transaction(request): if request.method == "POST": if something is True: messages.error(request, 'Error message here') # this don't work return HttpResponseRedirect(request.META.get('HTTP_REFERER')) # but this work template = "user/xyz/abc.html" render(request, template) else: return HttpResponseNotFound() else: context = { 'key1': 'value1', 'key2': 'value2', }

Django messages not showing after HttpResponseRedirect

别等时光非礼了梦想. 提交于 2019-11-29 10:34:50
问题 Tried tonnes of stuff out there but none of them really helped. I have a URL for example: http://localhost:8000/user/edit-transaction/?object_id=23a959d0561711e59e36acd1b8679265&type=grossary which calls the below view : def edit_transaction(request): if request.method == "POST": if something is True: messages.error(request, 'Error message here') # this don't work return HttpResponseRedirect(request.META.get('HTTP_REFERER')) # but this work template = "user/xyz/abc.html" render(request,