Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Timezone Awareness - Data to be stored in UTC
This is my first time developing a timezone aware web app. I'm using Django 1.11.7. I have looked through many posts regarding timezones and honestly, I'm starting to feel like I just don't understand the concept of timezones... 0_o I'm making a booking app with start_time and end_time for each reservations. I expect the user to be able to enter dates and times as he experiences them in his timezone. On the otherhand, I want these dates and times stored in a postgresql database in UTC format. My Timezone VS UTC If I was choosing to reserve, for example, between Noon and 2pm (today), the result in the database should show between 5pm and 7pm (today). Right? Django Internationalization settings: LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_TZ = True USE_L10N = True USE_I18N = True During database creation: start_time TIMESTAMP WITH TIME ZONE NOT NULL, end_time TIMESTAMP WITH TIME ZONE NOT NULL Using Django's built in admin page feature, I enter the following information: admin page form But when I look up the results in the database, here's what I get: 2017-12-05 19:00:00-05 | 2017-12-05 20:59:59-05 The stored result changed in the opposite direction of what I was expecting. I … -
Why there is another post request after submiting a form in Django?
I am using Django to create a form where users will have to enter their email to get notified in the future. The problem is after successfuly submiting the form I get a post call, that refreshes the page that the form is in: [07/Dec/2017 01:22:41] "POST /notify-email/add/ HTTP/1.1" 200 21 [07/Dec/2017 01:22:42] "POST / HTTP/1.1" 200 23030 Below is the relevant code: views.py def add_notify_email(request): if request.method == "POST": form = NotifyEmailForm(request.POST) if form.is_valid(): form.save(commit=True) return JsonResponse({"status": "success"}) else: return JsonResponse({"status": "error"}) else: form = NotifyEmailForm() return render(request, "landing/home.html", {"form": form}) html <form class="form" onsubmit="addNotifyEmailInHero()" method="POST" id="notify_email_form_in_hero"> {% csrf_token %} <div class="form-group row"> <div class="col-sm-10 input-group" id="email_input_in_hero"> <div class="input-group-addon" id="coming_soon_email_icon_in_hero"><i class="fa fa-envelope fa fa-2x" aria-hidden="true" id="email_icon_in_hero"></i></div> <input class="form-control" type="email" name="email" onkeypress="if(event.keyCode === 13){addNotifyEmailInHero()}" placeholder="If you want to get notified when we go live, please enter your email...." maxlength="255" required id="id_email"/> </div> <div class="col-sm-2" id="notify_email_button_in_hero"> <button type="submit" class="btn btn-block btn-primary" id="submit_notify_email_in_hero"><i class="fa fa-bell nav-icon" aria-hidden="true"></i>Notify Me</button> </div> </div> </form> <script src="coming_soon.js"></script> coming_soon.js function addNotifyEmailInHero(e){ var notifyEmailForm = $("#notify_email_form_in_hero"); var thanksModal = $("#thanks"); $.ajax({ type: 'POST', url: '/notify-email/add/', data: notifyEmailForm.serialize(), success: function(res){ alert(res.status); if(res.status === "success") { thanksModal.modal('show'); } else {$("#id_email").val(""); $("#id_email").attr("placeholder", "Please Enter A Valid Email Address"); } } })} -
Sum averages over date ranges in Django
I'm trying to construct a query in Django that sums averages that were taken (i.e. averaged) over a range of times. Here is the relevant Django model: class Data(models.Model): class Meta: verbose_name_plural = "Data" site = models.ForeignKey(Site) created_on = models.DateTimeField(auto_created=True) reported_on = models.DateTimeField(null=True, blank=True) baseline_power_kw = models.FloatField('Baseline Power (kw)', blank=True, null=True) measured_power_kw = models.FloatField('Measured Power (kw)', blank=True, null=True) In my query, I'm trying to average sites' data over a range of times, and then sum those averages for each range of time. Here is the query I have so far, which I believe just gets the average of all sites' data over a range of times. t_data = Data.objects.filter(site__in=sites) \ .filter(created_on__range=(start, end)) \ .extra(select={'date_slice': "trunc(extract(epoch from created_on) / '60' )"}) \ .values('date_slice') \ .annotate(avg_baseline_power_kw=Avg('baseline_power_kw'), avg_measured_power_kw=Avg('measured_power_kw'), time=Min('created_on')) \ .order_by('-created_on') Do you know how I can proceed? I am using Django with Postgres. Thanks! -
Update django model from background task
I am trying to update a django model from a task using django-background-tasks. Here's what I've got: @background(schedule=0) def difficult_work(): for i in range(0,100): time.sleep(1) with transaction.atomic(): workProgress = WorkProgress.objects.filter(id="fixed_work_id_for_testing").select_for_update().get() print("updating work progress to " + str(i)) workProgress.progress = i workProgress.currentJobInfo = "test work" # if we've finished then make sure to set the status if i == 100: workProgress.status = "success" transfer.save(force_update=True) Additionally, I have an API view to get the progress of a work task. class WorkDetail(APIView): def get(self, request, workId, format=None): with transaction.atomic(): work = Work.objects.filter(id=workId).select_for_update().get() data = WorkSerializer(transfer).data return Response(data) The problem is, I'm not seeing any updates to the database while executing a task. I've got python manage.py dbshell running, monitoring the database tables and they aren't updating as the task progresses. I'm making sure to run python manage.py process_tasks, and it's outputting the correct print statements, indicating progress, but the database doesn't update until the task exits. How do I make sure the table is updated while the task is running? -
Trying to prevent multiple form entries with identical field data (only allow first user to take timeslot)
I am trying to have users enter data in a django form and only allow ONE entry into the database per each time slot and day slot. Example: User fills out form to "sign up" to speak during 8:00am - 9:00am on Day 1 for schedule id 2. If a database entry already exists with the same TIMESLOT and DAYSLOT, I want to raise an error and prevent entry. Here is what I have so far, but the filter is spanning across the entire table rather than just filtering per schedule ID... models.py from django.db import models import datetime class Schedule(models.Model): title = models.CharField(max_length=250) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title class Agenda(models.Model): dayChoice = ( ('d1', "Day 1"), ('d2', "Day 2"), ('d3', "Day 3"), ('d4', "Day 4") ) fullName = models.CharField(max_length=250) startTime = models.TimeField(auto_now=False, blank=True, null=True) endTime = models.TimeField(auto_now=False, blank=True, null=True) approved = models.BooleanField(blank=True) daySlot = models.CharField(max_length=2, choices=dayChoice) sub_date = models.DateTimeField(auto_now=True) scheduler = models.ForeignKey(Schedule, on_delete=models.CASCADE) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.fullName views.py from django.shortcuts import render, redirect from django.utils import timezone from django.shortcuts import render, get_object_or_404 from .models import Schedule, Agenda from .forms import AgendaForm # Create your views here. def schedule_list(request): … -
Django filter icontains - find matches going the other way
In the code below, Django's icontains filter finds matches where the user_input is contained within the name. How do I find matches where the name is contained within the user_input? names = "Jim", "Bob", "James" user_input = "Jimbo" Names.objects.filter(names__icontains=user_input) #returns empty queryset Names.objects.filter(???=user_input) #returns queryset with "Jim" -
Trouble installing Django: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rcF9a5/Django/
I'm trying to install Django via command prompt. I used "pip install Django" but got this message: Collecting Django Using cached Django-2.0.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-rcF9a5/Django/setup.py", line 32, in version = import('django').get_version() File "django/init.py", line 1, in from django.utils.version import get_version File "django/utils/version.py", line 61, in @functools.lru_cache() AttributeError: 'module' object has no attribute 'lru_cache' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rcF9a5/Django/ How do I fix this? -
What is the purpose of adding to IINSTALLED_APPS in Django?
Most documentation simply tells you to add the name of each of your apps to the INSTALLED_APPS array in your Django project's settings. What is the benefit/purpose of this? What different functionality will I get if I create 2 apps, but only include the name of one in my INSTALLED_APPS array? -
Trouble with nginx and django configuration?
I use NGINX+GUNICORN+DJANGO and my gunicorn status is active. I want to set up nginx with django. I create a new file named 'mysite'in /etc/nginx/sites-available server { listen 8000 default_server; listen [::]:8000 default_server; server_name my_ip; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/split/mysite; } location / { include proxy_params; proxy_pass http://unix:/home/split/mysite/mysite.sock; } } saved it and create symbolyc link to /etc/nginx/sites-enabled After that I did sudo service nginx restart and got this: Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. I went to journalctl -xe -- -- Unit nginx.service has finished shutting down. Dec 07 01:05:17 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server... -- Subject: Unit nginx.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nginx.service has begun starting up. Dec 07 01:05:17 ubuntu nginx[49646]: nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory) Dec 07 01:05:17 ubuntu nginx[49646]: nginx: configuration file /etc/nginx/nginx.conf test failed Dec 07 01:05:17 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1 Dec 07 01:05:17 ubuntu sudo[49639]: pam_unix(sudo:session): session closed for user root Dec 07 01:05:17 ubuntu … -
How do I fix my mailgun to Django route "IncompleteRead" error?
Hello I'm trying to test my Mailgun route to send emails through Http Post but I keep getting this error: Post failed: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Here is the sample view I'm using to handle the Post requests: def on_incoming_message(request): if request.method == 'POST': sender = request.POST.get('sender') recipient = request.POST.get('recipient') subject = request.POST.get('subject', '') body_plain = request.POST.get('body-plain', '') body_without_quotes = request.POST.get('stripped-text', '') # note: other MIME headers are also posted here... # attachments: for key in request.FILES: file = request.FILES[key] # do something with the file # Returned text is ignored but HTTP status code matters: # Mailgun wants to see 2xx, otherwise it will make another attempt in 5 minutes return HttpResponse('OK') I thought what I had to do was simply make a url to catch Http Post requests. Am I missing something extra? Post failed: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) -
Run python scripts from within Django app
I'm helping to build a Django app that will interface with a voip phone system, and they've created some scripts to execute when an action is performed (add, update,delete) in order to have parity with the phone system side. They've asked me to pass the parameters to the script like this /var/www/html/om/om_add.sh deviceid filename title They've also mentioned to pass the title as a url, using urllib.quote_plus(title) Lastly, it should occur after each action is executed in the app. Now, I've heard that executing shell scripts from a Django app is not advised, but wondering if this is a different case? Also, how I can go about doing this, the only way I know how to pass those params is to pass them through a view. Any help is greatly appreciated! -
django selenium test for form submit and redirect
I'm trying to do a test with selenium in django but not sure how to test that the view will put the form data in the request session and redirect correctly to the next page? (I'm also unsure how to get the session from selenium like the django client?) class MySeleniumTests(StaticLiveServerTestCase): @classmethod def setUpClass(cls): super().setUpClass() options = webdriver.ChromeOptions() options.add_argument('headless') try: cls.selenium = webdriver.Chrome(chrome_options=options) except: raise Exception("couldn't start headless client") @classmethod def tearDownClass(cls): cls.selenium.quit() super().tearDownClass() def test_postcode_signup(self): self.selenium.get(f"{self.live_server_url}/users/postcode/") postcode_input = self.selenium.find_element_by_id('id_postcode') postcode_input.send_keys(postcode) self.selenium.find_element_by_tag_name('button').click() #self.assertRedirect() #self.selenium.session? #self.assertEqual(postcode,self.client.session.get('postcode')) -
"[Errno 12] Cannot allocate memory" on Geoip2() in Django with uWSGI
The following code runs successfully in manage.py shell: from django.contrib.gis.geoip2 import GeoIP2 g = GeoIP2() If I start the server manually with manage.py runserver and put the code in my Django view, it also runs fine. My Django application is hosted with uWSGI and Nginx as reverse proxy. Both uWSGI and Nginx run with www-data user. Here is the exception that I get there: ... File "/home/myuser/Env/virtenv/myproject/index/views.py" in index 28. g = GeoIP2() File "/home/myuser/Env/virtenv/local/lib/python2.7/site-packages/django/contrib/gis/geoip2/base.py" in __init__ 95. self._city = geoip2.database.Reader(city_db, mode=cache) File "/home/myuser/Env/virtenv/local/lib/python2.7/site-packages/geoip2/database.py" in __init__ 82. self._db_reader = maxminddb.open_database(filename, mode) File "/home/myuser/Env/virtenv/local/lib/python2.7/site-packages/maxminddb/__init__.py" in open_database 37. return maxminddb.reader.Reader(database, mode) File "/home/myuser/Env/virtenv/local/lib/python2.7/site-packages/maxminddb/reader.py" in __init__ 52. db_file.fileno(), 0, access=mmap.ACCESS_READ) Exception Type: error at / Exception Value: [Errno 12] Cannot allocate memory Local variables are: Variable Value database '/home/myuser/Env/virtenv/myproject/geoip/GeoLite2-City.mmdb' db_file <closed file '/home/myuser/Env/virtenv/myproject/geoip/GeoLite2-City.mmdb', mode 'rb' at 0x7f8c5cf5d390> mode 0 self <maxminddb.reader.Reader object at 0x7f8c5cf5f550> I use Virtualbox and my guest OS is Ubuntu 16.04. I have 4GB swap file there. If I free up some RAM the problem persists. This shouldn't be a memory issue on OS level, though, as I can create the GeoIP2 object in the shell and also if I run the server manually. Next thing I checked is that … -
Django: List all where one field combines all its unique values.
I got stuck. Problem I have is that I would like to create a list of objects.all() but where all objects, where one ForeignKey is the same, should be combined to one entry in a list. My Model: class TournamentStandings(models.Model): tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE) player = models.ForeignKey(Player, on_delete=models.CASCADE) player_place = models.FloatField(verbose_name=u"Place") The list I would like to get is something like this: ID | Player | Tournament| Place 1 | Name_1 | Tournament_1, Tournament_2| Place_on_tournament_1, P_o_t_2 2 |Name_2 |Tournament_1, Tournament_2| Place_on_tournament_1, P_o_t_2 So the ForeignKey(Player) would be the one I would like to limit and combine entries. I tried the generic view for objects.all() and the loop in my template: {% for player in ranking_list %} <tr> <td>{{ ranking_list.id }}</td> <td>{{ ranking_list.player }}</td> <td>{{ ranking_list.tournament }}</td> <td> {{ ranking_list.player_place }} </td> </tr> {% endfor %} It didn't work. Any hints ?? -
How to order Django querysets by upcoming birthdays
I want to list all users ordered by witch have their birthdays nearer. How do I order by by upcoming birthdays. -
Automatically set the primary key for one table as the foreign key for another?
I have two Django models: class seller_event(models.Model): event_id = models.AutoField(primary_key=True) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length = 300, default = 'Null') description = models.CharField(max_length = 300, default = 'Null') location = models.CharField(max_length= 300, default = 'Null') cash_payment = models.BooleanField(default=True) paytm_payment = models.BooleanField(default=False) def __unicode__(self): return str(self.event_id) class seller_event_items(models.Model): item_id = models.AutoField(primary_key=True) event_id = models.ForeignKey(seller_event) item_name = models.CharField(max_length = 300, default = 'Null') item_price = models.CharField(max_length = 300, default = 'Null') item_quant = models.CharField(max_length = 300, default = 'Null') def __unicode__(self): return str(self.item_id) The foreign key for the second table is the primary key for the first table. Essentially, I am trying to associate items with a sale. I have a forms like such: forms.py: class Seller_event(forms.ModelForm): class Meta: model = seller_event exclude = {'user'} class Seller_event_items(forms.ModelForm): class Meta: model = seller_event_items exclude = {'event_id'} views.py: def newlist(request): if request.user.is_authenticated(): user = request.user print user if request.method == 'POST': seller_event_form = Seller_event(request.POST) seller_event_items_form = Seller_event_items(request.POST) if seller_event_form.is_valid() and seller_event_items_form.is_valid(): new_seller_event = seller_event_form.save(commit=False) new_seller_event.user = user new_seller_event.save() seller_event_items_form.save() return redirect('/home') else: seller_event_form = Seller_event() seller_event_items_form = Seller_event_items() return render(request, 'home/newlist.html', {'seller_event_form': seller_event_form, 'seller_event_items_form': seller_event_items_form}) The form here is helping a seller both create a sale and then populate the sale with … -
Django - Cannot update model with model form gives str error
Im trying to let the user update some of the settings on their team but it doesn't seem to work correctly I want to update the name and if they accept users. Views.py @login_required def teamsettings_general(request, team_pk): logged_in_user = get_object_or_404(User, pk=request.user.pk) requested_team = get_object_or_404(Team, pk=team_pk) if request.method == 'POST': for member in requested_team.teammembership_set.all().order_by('-leader'): if member.user.pk == request.user.pk and member.leader: form = TeamSettings_GeneralForm(request.POST, instance=team_pk) if form.is_valid(): form.save() messages.success(request, "The team has been updated!") return redirect('teamsettings_general', team_pk=team_pk) for member in requested_team.teammembership_set.all().order_by('-leader'): if member.user.pk == request.user.pk and member.leader: feedback = FeedbackSupportForm() form = TeamSettings_GeneralForm(instance=team_pk) context = { 'requested_team': requested_team, 'feedback': feedback, 'form' : form, 'logged_in_user': logged_in_user, } return render(request, 'team/settings.html', context) break else: return redirect('team', team_pk) and my form.py class TeamSettings_GeneralForm(forms.ModelForm): class Meta: model = Team fields = ('name', 'accepts_applications',) Now I just want it to update name and accepts_applications 'str' object has no attribute '_meta' form = TeamSettings_GeneralForm(request.POST, instance=team_pk) if form.is_valid(): form.save() messages.success(request, "The team has been updated!") return redirect('teamsettings_general', team_pk=team_pk) logged_in_user = get_object_or_404(User, pk=request.user.pk) requested_team = get_object_or_404(Team, pk=team_pk) form = TeamSettings_GeneralForm(instance=team_pk) ... for member in requested_team.teammembership_set.all().order_by('-leader'): if member.user.pk == request.user.pk and member.leader: feedback = FeedbackSupportForm() context = { 'requested_team': requested_team, 'feedback': feedback, Thanks in adbanvce -
Force SSL for Django Postgres connection
I want to force Django to use SSL to connect to my postgres database. This question indicates that I need to pass sslmode='require' to the psycopg2 connect call. How do I add this to Django's database paremeters? -
AttributeError: 'tuple' object has no attribute 'get' Django Rest-Auth
I am trying to override the django-rest-auth RegisterSerializer. in settings file I have: # for use with the custom signup serializer REST_AUTH_REGISTER_SERIALIZERS = { 'REGISTER_SERIALIZER': 'myapp.users.serializers.CustomRegisterSerializer' }, in the serializers I have also have the customserializer class CustomRegisterSerializer(RegisterSerializer): first_name = serializers.CharField(required=True, write_only=True) last_name = serializers.CharField(required=True, write_only=True) ... def save(): ... app name in in appconfig class UsersConfig(AppConfig): name = 'myapp.users' verbose_name = "Users" but this gives keeps showing this error return getattr(import_module(package), attr) AttributeError: module 'myapp.users.serializers' has no attribute 'CustomRegisterSerializer' -
Django REST Framework File Upload with React
I'm trying to use FileUploadParser from rest_framework.parsers to send a raw CSV directly from a client request, but I'm running into some trouble. On the client side, my File object looks like (the contents of the file itself are 'foo,bar'): File(7) {preview: "blob:http://localhost:5011/c576258c-cdcb-4cfa-88dd- f1c52fcfaffe", name: "testcsv.csv", lastModified: 1512578725000, lastModifiedDate: Wed Dec 06 2017 11:45:25 GMT-0500 (EST), webkitRelativePath: "", …} lastModified: 1512578725000 lastModifiedDate: Wed Dec 06 2017 11:45:25 GMT-0500 (EST) {} name: "testcsv.csv" preview: "blob:http://localhost:5011/c576258c-cdcb-4cfa-88dd- f1c52fcfaffe" size: 7 type: "text/csv" webkitRelativePath: ""} and in React i'm using the request: req.post(`upload/${file.name}`,file, (err, res) => { console.log(req) if (!err) { dispatch(createProjectFormHeaders(headers)); browserHistory.push(`/project/${data.id}/create-form- from-upload`); } }); When it hits Django however, the contents of the file are: request.data['file'].read() (Pdb) b'{"preview":"blob:http://localhost:5011/5cd55446-b6e2-4991-b568- 326485b1bbd8"}' and not 'foo,bar'. Is there a way to do this just using the FileUploadParser? Am I passing the file object incorrectly from the client? I would prefer to use this Parser instead of refactoring to use multipart/form-data. Thanks for any guidance. -
Building a survey with questions having dynamic choices
I am currently building a survey which consists of questions with choices. The various choices for a question can be entered through the admin page. These choices are then required to be displayed as a drop down for a particular question in a django form. I believe the Choicefield is necessary but am unsure how to implement it as there is documentation only on static choices. Thanks in advance. -
Python: how to sort a list of strings by substring?
I have some list of strings, for example: ["foo bar SOME baz TEXT bob", "SOME foo bar baz bob TEXT", "SOME foo TEXT", "foo bar SOME TEXT baz", "SOME TEXT"] I want it to be sorted by exactness to SOME TEXT substring (upper case doesn't matter). Something like this order: ["SOME TEXT", "foo bar SOME TEXT baz", "SOME foo TEXT", "foo bar SOME baz TEXT bob", "SOME foo bar baz bob TEXT"] The idea is - the best score gets the string with the best match to substring words position. And for bigger amount of "sloppy" words between substring's words - the lower ordering it gets. I have found some libraries like fuzzyset, or Levenshtein distance but I'm not sure this is what I need. I know the exact substring by what I want to sort and those libs search the similar words, as I understood. Actually I need to do this sort after some database query (Postgresql) in my Django project. I have already tried full-text search with its ORM, but didn't get this relevant sort order (it doesn't count the distance between substring words). Next I have tried Haystack+Whoosh, but also at this moment didn't find info how … -
Ajax not posting Select Option
I'm trying to get the value of the option in my template below called exampleid. I've followed several examples I found online, but nothing seems to work. My template below has the ajax and jquery to get the value but when I try to print it returns None. I've exhausted my resources and my professor doesn't seem to know, he's "looking into it". <form action = "{% url 'example' %}" form method = "POST"> <script> $(document).ready(function () { $('#exampleid').on('change', function () { var exampleid= $(this).val(); $.ajax({ url: "{% url 'example' %}", data: exampleid, type: POST, success: function (result) { alert(result); }, }); }); }); </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <select title ="accesslevelid" class="form-control" id="exampleid" onchange="exampleid"> <option value="1"> Option1</option> <option value="2"> Option2</option> <option value="3"> Option3</option> </select> </form> my view attempting to retrieve the value of the post. exampleidpost = request.POST['exampleid', False] print (exampleidpost) My desired result is for the POST to return a 1,2, or 3. -
Django UUIDField in admin search_fields
In a model I have a UUIDField like this: uuid = models.UUIDField(_('UUID'), primary_key=True, default=uuid.uuid4, editable=False) in corresponding adminisration I would to search by uuid value. So I have: class MyAdmin(admin.ModelAdmin): search_fields = ('uuid',) but in this way it does not produce any results. Have I to set somethink? I use Django 1.11 -
php error with sending email?
I use VPS+NGINX+DJANGO+GUNICORN My pip freeze: Django==1.11.7 django-pagedown==0.1.3 gunicorn==19.7.1 Markdown==2.6.9 I active my venv and run gunicorn. (venv) name@ubuntu:~/mysite$ ls accounts api_v0 boards manage.py mysite posts static templates (venv) name@ubuntu:~/mysite$ gunicorn --bind 0.0.0.0:8000 mysite.wsgi And get such mistake: Traceback (most recent call last): self.callable = self.load() File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/usr/local/lib/python3.6/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python3.6/dist-packages/gunicorn/util.py", line 352, in import_app __import__(module) File "/home/name/mysite/mysite/wsgi.py", line 16, in <module> application = get_wsgi_application() File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named 'pagedown' What's the problem?