Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ssl.SSLEOFError while sending emails through Django
Settings EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' DEFAULT_FROM_EMAIL = EMAIL_HOST_USER = 'no_reply@domain.com' SERVER_EMAIL = 'no_reply@domain.com' DEFAULT_DO_NOT_REPLY = 'User <no_reply@domain.com>' EMAIL_HOST_PASSWORD = 'xxxxxxxxx' EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = EMAIL_HOST_USER Class class EmailThread(threading.Thread): def __init__(self, subject, context, recipient, template): self.subject = subject self.recipient = recipient self.message = get_template(template).render(context) threading.Thread.__init__(self) def run(self): msg = EmailMessage( subject=self.subject, from_email=settings.DEFAULT_DO_NOT_REPLY, to=self.recipient, body=self.message ) msg.content_subtype = "html" try: msg.send(fail_silently=False) log.info("E-mail triggered. Subject: '%s', to: %s" % (self.subject, self.recipient)) except Exception as e: log.exception(e) Usage def notify_admin_blocked_account(user): """ Sends sends an email when the account is blocked :return: """ email = EmailThread( subject='{}, your account has been blocked'.format(user), context={ 'user': user, 'login_attempts': settings.MAX_STAFF_PWD_ATTEMPTS, }, recipient=[user.email,], template='mail/notify_admin_blocked_account.html' ) email.start() Error [ERROR][2017-08-01 10:40:26,835][mail] EOF occurred in violation of protocol (_ssl.c:645) Traceback (most recent call last): File "./bin/mail.py", line 27, in run msg.send(fail_silently=False) File "/home/web/sites/envs/project/lib/python3.5/site-packages/django/core/mail/message.py", line 348, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/web/sites/envs/project/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 104, in send_messages new_conn_created = self.open() File "/home/web/sites/envs/project/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 69, in open self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile) File "/usr/lib/python3.5/smtplib.py", line 766, in starttls server_hostname=self._host) File "/usr/lib/python3.5/ssl.py", line 377, in wrap_socket _context=self) File "/usr/lib/python3.5/ssl.py", line 752, in __init__ self.do_handshake() File "/usr/lib/python3.5/ssl.py", line 988, in do_handshake self._sslobj.do_handshake() File "/usr/lib/python3.5/ssl.py", line 633, in do_handshake self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation … -
python couchdb mapped documents returning the wrong data for DateField
Given the following mapped document: from couchdb.mapping import DateField, Document class Statement(Document): date = DateField() When I query CouchDB, the resulting document has date set correctly as a Date object. However, I'm trying to use this document in a Django template which winds up getting the date value via get(). Using get() translates to this bit of code in couchdb/mapping.py: def __getitem__(self, name): return self._data[name] So instead of returning a real Date object, it returns a unicode string from _data instead. Am I missing something? I want get() to return the mapped date value, not the original unicode string from _data. I can work around this by going through all the documents returned by my query and updated _data or by subclassing Mapping() so that get() works correctly, but it seems to me that this would be a bug. -
django rest framework global pagination not working with ListCreateAPIView
I have the following in my settings.py REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 50 } urls.py url(r'^dashboard/users$', views.UserList.as_view()), And the View itself class UserList(generics.ListCreateAPIView): queryset = User.objects.all() serializer_class = UserSerializer When i try to access /dashboard/users/?page=1 I get a 404 error with the following urls in the debug mode: ^dashboard/users$ ^dashboard/users\.(?P<format>[a-z0-9]+)/?$ According to the Django rest frameworks's pagination docs: Pagination is only performed automatically if you're using the generic views or viewsets. If you're using a regular APIView, you'll need to call into the pagination API yourself to ensure you return a paginated response. See the source code for the mixins.ListModelMixin and generics.GenericAPIView classes for an example. I am already using generic views here, then why doesn't this work? -
How to render a Matplotlib plot in a Django web application?
I'm reading the book Matplotlib for Python Developers but am struggling to follow the example in the section "Matplotlib in a Django application" in chapter 8. So far, I've issued the command django-admin startproject mpldjango and, in the mpldjango directory, python manage.py startapp mpl As per the example, in mpldjango/mpl I've made the views.py as follows: import django from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure import numpy as np def mplimage(request): fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(111) x = np.arange(-2,1.5,.01) y = np.sin(np.exp(2*x)) ax.plot(x, y) response=django.http.HttpResponse(content_type='image/png') canvas.print_png(response) return response Next, the book says that the mpldjango/urls.py should have this line added to it: urlpatterns = patterns('', (r'mplimage.png', 'mpl.views.mplimage'), ) However, I don't see how this would work since in the 'default' urls.py, urlpatterns is a lits of django.conf.urls.url objects: from django.conf.urls import url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), ] and there is no patterns constructor defined. Perhaps this book (which is from 2009) is referring to a legacy Django API? If so, how would I modify this code to make it work? (That is, after python manage.py runserver I should be able to browse to localhost:8000/mplimage.png and see an image … -
STAThread attribute for Python
I'm calling a COM object from a Python application (see below). If I run in debug mode with a point break on line: xlsapp = win32com.client.Dispatch("Excel.Application") and then continue, everything works well, but if I try to run the application, I get the same error: 'CoInitialize has not been called'. I have tried to find a solution on stackoverflow and it seems (Coinitialize has not been called) that I need to put a STAThread attribute. How do we handle that in Python 3.5? Do you suggest another approach? Many thanks in advance for your help. Gilles import win32com.client from pathlib import Path from FundBook_v3.utilities import * import datetime import numpy as np import os import FundBook_v3.settings class OnePager: def __init__(self, ratio, matBenchstat, style_drift_results, vecMthDates, matVami, qualInfo, quantInfo, sorted_AUMs, file_name): # We need to put the path part in constant files my_file = Path(os.path.join(FundBook_v3.settings.STATIC_ROOT, 'b_up_fd/xlsx_templates/'+file_name)) # Open an excel server xlsapp = win32com.client.Dispatch("Excel.Application") if my_file.is_file(): eWorkbook = xlsapp.Workbooks.Open(my_file) xlsapp.Visible = 0 # just for test purpose xlsapp.Worksheets("data").Activate() eSheets = xlsapp.ActiveWorkbook.ActiveSheet ... -
How to reduce brackets in nested JSON in Django Rest
I'm solving the problem with Django Rest Framework. The issue is too many brackets in my nested JSON. This is my output: [ { "1": { "name": "Company 1", "data": [ { "1": { "name": "Place brno", "data": [ { "2": { "name": "Device 1", "data": [ { "5": { "name": "revize 5", "category": 0 } }, { "6": { "name": "rev rev", "category": 0 } } ] } }, { "4": { "name": "Device 3", "data": [ { "8": { "name": "revize 4", "category": 0 } }, { "9": { "name": "revize 7", "category": 2 } } ] } } ] } }, { "4": { "name": "Place r", "data": [ { "3": { "name": "Device 2", "data": [ { "3": { "name": "revize 2", "category": 2 } }, { "4": { "name": "revize 3", "category": 3 } }, { "11": { "name": "revision 33", "category": 0 } } ] } } ] } } ] } } ] But I need something like this: [ { "1": { "name": "Company 1", "data": { "1": { "name": "Place brno", "data": { "2": { "name": "Device 1", "data": { "5": {...}, "6": {...} } }, "4": { "name": "Device 3", … -
How to create a user who can create another user but not grant permissions(only grant predefined group permissions) in django?
I want to be able to create a user (in openwisp2 which is django based), who in turn, can create another user but not be able to grant individual permissions for this user. Only only granting predefined group permissions should be allowed for this new user. When I gave user add permission to a user, I saw that this user gets the 'permission add' option by default(eventhough I have not granted the 'permission adding' permission for this user). I observed that this new user had the privilege to create a superuser aswell(which was quite surprising) -
Django long request timeout
I have a view in a Django application that take as input a large csv file, it cycle all the rows and insert datas on DB. Locally I have no problem but when I deploy my proj online the view give me back a timeout after some time. My webserver configuration is Nginx + Gunicorn. I tried to increase timeout on Gunicorn and proxy_connect_timeout, proxy_read_timeout on Nginx by writing a large number (120000) and now is better, I get timeout after about 90 seconds instead of 30 (default for Gunicorn) but still is not what I expected, and it's not enough to finish my job. Also I don't like so much this approach, I don't want infinite timeout for every request. What's the best approach to deal with long request and not have timeout? Maybe by answering to user with a message and then run the job in background? Any suggestion? Thanks. -
I am new to django web framework, Is there any web application sample demo available to understand flow which have login and user details?
I am new to django web framework, Is there any web application sample demo available to understand flow which have login and user details ? -
ssl.SSLEOFError while sending emails through Django in AWS
I have some weird behavior when I try to send an e-mail (async) with Django. I really wanted to avoid third-party apps being installed to reduce code fragmentation - specially with some of them that seem to use crontab. It is worth noticing that the error doesn't happen all the time. However, even though it doesn't happen, sometimes e-mails are not sent either. On my development environment it runs fine, and I can send the e-mails. However, on my production environment (EC2 instance) it simply doesn't work. If I trigger an e-mail through the normal process, it is not sent. If I login to the server, open the manage.py shell, import a project and call the function that sends e-mail, sometimes I receive both triggered and manually-triggered e-mails or get an error (the one bellow). Settings EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' DEFAULT_FROM_EMAIL = EMAIL_HOST_USER = 'no_reply@domain.com' SERVER_EMAIL = 'no_reply@domain.com' DEFAULT_DO_NOT_REPLY = 'User <no_reply@domain.com>' EMAIL_HOST_PASSWORD = 'xxxxxxxxx' EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = EMAIL_HOST_USER Class class EmailThread(threading.Thread): def __init__(self, subject, context, recipient, template): self.subject = subject self.recipient = recipient self.message = get_template(template).render(context) threading.Thread.__init__(self) def run(self): msg = EmailMessage( subject=self.subject, from_email=settings.DEFAULT_DO_NOT_REPLY, to=self.recipient, body=self.message ) msg.content_subtype = "html" try: msg.send(fail_silently=False) … -
Keras predict not returning inside celery task
Following Keras function (predict) works when called synchronously pred = model.predict(x) But it does not work when called from within an asynchronous task queue (Celery). Keras predict function does not return any output when called asynchronously. The stack is: Django, Celery, Redis, Keras, TensorFlow -
Attrs argument doesn't work in URLColumn (Django-tables2)
I'm trying to create a column which points to related user. I've decided to try URLColumn. Text attribute works correctly but when I try to add href url, it renders <a href="None">Text</a>. Do you know where is the problem? class PossiblePairsTable(tables.Table): customer_one = tables.URLColumn(attrs={'href':'somehref'},text=lambda x: x.reservation_one.customer.userprofile.display_name,) -
Keeping count of clicks of <a> tag (non-JS)
In a Django mobile web app I'm building, I'm using the sms html tag in one particular template. I.e. the typical <a href="sms:/* phone number here */?body=/* body text here */">Link</a>. Every time the user presses Link, they're redirected to their phone's default SMS app with a prepopulated message. Is there any way one can store a counter of how many users clicked Link? The challenge is to solely use Python/Django (server-side), no JS. What would one do? Need some creative, low-cost solutions to this. -
django annotating value with model field name
I have the following model class Status(object): FIRST_STATUS = 'FS' SECOND_STATUS = 'SS' CHOICES = ((FIRST_STATUS, 'First Status'), (SECOND_STATUS, 'Second Status') class MyModel(models.Model): status = models.CharField(max_length=2, choices=Status.CHOICES) I'm trying to annotate the status field so that the results will hold the readable value and not the status code. This is what i was trying to do: MyModel.objects.annotate(status=Case(When(status=Status.FIRST_STATUS, then='First Status'), When(status=Status=SECOND_STATUS, then='Second Status'), output_field=CharField())).values('status') The result was an exception: ValueError: The annotation 'status' conflicts with a field on the model. Which was not surprising because of this but what is, is that i can do this: MyModel.objects.extra(select={'status': "CASE WHEN status='FS' THEN 'First Status' WHEN status='SS' THEN 'Second Status' ELSE 'Unknown status' END"}).values('status') Why put the restriction on annotate and not validate the same behavior in extra? Is there any way of overriding the restriction on annotate and save me of building the query manually? -
Django rest framework how to ignore an object within a serializer function
I'm using celery with django / django-rest-framework. And I'm using tensorflow as well. Now for a session problem with tensorflow, I need to initialise sessions before the celery workers are called. Thus, I tried to do it from the view, but then I have to initialise a class containing a specific script. It looks like that: def perform_create(self, serializer): instance = serializer.save( state=app_models.Video.STATE_PROCESSING_QUEUED, agency=self.request.user.agency ) sess_det = tf.Session() sess_clf = tf.Session() ED = Emotion_Detector(sess_det, sess_clf) app_tasks.process_video.delay(instance.id, ED) sess_det.close() sess_clf.close() which is within a class based view: class VideoProcessingViewSet( CreateModelMixin, RetrieveModelMixin, GenericViewSet ): .... But then, when I try to run celery I have this error: kombu.exceptions.EncodeError: Object of type 'Emotion_Detector' is not JSON serializable How can I ignore the Emotion_Detector? Is there a way not to serialise it? -
Try to run crontab without success
I have project in django and I'm trying to run my crontask: Here is my code in crontab: 30 12 * * * cd /path/to/file/in/project/apps && python import.py but this code doesn't works for me. Please for any hint. Thanks a lot. -
Creating a price calculator function in a Django model
I have this: Class OrderService(models.Model): article_deadline = models.IntegerField() article_pages= models.IntegerField() def price_calc(self): if OrderService.article_deadline <= 12 unit_price = 35 elif OrderService.article_deadline>= 13 <= 24 unit_price= 30 else: unit_price= 25 price_calc() return unit_price total_cost = article_pages * unit_price It gives an error that unit_price is not defined. I need when the user enters article_deadline in the form, the function determines the unit cost to use and then calculates total_cost. I think I am missing something very simple, but I have to finish it asap without delay. Thank you -
Django update or create ValueError: invalid literal for int() with base 10: ''
I am getting the below error when an update is triggered on the update or create method. this only just started happening when one of the status of the VPNs I monitor went from service_status to red and vpn_count to 0. im not sure why this is erroring, I have outputted each variable I thought might be an issue and they all look good to me. can anyone help? Thanks def vpn_status(id, conn): vpn_data = conn.describe_vpn_connections(VpnConnectionIds=[id]) # iterate the json objects and set variables for vpn in vpn_data['VpnConnections']: service_name = vpn['Tags'][0]['Value'] print service_name vpn_count = 0 for v in vpn['VgwTelemetry']: if v['Status'] == 'UP': vpn_count += 1 vpn_service_status = '' if vpn_count == 0: vpn_service_status = 'red' elif vpn_count == 1: vpn_service_status = 'amber' else: vpn_service_status = 'green' received_routes = re.sub("[^0-9]", "", vpn['VgwTelemetry'][0]['StatusMessage']) # check timestamps service_time = timestamp(service_name, vpn_service_status) print service_time print vpn_service_status print vpn_count # create or update records print AWSService.objects.update_or_create( defaults={ 'service_name' : service_name, 'service_status' : vpn_service_status, 'vpn_count' : vpn_count, 'received_routes' : received_routes, 'last_change' : service_time, 'timestamp' : datetime.now().strftime("%Y-%m-%d %H:%M:%S") }, service_name = service_name ) return 'service updated' >>> vpn_status('vpn-123456789',live_ldn_ec2) LDN-LIVE-VPN 2017-07-26 12:23:58 red 0 Traceback (most recent call last): File "<console>", line 1, in <module> File … -
creating menu like https://docs.influxdata.com in django
I am developing a site on Django (first time using). I am trying to make a menu like https://docs.influxdata.com/ . When we chose an option from the menu, we see the text of the option is overwritten in place of “Select a Product”. I used dropdown button to make this with the following code. <ul class="nav" id="top-menu"> <li> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-bar-chart-o fa-fw"></i> Platforms <span class="caret"></span></a> <ul class="dropdown-menu" > {% platforms as platforms %} {% for platform in platforms %} <li ><a href="/platform /{{ platform .name }}">{{platform .name}} </a></li> {% endfor %} </ul> </li> </ul> I used the following javascript, to change the text of the "Platform" to the option selected. $(function () { $(".dropdown-menu li a").click(function () { $(".btn:first-child").text($(this).text()); $(".btn:first-child").val($(this).text()); }); }); When i clicked the button, it changed the text on it but when the url changes according to the href, the previous text "Platform" appears again. I understand now,I should create a view for the menu in django. Since i am generating menu by tempaltetags from django import template register = template.Library() @register.assignment_tag def platforms(): platforms= Platform.objects.values() return platforms; Can anyone suggest me what is the best way of creating a menu like https://docs.influxdata.com/ … -
define database modelwise in django
I just tried to find a solution for define database model wise in Django. like in my settings.py there are three databases settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'db_one': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db_one.sqlite3'), }, 'db_two': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db_two.sqlite3'), }, } And in my polls/models.py class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question_text def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) @python_2_unicode_compatible class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice_text now i want to add question model in db_one database and Choice model in db_two database so how can i do that i try with routers follow this multiple databases and multiple models in django but it prefer only default database only after that i tried with put blank setting in default databse and try ti migrate but it gives me an error -
how to use command line arguments with python manage.py
error when i run this command python manage.py shell <processing.py 66 i think its not the right way to pass arguments while using shell. i cannot directly write python processing.py because i am using database filtering and so i have to use shell. this is my processing.py import os import sys from webapp.models import status dirname = sys.argv[1] print(os.getcwd()) sta = status.objects.filter(status_id=66)[0] sta.status = True sta.save() print(sta.status) thanks in advance -
Docker-compose can't find .env file
I have 3 containers with postgresql, nginx and django. The last two have their own Dockerfile, I run whole system with docker-compose. I have multiple problems: I can't run my custom nginx container, named nginx with build: ./nginx/. only image: nginx. Yes, I try docker-compose build as was suggested in thread. Strange behavior with volumes, I mentioned theese one: - ./web:/code and nothing work, i commented it, but now Django said me: /usr/local/lib/python3.5/site-packages/environ/environ.py:609: UserWarning: /code/translation_microservice/.env doesn't exist - if you're not configuring your environment separately, create one. "environment separately, create one." % env_file) Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute django.setup() File "/usr/local/lib/python3.5/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models() File "/usr/local/lib/python3.5/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/usr/local/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 673, in _load_unlocked File "", line 673, in exec_module File "", line 222, in _call_with_frames_removed File "/code/api_controller/models.py", line 8, in from web.translation import TranslatedLesson, TranslatedStep ImportError: No module … -
how to deploy djnago app on google app engine and making connection with postgres instance?
currently i am trying to deploy django app on google app engine(gae). all goes well and app deploys. but when its deploys its connection with postgres instance lost. i dont know why this happening. following is my setting.py file. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'dbname', 'USER': 'username', 'PASSWORD': 'password', } } # In the flexible environment, you connect to CloudSQL using a unix socket. # Locally, you can use the CloudSQL proxy to proxy a localhost connection # to the instance DATABASES['default']['HOST'] = '/cloudsql/shopnroar-175407:us-central1:snr-instance1' if os.getenv('GAE_INSTANCE'): pass else: DATABASES['default']['HOST'] = '100.107.126.241' when i run locally, its make connection with google cloud postgres as i have gien ipv4 address to make connection. but as soon as i deploy it on GAE folling error comes when i try to access database. Is the server running locally and accepting connections on Unix domain socket "/cloudsql/shopnroar-175407:us-central1:snr-instance1/.s.PGSQL.5432"? here is my app.yaml # [START runtime] runtime: python env: flex entrypoint: gunicorn -b :$PORT SNR.wsgi env_variables: # Replace user, password, database, and instance connection name with the values obtained # when configuring your Cloud SQL instance. SQLALCHEMY_DATABASE_URI: >- postgresql+psycopg2://amad.uddin:goingtoin1122@/shopnroar?host=/cloudsql/shopnroar-175407:us-central1:snr-instance1 beta_settings: cloud_sql_instances: shopnroar-175407:us-central1:snr-instance1 runtime_config: python_version: 2 # [END runtime] can anybody tell me how can … -
override form's clean method to customize error messages
I'm having trouble overriding clean method of a built-in Django form (django.contrib.auth.SetPasswordForm). This form has two fields: new_password1 and new_password2. so in my views.py I call the customized form (MySetPasswordForm): def reset_confirm(request, uidb64=None, token=None): return password_reset_confirm_delegate(request, template_name='app/reset_confirm.html', set_password_form = MySetPasswordForm, uidb64=uidb64, token=token, post_reset_redirect=reverse('main_page')) In my forms.py: I want to define my own clean method to show my customized error messages. here's how I wrote MySetPasswordForm: from django.contrib.auth.forms import SetPasswordForm class MySetPasswordForm(SetPasswordForm): error_messages = { 'password_mismatch': _("Missmatch!"), } def clean(self): password1 = self.cleaned_data.get('new_password1', '') password2 = self.cleaned_data.get('new_password2', '') print password1 #prints user's entered value print password2 #prints nothing!! print self.data['new_password2'] #prints user's entered value if password1 == '': self._errors["new_password1"] = ErrorList([u"enter pass1!"]) if password2 == '': self._errors["new_password2"] = ErrorList([u"enter pass2"]) elif password1 != password2: raise forms.ValidationError( self.error_messages['password_mismatch'], code='password_mismatch', ) return self.cleaned_data The problem is that when the user enter the repeat password wrong, instead of getting "Missmatch" error, it gives "enter pass2"! Also print password2 doesn't print user's entered value for password2. What am I doing wrong in this code?! and what is the best way to do customized error messages? p.s. using the original SetPasswordForm in the view works fine. -
Django rest specific attribute for multiuser model
I use a Django Rest Framework. I have a Task model (multiuser). All fields for it - available for all members of this Task. But one field - is_important - is specific for each user. What the right way set this property for specific user? I think about M2M field (is_important_users), where I will add a users. But perhaps exist a more elegant way? Thanks a lot.