django-messages

Django - Messages functionality not working in Class based view

十年热恋 提交于 2021-02-11 14:02:43
问题 Unable to display messages in class based view. In another app's views.py, it is working fine where I used function based view. views.py: class PostDeleteView(LoginRequiredMixin, UserPassesTestMixin, SuccessMessageMixin, DeleteView): model = Post success_url = '/user-profile/' success_message = "Your post has been deleted sucessfully!" def test_func(self): post = self.get_object() if self.request.user == post.author: return True return False urls.py: path('user-profile/', user_views.user

Django building a user-to-user messaging system [closed]

此生再无相见时 提交于 2021-01-29 11:35:50
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Improve this question I'm trying to build a messaging system for my website using Django but I don't know how to do. What I want is a system that enables a user to send a message to another user, with an inbox to see the received messages and notifications that warn the user he received

Redirect while passing message in django

不羁岁月 提交于 2020-01-13 03:59:06
问题 I'm trying to run a redirect after I check to see if the user_settings exist for a user (if they don't exist - the user is taken to the form to input and save them). I want to redirect the user to the appropriate form and give them the message that they have to 'save their settings', so they know why they are being redirected. The function looks like this: def trip_email(request): try: user_settings = Settings.objects.get(user_id=request.user.id) except Exception as e: messages.error(request,

Redirect while passing message in django

别来无恙 提交于 2020-01-13 03:59:05
问题 I'm trying to run a redirect after I check to see if the user_settings exist for a user (if they don't exist - the user is taken to the form to input and save them). I want to redirect the user to the appropriate form and give them the message that they have to 'save their settings', so they know why they are being redirected. The function looks like this: def trip_email(request): try: user_settings = Settings.objects.get(user_id=request.user.id) except Exception as e: messages.error(request,

Django Cannot assign “u'username'”: “Message.recipient” must be a “User” instance

爷,独闯天下 提交于 2020-01-05 04:42:18
问题 why I'm getting this error? I don't know how to get rid of this error. How can i clean the form field to enable the username to be validated? Thanks in advance. class InboxCompany(generic.UpdateView): model = CandidateToJob template_name = 'dashboard/inbox-company.html' form_class = ComposeMessage def get(self, *args, **kwargs): recipient = self.get_object(queryset=CandidateToJob.objects.select_related('candidate')) if recipient is not None: user = User.objects.get(username=recipient

Delayed display of message from within an inclusion tag

妖精的绣舞 提交于 2019-12-25 09:35:04
问题 The following problem is occurring in a large django project. I've been able to replicate the issue in a small mock-up project (code below). I am trying to use the django messaging framework within an inclusion tag to display a message when a POST'ed form returns is_valid(). This approach has also been used in an another answer here (see 'final update' section). The problem is that the message is not immediately displayed when the page is rendered after the POST. Instead the message appears

Django Postman implementation for sending messages

徘徊边缘 提交于 2019-12-23 01:34:48
问题 I am trying to use the Django-Postman framework to send messages between users in Django 2.0 . I have installed the app and made the necessary changes as mentioned in the docs of the framework. However when i try to go the the message urls I get a blank page (like this screenshot): Here is what I have done so far: Installed django-postman In settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib

Django: customizing the message after a successful form save

被刻印的时光 ゝ 提交于 2019-12-19 19:52:53
问题 whenever I save a model in my Admin interface, it displays the usual "successfully saved message." However, I want to know if it's possible to customize this message because I have a situation where I want to warn the user about what he just saved and the implications of these actions. class PlanInlineFormset(forms.models.BaseInlineFormset): def clean(self): ### How can I detect the changes? ### (self.changed_data doesn't work because it's an inline) ### and display what he/she just changed

Django messages faulty, but only on one particular network

佐手、 提交于 2019-12-13 20:09:51
问题 I'm experiencing an issue with Django's messaging framework, but only on one specific network. Two users have reported the issue on their office network, but if they access the site via a different network (e.g. their home network), everything runs smoothly. The issue is simply that messages don't get 'cleared' after being viewed. So once a message has been created, it will persist across requests until the user has lots of messages piling up on the screen. I just wondered if anyone had any

Django messaging framework messages not making it passed the redirect()

隐身守侯 提交于 2019-12-11 17:54:07
问题 I have some "save" code that sets a success message using the Django messaging framework upon successful creation of a record, then does a redirect back to the main 'application_update' view. I'm having trouble determining why these messages are not making it thru the redirect. The messaging seems to work just fine when doing a "render_to_response", but not when doing a "redirect". function snippet (if POST) in views.py: if ovrd_form.is_valid(): fields = {'application': ovrd_form.cleaned_data