Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Selenium and django debug toolbar
My website with Django 1.11.1 and Django debug toolbar 1.8 runs fine on my development server (vagrant/gunicorn/nginx). My regular test suite runs fine. However, when I tell it to run the selenium tests, it dies with a 'djdt' is not a registered namespace error. I have the appropriate entries in urls, middleware, and config. If I curl localhost, it returns the home page with the debug toolbar in it. If I set the toolbar not to show with the show_toolbar code, my selenium tests still crash, but the website still works fine (and doesn't show the debug toolbar). Thoughts on how I can get my selenium tests to run? > python manage.py test ann.selenium Creating test database for alias 'default'... Installed 8 object(s) from 1 fixture(s) Installed 3 object(s) from 1 fixture(s) Installed 2 object(s) from 1 fixture(s) Installed 16 object(s) from 7 fixture(s) Installed 6 object(s) from 1 fixture(s) Installed 1 object(s) from 1 fixture(s) Adding auth tokens for the API... System check identified no issues (0 silenced). Internal Server Error: / Traceback (most recent call last): File "/home/vagrant/.virtualenvs/ann/lib/python3.5/site-packages/django/urls/base.py", line 77, in reverse extra, resolver = resolver.namespace_dict[ns] KeyError: 'djdt' During handling of the above exception, another exception occurred: Traceback … -
In django, how generic view works
I have started learning django, I'm not sure how generic view works. I read django documentation several times, I can't gain clear understanding of how generic view works. Very strange but it works well. It retrieves data from the database and renders data on the browser. Here is snippet code of polls/urls.py. url(r'^$', views.IndexView.as_view(), name = 'index') It will go to the IndexView class in views.py. Here is snippet code of polls/views.py. from django.views import generic from .models import Question, Choice class IndexView(generic.ListView): template_name = 'polls/index.html' context_object_name = 'latest_question_list' def get_queryset(self): return Question.objects.order_by('-pub_date')[:5] When I change template_name as something, the exception has occurred as follows. TemplateDoesNotExist: polls/question_list.html What does question_list.html mean? Where does it come from? And here is index.html. {% if latest_question_list %} <ul> {% for question in latest_question_list %} <li> <a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a> </li> {% endfor %} </ul> {% else %} <p>No polls are available.</p> {% endif %} As you can see, index.html file use latest_question_list as a parameter. In views.py file, what does context_object_name = 'latest_question_list' mean? Where does the 'list_question_list' come from and how can index.html use list_question_list? Do I use context_object_name in views.py? What's the role of the get_queryset() function? -
Wagtail per page user permission
My task is to enable users to edit their own page. I see how to give permissions to a particular page to a group, but how do I do this for the user? I'd tried use django guardian: UserObjectPermission.objects.assign_perm('change_custompage', user, obj=custompage) but this wasn't given me results I also found the wagtailcore_grouppagepermission table and realized that the permissions principle is not the same as used in django auth_permission I want to give permissions to edit, and access wagtail admin, I do not need anything else In this particular task, wagtail I need because of the struct_blocks, I think this is a terrific concept. Now I see two options: either an override template and the ability to use all the power of the struct_block outside the wagtail, or something to solve with permissions. -
Many-to-Many Relationships through 3-way Legacy Junction Table in Django
With a legacy database where the many-to-many relationships between projects, the people in the projects, and their roles in that project are represented through a three-way junction table like so: How would one represent this data in with Django models? I'm trying to write a model where project.manager would return a list of person instances that are paired with the manager role for that project_id. So far, the closest I've gotten is using models.ManyToManyField through two of different fields in Rolepersonproject, but that only gives me the roles and people associated with that project, not what roles those people played. How would I do this? Is this a job for custom managers, the ManyToManyField, model methods, or custom SQL? manage.py inspectdb gave me model classes like these to work with: class Project(models.Model): project_id = models.AutoField(db_column='project_id', primary_key=True) class Role(models.Model): role_id = models.AutoField(db_column='role_id', primary_key=True) class Person(models.Model): person_id = models.AutoField(db_column='person_id', primary_key=True) class Rolepersonproject(models.Model): project_id = models.ForeignKey(Project, models.DO_NOTHING, db_column='project_id') role_id = models.ForeignKey(Role, models.DO_NOTHING, db_column='role_id') person_id = models.ForeignKey(Person, models.DO_NOTHING, db_column='person_id') -
Does post_save hook runs immediately after creating model in Django?
I have post_save method which needs pk. def create_key(instance=None, sender=None, created=False, **kwargs): if created: last_index = instance.pk instance.private_key = cipher.encrypt(instance.private_key) instance.save() Before calling it I assign self.private_key not encrypted private_key. Question: Can attacker get not encrypted private_key from DB in time period between save method and post_save? -
django forms do not always save changes to the database
I am working on a django app that has a postgresql backend. I have a python script that goes through a process that ultimately launches several web forms, one for each record in a table in the database that needs to be modified. The script iterates over a list of IDs to determine which records need to be modified and launches the forms all at once. I notice that some of the forms will accept and save changes, whereas some of the forms do not save the changes. I also notice with a form that initially saves changes, if I reload the form and try to make additional changes, those do not get saved. I'm not sure what is wrong? New to using django. Here is the html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'update/css/forms.css' %}" /> </head> <body> {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} <div><label class="page_header">{{title}}<label><div> <form method="POST" action=""> <div><fieldset class="fieldset"> <legend class="legend">Create Map Index Record</legend> {% csrf_token … -
How to pass Django forms from jQuery/Ajax function to Django templates?
I have a comments section on my website. The comments posted have an option to reply. Upon selecting the option reply, a form appears as shown below. Upon selecting the option reply, The problem here is that, I am using Ajax calls to post a comment. While posting a comment, I should be able to render the reply form to the newly posted comment. I tried passing it through the views, the one where comments are handled for each of the Ajax calls made, but it throws an error : views.py : def add_comment(request): comment_form = CommentForm(request.POST or None) // Created a new comment form if request.POST: input_comment = request.POST.get("input_comment") content_type = "post" content_type = ContentType.objects.get(model=content_type) object_id = request.POST.get("object_id") content_data = input_comment parent_object = None parent_qs = None try: parent_id = int(request.POST.get("parent_id")) except: parent_id = None if parent_id : parent_qs = Comments.objects.filter(id = parent_id) if parent_qs.exists() and parent_qs.count() == 1 : parent_object = parent_qs.first() new_comment = Comments.objects.get_or_create( user = request.user, content_type = content_type, object_id = object_id, content = content_data, parent = parent_object ) timestamp = created_comment.timestamp month = timestamp.strftime("%B") day = timestamp.strftime("%d") year = timestamp.strftime("%Y") hour = timestamp.strftime("%H") mins = timestamp.strftime("%M") secs = timestamp.strftime("%S") commented_on = day + " " … -
In Django, how can I avoid cascade deletions when using a GenericRelation?
According to the Django Docs, if I add a GenericRelation to my model, then when an instance of that model is deleted, it will cascade-delete anything with a GenericForeignKey pointing to it. I need the querying benefits of having a GenericRelation, but I do NOT want it cascade-deleting stuff (I can't believe potentially-catestrophic behavior is what the django people selected as the default...). Both the GenericRelation class and the GenericForeignKey class do not accept an on_delete param for customizing the behavior. Is there a way I can avoid the cascade deletion? The docs suggest possibly using the pre_delete signal, but the docs for that are skimpy so it's unclear how that can help me... -
django: filtering with multiple criteria without losing other fields?
My model looks like so: Each Bottle has an attribute name, and a relationship to Brand. In one of my views, I want to show a user all distinct bottles, and their counts. A distinct bottle is a bottle that has the same name attribute, and the same Brand relationship. So this table: Should display 2 lines instead of 3, with the proper quantities (1 for Eitan, 2 for Almon). The following line in my views.py: object = Bottle.objects.filter(brand__business__owner_id=user.id).all().values('name').annotate(Count('brand')) Produces this when I print object: <QuerySet [{'name': 'Almon', 'brand__count': 2}, {'name': 'Eitan', 'brand__count': 1}]> Which seems to be the right direction, but it has two problems: I lose all other fields (vintage, capacity) except name and brand__count. I can of course explicitly add them to values, but that seems a) upythonic b) that it will group_by these items as well! My pug template complains: Need 2 values to unpack in for loop; got 1 (this is because I'm iterating through them as a list, and using its index for numbering) Any help is appreciated! -
CSRF verification failed. Request aborted. {% csrf_token %} in django python3 html
I am trying to do a log in in django/python. I have this @csrf_exempt def Principal(request): context = {} if request.method != 'GET': context = { 'title': '405 Method Not Allowed', } if request.user.is_authenticated(): logged_q = 'Logged in as '+ request.user.username logged = True else: logged_q = 'Not logged in.' logged = False print (logged_q) top_aparcamientos = Aparcamiento.objects.all() #top_aparcamientos = Comentario.objects.all().order_by('-aparcamiento__id').unique()[:5] pagina_list = Pagina.objects.all() context['top_aparcamientos'] = top_aparcamientos context['pagina_list'] = pagina_list usuario = request.user.username context = { 'usuario' : usuario, 'logged' : logged } return render_to_response('index.html', context So, for do my template, I take the variable logged in my base.html like that: {% if logged %} <div class ="container_corner"> <div class="topright"> <span id="corner_message"><strong>Bienvenido,</strong>&nbsp<span class="oblicuo">{{usuario}}</span></span> <a href='logout/'><button id="logged"type="submit">Salir</button></a><br> </div> </div> {% else %} <form id="login_form" action="login/" method ="POST"> {% csrf_token %} <label for="id_username"><span class="login_fields">Nick: </span></label> <input id="id_username" maxlength="254" name="username" type="text" /> <label for="id_password"><span class="login_fields">Contraseña: </span></label> <input id="id_password" name="password" type="password" /> <button type="submit">Login</button> </form> {% endif %} But it gives me this error when I try to log in: Forbidden (403) CSRF verification failed. Request aborted. Help Reason given for failure: CSRF token missing or incorrect. Do I need anymore {% csrf_token %}? Where? Thank you! -
how to update unique field for multiple entries in django
I have a simple Django model similar to this: class TestModel(models.Model): test_field = LowerCaseCharField(max_length=20, null=False, verbose_name='Test Field') other_test_field = LowerCaseCharField(max_length=20, null=False, unique=True, verbose_name='Other Test Field') Notice that other_test_field is a unique field. Now I also have some data stored that looks like this: [ { test_field: "object1", other_test_field: "test1" }, { test_field: "object2", other_test_field: "test2" } ] All I'm trying to do now is switch the other_test_field fields in these two objects, so that the first object has "test2" and the second object has "test1" for other_test_field. How do I accomplish that while preserving the uniqueness? Ultimately I'm trying to update data in bulk, not just swapping two fields. Anything that updates data in serial is going to hit an IntegrityError due to unique constraint violation, and I don't know a good way to remove the unique constraint temporarily, for this one operation, before adding it back. Any suggestions? -
Django-Report-Builder: DjangoUnicodeDecodeError byte 0x80
I am developing a django site that will query a legacy db and return data. In the django admin panel everything works perfectly. I have installed django-report-builder, and it can query most of the data but there are a couple models that give me the DjangoUnicodeDecodeError I have scoured the interwebs and I believe I found the problem: It seems that my environment locales are mismatched. What I am looking for is a way to change the django server's default locale settings. Unfortunately I cannot find this anywhere. Any Help please????? Details: I am running up to date debian and am basically running an out of the box django Traceback Error: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 42, in inner response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 489, in dispatch response = self.handle_exception(exc) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 449, in handle_exception self.raise_uncaught_exception(exc) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 486, in dispatch response = handler(request, … -
Count entries per day and output in Google Chart
I want to create a graph of entries (articles) per day, using the Google Graph. Looking at their example, I need to output something like this from the Django DB. var data = google.visualization.arrayToDataTable ([['Year', 'Sales', 'Expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540], ]); DB Layout from the table Articles ID | name | pub_date | -- | -----------| ---------------------| 1 | Article T1 | 2017-05-17 18:31:09 | -- | -----------|----------------------| 2 | Article T2 | 2017-05-19 20:52:00 | I tried to do it in SQL but it doesnt group that well select CAST(publication_date AS DATE),count(id) as count from news_article GROUP BY CAST(publication_date AS DATE) How would I group correctly in SQL and make so it works with Google Graph? I'm very new to Django. -
django translation.activate() inside function
I have all strings already translated in django.po files and I want to send email in user current language. Translation system works fine except this part. Because it doesn't work as expected I'm trying to use translation.activate(lang) to get string translated in current language but it doesn't work. Here is situation: from django.utils.translation import ugettext_lazy as _ from django.utils import translation TEMPLATES = [ (DEFAULT_REPLY, _("There was a reply to your post:") + " %URL% "), (DEFAULT_INVITE, _("You are invited to: ") + " %URL% ") ] def get_template(template_type): cur_language = translation.get_language() translation.activate(cur_language) template = [item for item in TEMPLATES if item[0] == template_type][0][1] return template Both ugttext_lazy and ugettext provide the same result. Function return English string in both cases. In settings I have LANGUAGE_CODE = 'en-us' LANGUAGES = ( ('en', ugettext('English')), ('fr', ugettext('French')), ('es', ugettext('Spanish')), ) -
Django - How to add sender-name in Email?
What I am trying to achieve is having the senders-name, from the current logged in user with the association name, to show up in the receivers inbox like so: 'associaton-name'@domain.com I have commented it down below where i tried to achieve it in views.py Can't seem to find any related solutions after days and hours of work. Really appreciate your help, folks! Django: 1.10 Python: 3.6 views.py class mailPost(FormView): success_url = '.' form_class = mailHandler template_name = 'post/post.html' def form_valid(self, form): messages.add_message(self.request, messages.SUCCESS, 'Email Sent!') return super(mailPost, self).form_valid(form) def form_invalid(self, form): messages.add_message(self.request, messages.WARNING, 'Email not sent. Please try again.') return super(mailPost, self).form_invalid(form) def post(self, request, *args, **kwargs): form_class = self.get_form_class() form = self.get_form(form_class) if form.is_valid(): sender = "noreply@domain.com" # Instead of noreply I wish for current requested associaton name receiver = form.cleaned_data.get('receiver') cc = form.cleaned_data.get('cc') bcc = form.cleaned_data.get('bcc') subject = form.cleaned_data.get('subject') message = form.cleaned_data.get('message') time = datetime.now() asoc_pk = Association.objects.filter(asoc_name=self.request.user.association) asoc = Association.objects.get(id=asoc_pk) Email.objects.create( sender=sender, receiver=receiver, cc=cc, bcc=bcc, subject=subject, message=message, association=asoc, sentTime=time ) msg = EmailMultiAlternatives(subject, message, sender, [receiver], bcc=[bcc], cc=[cc]) msg.send() return self.form_valid(form) else: return self.form_invalid(form) models.py class Email(models.Model): sender = models.CharField(max_length=254) sentTime = models.DateTimeField(auto_now_add=True, blank=False) subject = models.CharField(max_length=254) receiver = models.CharField(max_length=254) cc = models.CharField(max_length=254) bcc = models.CharField(max_length=254) message … -
Correct usage of prefetch_related and Prefetch in django
I have the following models: class Goal(Model): id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # title of the goal title = CharField(verbose_name=_('Name'), max_length=256) is_quantitative = BooleanField(verbose_name=_('Quantitative?'), default=False) authors = ManyToManyField(Expert, related_name='goals', related_query_name='goal') problem = ForeignKey(Problem, related_name='goals', related_query_name='goal') # decomposition of the goal decomposition = OneToOneField('Decomposition', related_name='goal', null=True, blank=True) children = ManyToManyField('self', related_name='influences_on', related_query_name='influence_on', through='DecompositionGoal', symmetrical=False) # level of the goal in decomposition tree level = PositiveSmallIntegerField(default=0) create_date = DateTimeField(auto_now_add=True) @python_2_unicode_compatible class Decomposition(Model): id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False) create_date = DateTimeField(auto_now_add=True) stage = CharField(max_length=2, choices=STAGE_CHOICE, default=ADD_GOALS) goals_grouping_method = CharField(max_length=2, choices=METHODS_FOR_GOALS_GROUPING, blank=True) goals_voting_method = CharField(max_length=2, choices=METHODS_FOR_GOALS_VOTING, blank=True) experts = ManyToManyField(Expert, through='DecompositionExpert') organizers = ManyToManyField(Organizer, through='DecompositionOrganizer') class DecompositionExpert(Model): id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False) decomposition = ForeignKey(Decomposition) stage = CharField(max_length=2, choices=STAGE_CHOICE) expert = ForeignKey(Expert, related_name='decomposed_by') # this doesn't delete an expert, just deactivates it is_active = BooleanField(default=True) class Meta: unique_together = (('decomposition', 'expert', 'stage'), ) ordering = ('expert', ) class DecompositionGoal(Model): id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False) parent = ForeignKey(Goal, related_name='related_src') child = ForeignKey(Goal, related_name='related_dst') # storing author here, since goal can be reused (this is author of goal choice, either new or reused) author = ForeignKey(Expert, null=True, blank=True) What I want to accomplish is to prefetch DecompositionExpert with DecompositionGoals where that expert is author (either list, … -
django.setup() throws "ImportError: cannot import name update_contenttypes"
Traceback: Traceback (most recent call last): File "my_script.py", line 16, in <module> django.setup() File "c:\Python27\lib\site-packages\django\__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "c:\Python27\lib\site-packages\django\apps\registry.py", line 85, in populate app_config = AppConfig.create(entry) File "c:\Python27\lib\site-packages\django\apps\config.py", line 112, in create mod = import_module(mod_path) File "c:\Python27\lib\importlib\__init__.py", line 37, in import_module __import__(name) File "c:\Python27\lib\site-packages\django\contrib\contenttypes\apps.py", line 7, in <module> from .management import update_contenttypes ImportError: cannot import name update_contenttypes The script used to run fine until I attempted to update django-allauth (which updated a ton of other packages: pytz, requests, oauthlib, requests-oauthlib, and Django (though I Ctrl-C'd when it started wanting to update Django. I am using Django 1.8.5) Please help Thanks in advance -
Integrating Django and openui5
I want to use openui5 with django applications. There is no information about it. It's unclear how to use ui5 routing with django urls.py. Perhaps someone has to experience this? -
Django Unit tests for forms
Let's assume that I've a form defined as: class NumbersABForm(forms.Form): a = forms.FloatField(required=False) b = forms.FloatField(required=False) def clean(self): if self.cleaned_data['a'] < self.cleaned_data['b']: raise ValueError('a < b') I want to define unit test cases for this form as follows: class NumbersABFormTest(TestCase): def test_invalid(self): try: form = NumbersABForm({ 'a': 10.0, 'b': 5.0 }) self.assertFalse(form.is_valid()) except ValueError: self.assertEqual(form.errors, {'a < b'}) Exception is thrown but 'form.errors' is empty. I don't understand how this works. Also, after calling form.is_valid() before which was returning False, calling it again returns True. I don't know how this is possible. Is there something I'm missing? -
Template variable not persistent value
When my MyLoginView encounters an invalid login attempt (wrong username/password) I send a message through django.contrib.messages (invalid_login) and redirect to other view. This view renders this template, part of which is: {% define 'false' as inv_login %} {% if messages %} {% for message in messages %} {% if message.message == 'invalid_login' %} {% define 'true' as inv_login %} {{ inv_login }} --> true {% endif %} {{ inv_login }} --> true {% endfor %} {{ inv_login }} --> false {% endif %} {{ inv_login }} --> false The problem is, that for some reason, the variable inv_login does not hold true throughout the template for some reason. The define tag is: @register.simple_tag def define(value): return value Any idea what causes this strange behaviour? -
Deploying django app with gunicorn and systemd
I am following this guide and this to deploy a django test app of mine. I have this django app at: /var/www/html/django-project/helloapp It works OK when I run it in this way: $ gunicorn helloapp.wsgi:application [2017-05-18 22:22:38 +0000] [1779] [INFO] Starting gunicorn 19.7.1 [2017-05-18 22:22:38 +0000] [1779] [INFO] Listening at: http://127.0.0.1:8000 (1779) [2017-05-18 22:22:38 +0000] [1779] [INFO] Using worker: sync [2017-05-18 22:22:38 +0000] [1783] [INFO] Booting worker with pid: 1783 Below are the steps I have taken. 1. /etc/systemd/system/gunicorn.service: [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] PIDFile=/run/gunicorn/pid User=loutee Group=loutee RuntimeDirectory=gunicorn WorkingDirectory=/var/www/html/django-project/helloapp ExecStart=/var/www/html/django-project/helloapp/env/bin/gunicorn --workers 3 --bind unix:/var/www/html/django-project/helloapp.sock helloapp.wsgi:application ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s TERM $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target I don't quite understand what should I put in for GROUP so I use the same as User: User=loutee Group=loutee Will this causing any problems? 2. /etc/systemd/system/gunicorn.socket [Unit] Description=gunicorn socket [Socket] ListenStream=/run/gunicorn/socket [Install] WantedBy=sockets.target 3. /etc/tmpfiles.d/gunicorn.conf: d /run/gunicorn 0755 loutee loutee - 4. enable the socket and start the service: systemctl enable gunicorn.socket systemctl start gunicorn.socket 5. This is the step I have the problem: curl --unix-socket /run/gunicorn/socket http I get error on printed on my terminal: ... ... ... </tbody> </table> </div> <div id="explanation"> <p> You're seeing this error because you have … -
How to implement a multi-step form in Django admin
My task is to give the opportunity to fill out the form in several steps, processing the result of each step. I found an example of what I need, but this example of 2009 I know about wizard form, but I do not understand how to implement it in Dango admin. I tried to do this: def get_urls(self): urls = super(MyCustomAdmin, self).get_urls() my_urls = [ url(r'^my_view/$', Wizard.as_view([Form1, Form2])) ] return my_urls + urls But got an error: AttributeError at /admin/сustom/custommodel/my_view/ 'NoneType' object has no attribute 'rsplit' Perhaps Wizard formf are not the best option. But I do not know how to implement the task set otherwise -
Nginx not working after docker restart policy = always
My team is using Docker Compose to serve a Django web application. We have one container that serves Django via a Gunicorn web server, and another container that is a reverse http proxy to the first container using Nginx (it also serves static files). We are trying to implement docker's "always" restart policy. Here is the issue: Right after a reboot (or after taking docker engine down and bringing it back up), when we visit our web page in the browser we see a "ERR_EMPTY_RESPONSE localhost didn't send any data" error. A quick "docker-compose ps" shows that both containers are running despite not working as expected. But when we do "docker-compose restart", THEN everything works as expected. I have been inspecting our setup trying to localize the issue, and all I know is that it is an issue with the Nginx container after it is automatically restarted by docker. I mapped a port on my host machine to our Gunicorn container, and I can access the Gunicorn container and that container works as expected after the auto restart. So by process of elimination, it must be an issue with the Nginx container. Here is our docker-compose.yml file. Here is the … -
decoding Unicode is not supported
sign = md5('Помогите, я больше не могу').digest() Exception Type: TypeError Exception Value: decoding Unicode is not supported Пробовал decode, encode и прочие - не помогло -
How to use Pymodm in Django
I've add DATABASE sections like following in Django's settings.py: DATABASES = { 'default': { 'ENGINE': 'pymodm', 'NAME': 'mydb_name', 'USER': 'my_username', 'PASSWORD': 'my_pass', 'HOST': '127.0.0.1', 'PORT': '27017', } } But when run Django's development server with python manage.py runserver, I got a bunch of error messages, but the most noticeable is: conn = backend.DatabaseWrapper(db, alias) AttributeError: module 'pymodm.base' has no attribute 'DatabaseWrapper' How to config Pymodm for Django? Any helps are appreciate. Thanks.