Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why django-registration-redux not serving Registration Form
I'm using django-registration-redux to create registration form but it is not serving me registration form. {% load staticfiles %} {% if user.is_authenticated %} <li> <a href="{% url 'auth_logout' %}">Logout</a> </li> {% else %} <li> <a href="{% url 'auth_login' %}">Login</a> </li> <li> <a href="{% url 'registration_register' %}">Register</a> </li> {% endif %} </body> </html> My Registration Form is simple: {% extends 'base.html' %} {% block title %} Registration Form - {{ block.super }} {% endblock title %} {% block content %} <h1>Registration Form</h1> <form role="form" action="" method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Submit" /> </form> {% endblock content %} And my settings.py has apps: INSTALLED_APPS = [ 'django.contrib.admin', 'registration', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'signups', ] Url pattern is: url(r'^accounts/', include('registration.backends.simple.urls')), enter image description here Here is screenshot which shows just blank list of Login and Register. -
Can I use Django groups as friends list?
Can I Use Django's built in auth groups as a friend list? For each user I would like to create each group and the main advantage I see is possibility of use of permissions. If chose to use a friendship model instead of group, is it possible to add permissions to the friendship model? Thanks -
How can I allow user to download or view a PDF online that I am hosting in my static folder?
I have a modal that stores the file_name, file_link, is_active and an uploaded on field. I can add the PDF via the admin site but I am trying to allow the users the ability to download the PDF or view the PDF on a new tab from the front end webpage that I created. Currently, the view that I created is getting the information for each PDF so that I can display the name, link, etc. If I put the {{ pdf.file_link }} into an it doesn't do anything. I would really appreciate getting some assistance on this so that I can stope spinning my wheels. Thank you in advance! -
Django Mailchimp list member status not updating
I'm creating a function that allows user to subscribe and unsubscribe to our email service, the subscribe part works, it updates the status of the member(user), but the unsubscribe part doesn't work. Here is part of my view.py email_hash = request.user.email_id client.lists.members.update(list_id='8b261363fb', subscriber_hash=email_hash, data={'email_address':request.user.email ,'Status': 'unsubscribed'}) I'm using mailchimp3 app, and the correct format of updating a member is: client.lists.members.update(list_id='', subscriber_hash='', data={}) I think I have all the requirements filled out in my code, what is missing? -
Other templates are not inheriting FOR LOOP in my base template
I have a FOR Loop in my base.html <div class="col-md-3 pi-mm-col"> <ul class="pi-mm-list"> {% for shop_name1 in shop_name1 %} <li> <h3> {{ shop_name1 }}</h3> </li> {% endfor %} {% for Shop_cat1 in Shop_cat1 %} <li> <a href="#">{{ Shop_cat1 }}</a> </li> {% endfor %} </ul><!-- .pi-mm-list end --> </div><!-- .col-md-3 end --> It works just fine in base.html. But when i {% extends base.html %} in index or other templates. The templates loads just fine, but the FOR loop isnt functional. What exactly am i doing wrong? -
Can anyone help me with building a website using python?
I want to make a website which collects reviews from few other websites and performs sentiment analysis on these reviews...so can anybody tell me what are all the tools and languages i need to learn to complete this project???? -
How to request from an application (ios or android) using Django-auth-toolkit with Python-social-auth?
I am developing android and ios application. Actually, I am using django-rest-framework-social-oauth2 which include Django-auth-toolkit and Python-social-auth. However, I have a problem here. when I try to curl -X POST -d "grant_type=convert_token&client_id=<client_id>&client_secret=<client_secret>&backend=facebook&token=<facebook_token>" http://localhost:8000/auth/convert-token this, It is working correctly. It creates an social user and also Django regular user and finally a token. But how can I do this in android ( or maybe ios ). I mean, what happen when a user click the facebook login button. I research a lot and they said that you should not put client secret in your application which means front-end. Please somebody help me. -
Django on Heroku : Application Error
I'm trying to run an existing git Django project on Heroku. Doesn't seem to be working. I'll post the logs. Any ideas what the issue is? There was an error before with collect_static, but I'm not sure if that is the main issue with this. C:\Django\campusarchitect>heroku logs 2017-02-18T19:25:20.432194+00:00 app[api]: Release v1 created by user bradleymitchellis@gmail.com 2017-02-18T19:25:20.585437+00:00 app[api]: Enable Logplex by user bradleymitchellis@gmail.com 2017-02-18T19:25:20.432194+00:00 app[api]: Initial release by user bradleymitchellis@gmail.com 2017-02-18T19:25:20.601060+00:00 app[api]: Release v1 created by user bradleymitchellis@gmail.com 2017-02-18T19:25:20.585437+00:00 app[api]: Release v2 created by user bradleymitchellis@gmail.com 2017-02-18T19:25:20.685280+00:00 app[api]: Release v2 created by user bradleymitchellis@gmail.com 2017-02-18T19:26:02.680411+00:00 heroku[slug-compiler]: Slug compilation started 2017-02-18T19:27:27.383189+00:00 heroku[slug-compiler]: Slug compilation started 2017-02-18T19:32:18.057971+00:00 heroku[slug-compiler]: Slug compilation started 2017-02-18T19:35:18.091254+00:00 heroku[slug-compiler]: Slug compilation started 2017-02-18T19:36:13.149054+00:00 app[api]: Release v3 created by user bradleymitchellis@gmail.com 2017-02-18T19:36:13.149054+00:00 app[api]: Set DISABLE_COLLECTSTATIC config vars by user bradleymitchellis@gmail.com 2017-02-18T19:36:13.345418+00:00 app[api]: Release v3 created by user bradleymitchellis@gmail.com 2017-02-18T19:37:11.776702+00:00 app[api]: Release v4 created by user bradleymitchellis@gmail.com 2017-02-18T19:37:11.776702+00:00 app[api]: Attach DATABASE (@ref:postgresql-curly-36955) by user bradleymitchellis@gmail.com 2017-02-18T19:37:12.395622+00:00 heroku[slug-compiler]: Slug compilation started 2017-02-18T19:37:12.395628+00:00 heroku[slug-compiler]: Slug compilation finished 2017-02-18T19:37:12.211277+00:00 app[api]: Release v5 created by user bradleymitchellis@gmail.com 2017-02-18T19:37:12.211277+00:00 app[api]: Deploy 43da54b by user bradleymitchellis@gmail.com 2017-02-18T19:37:12.415876+00:00 app[api]: Release v5 created by user bradleymitchellis@gmail.com 2017-02-18T19:37:35.187380+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=warm-brook-86729.herokuapp.com request_id=10bfc523-f737-4224-86bd-e7319b9ab34c fwd="192.76.177.124" … -
django; keep track of relation between model object and a thread
I am currently working on a django-project which supervises matches on multiple gameservers. I have my CsgoServer Model, which contains all the necessary information about the server. class CsgoServer(models.Model): name = models.CharField(max_length=64, unique=True) ip = models.GenericIPAddressField(null=False) ip_public = models.GenericIPAddressField(null=False) port = models.IntegerField(null=False) password = models.CharField(max_length=128, default='') rcon_password = models.CharField(max_length=128, default='') owner = models.ForeignKey(settings.AUTH_USER_MODEL) My django API provides a method called matchbot_summon, which creates a thread of my matchbot. The Matchbot then connects to the gameserver and does numerous things like tracking match statistics and so on. The matchbot automatically disconnects once the game has ended. @detail_route(methods=['get'], url_path='matchbot_summon') def matchbot_summon(self, request, pk=None): server = models.CsgoServer.objects.get(pk=pk) sections = list() sections.append(SectionMapVote) sections.append(SectionWarmup) sections.append(SectionKnifeRound) sections.append(SectionWarmup) sections.append(SectionHalf) server.matchbot = Match(server=server, map='de_dust2', sections=sections) server.matchbot.start() steamconnect = 'steam://connect/%s:%s/%s' % (server.ip_public, server.port, server.password) return Response({'error': '0', 'message': 'match created. connect by clicking on this link: <a href="%s">%s</a>' % (steamconnect, steamconnect)}) Since i am currently creating the thread from within my views.py, i have no way to keep a reference to the thread, so i could for example stop it through another api call. Is there any way i can persist the reference to the thread in the CsgoServer Model? So i could implement functionality to stop the matchbot? … -
django 1.10 media image not showing up
I am unable to display images uploaded by the admin user through admin on a template. settings.py MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') url.py from django.conf.urls import url from django.conf import settings from django.conf.urls.static import static from django.contrib import admin import web.views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', web.views.home, name='home') ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) page.html <img src="{{ event.image.url }}" alt="{{ event.title }}" /> also tried <img src="{% get_media_prefix %}{{ event.image.url }}" alt="{{ event.title }}" /> I am not sure what I am missing. Thanks for your help. -
cookie-cutter django nginx connect() failed (111: Connection refused) while connecting to upstream,
Hi I am new to this project and I am having issues hosting it on a CentOS7 ec2 instance. I am getting this error when I hit my domain: 2017/02/17 05:53:35 [error] 27#27: *20 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server:myApp.io, request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.18.0.7:5000/favicon.ico", host: "myApp.io", referrer: "https://myApp.io" When I look at the logs docker logs d381b6d093fa sleep 5 build starting nginx config replacing ___my.example.com___/myApp.io user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; upstream app { server django:5000; } server { listen 80; charset utf-8; server_name myApp.io ; location /.well-known/acme-challenge { proxy_pass http://certbot:80; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; } location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } # cookiecutter-django app location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app; } } } . Firing up nginx in the background. Waiting for folder /etc/letsencrypt/live/myApp.io to exist replacing ___my.example.com___/myApp.io … -
Dynamic length Django model field
I have one Django model field definition like this, landMark = models.CharField(max_length=50, blank=True) Can I define the landMark field dynamically so that it should capable of holding a string which has a varying size ? -
Stuck with formset initial values
I barely understand Django, and becаme acquainted with formsets just today. I have following task: i need a table of N rows with M cells in each row. The table must be filled with random data. I must be able to edit data in a row, add/delete rows etc. Since amount of cells in the table's row can be arbitrary, i used formsets. I've almost done my task, but i want following feature. When editing row, each cell (which is an input field) should contain initial values that been there before editing. I've tried to use construct like formset = RowFormSet(initial=[{'Cell 1': 'Bla-bla'}, {'Cell 2': 'Bow-wow'}]) but it seems that it works not the way i think. I'll be very grateful for help. -
Django save different objects in a single view
I need to render a view where I show: One form for the model A. Multiple forms for the model B. Once the user clicks on save, the model A and all the models B should be saved. Then, the same view is rendered with the fields properly updated. There's a special case where this view must be init with the model B forms prefilled with data coming from another model (C). I'm trying to implement this view using a FormView, which renders a ModelForm for model A, and a formset for model B, with no luck. Is this the correct way to go for this scenario? -
Django rest - serialize related object
I am using Django 1.10.5 and django rest framework 3.5.3 . I created an model named Abstract and it has a related field user and a Minisymposium. When I post a new abstract I enter the user`s and minisymposiums ID. But I dont want to get the ID when getting the object, I want to get the serialized object (for example: I post user 2 and get user: {name: david, id: 2} What should I do ? class Abstract(models.Model): STATUS_CHOICES = ( ('submitted', 'Submitted'), ('mso_approved', 'MSO Approved'), ('congress_org_approved', 'Congress Org Approved'), ('approval_email_sent', 'Approval email sent'), ('scheduled', 'scheduled'), ('denied', 'Denied') ) DISPLAY_STATUS_CHOICES = ( ('pending', 'Pending'), ('approved', 'Approved'), ('scheduled', 'scheduled'), ('denied', 'Denied') ) id = models.AutoField(primary_key=True) title = models.CharField(max_length=100, null=False) description = models.TextField(max_length=9000, null=False) minisymposium = models.ForeignKey(Minisymposium, related_name='abstracts', null=False) status = models.CharField(max_length=100, choices=STATUS_CHOICES, null=False, default='submitted') display_status = models.CharField(max_length=100, choices=DISPLAY_STATUS_CHOICES, null=False, default='pending') user = models.ForeignKey(User, null=False) date = models.DateTimeField(auto_now_add=True) def __str__(self): return str(self.id) + ' ' + self.title class AbstractSerializer(serializers.ModelSerializer): authors = AuthorSerializer(many=True, read_only=True) minisymposium = MinisymposiumSerializer(read_only=True) class AbstractViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ queryset = Abstract.objects.all() serializer_class = AbstractSerializer filter_fields = ['id', 'title', 'description', 'status', 'minisymposium', 'display_status', 'date', 'user'] search_fields = ['id', 'title', 'description', … -
sock file is missing in running django app with nginx and gunicorn
I was following this tutorial and successfully ran the project manually. However, after setting up nginx and systemd, it says 502 Bad Gateway. I have looked through other similar threads to no avail. I see that my gunicorn workers are running by doing ps -ax | grep gunicorn. my nginx configuration: server { listen 8000; server_name 127.0.0.1; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/ubuntu/myproject; } location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/myproject/myproject.sock; } } and the systemd file: [Unit] Description=gunicorn daemon After=network.target [Service] User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/myproject ExecStart=/home/ubuntu/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/myproject/myproject.sock myproject.wsgi:application [Install] WantedBy=multi-user.target The contents of /var/log/nginx/error.log: 2017/02/18 17:57:51 [crit] 1977#1977: *6 connect() to unix:/home/ubuntu/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: 10.0.2.2, server: 172.30.1.5, request: "GET / HTTP/1.1", upstream: "http://unix:/home/ubuntu/myproject/myproject.sock:/", host: "localhost:8000" Manually running /home/ubuntu/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/myproject/myproject.sock myproject.wsgi:application is also working. That is, sock file is created. I feel like I missing something very simple. What could I be doing wrong? -
elastic beanstalk python manage.py collectstatic : boto.exception.S3ResponseError: 400 Bad Request
After having launched elastic beanstalk with a django app. i do a collectsatic executed in a .ebextension file. But i have an error when executing the collectstatic container_commands: 03_collectstatic: command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput" I use the solution describe just below and it works on my personnal computer but not on elastic beanstalk environement. python manage.py collectstatic : boto.exception.S3ResponseError: 400 Bad Request The error is boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request I put the AWS in environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_STORAGE_BUCKET_NAME and get them with os.environ.get The error is still the same Any suggestion ? Thanks -
Ajax don't send request more then 1 time (Django)
Hi i have an Ajax post request $("button#confirm").on("click", function(){ $.post('/orders/confirm/', { amount: $('#amount-deliver').val(), order: $("div.order-cont").attr("order"), type: 'product' }, function(response) { $('.delivery-info').html(response); }); }); When I press 1-st time(when page just loaded) all is ok Ajax send request and recieved part of page to change(as response from django backend). But when I put other info into input or try to send the same value ajax don't send anything. If I reload the page all is ok for 1 time. Don't put here backend code cause ajax even send an request I check Firefox Dev Tools Network it send only the first click, other 2 + clicks it don't send anything -
How can I Set A Security Session in django
How can i set session for a password or username to know username.is is with a Security ? How cna i khow user when he log in. (fast and Security) All of this i want in django -
Always missing something while trying to setup Django with virtualenv, Python3.5, MySQL on CentOS server
A linux noob here. Sorry if this question has already been asked before. I could find a comprehensive solution. I have developed a web based solution in Django 1.10, virtualenv using Python3.5 and MySQL. The website works fine and now I am trying to deploy it on our local CentOS server. I tried number of recipes online to do so but none of them really worked for me. Always missing something. For example after following the entire digitalocean instructions, I see this error: No package libapache2-mod-wsgi-py3 available. Can someone please provide step by step or point me to right direction? My setup is as follows MySQL/MariaDB: 5.5.52-MariaDB MariaDB Server Server version: Apache/2.4.6 (CentOS) Python 3.5.3 Django==1.10.5 PyMySQL==0.7.9 virtualenv Thanks in advance! -
Django Form Field Custom attribute assignment and use in template
I am trying to generate a form dynamically and want to assign indentation of form fields. I am trying to assign an custom attribute offset to forms.CharField in subclass. I plan to use this logic to create a form dynamically from an xml file, where the fields would be indented based on the depth of the node. I am unable to retrieve the value of offset while rendering the template and hence unable to assign the margin-left style parameter. The final html output is also shown. Can someone please help. I have searched some other answers on this site where it appears that arbitrary attributes can be assigned and retrieved in template. e.g.as in thread here where an arbitrary label_class attribute is assigned My forms.py file : class MyCharField(forms.CharField): def __init__(self, *args, **kwargs): self.offset = kwargs.pop('offset', 0) super(MyCharField, self).__init__(*args, **kwargs) class MyDynamicForm(forms.Form): def __init__(self, *args, **kwargs): super(MyDynamicForm, self).__init__(*args, **kwargs) self.fields["Field_A"] = MyCharField(label="Input A", offset="5") self.fields["Offset_Field_B"] = MyCharField(label="Input B", offset="50") My Views.py looks like this: class MyDynamicView(View): template_name = 'demo/myform.html' form_class = MyDynamicForm def get(self, request, *args, **kwargs): form = self.form_class() return render(request, self.template_name, {'form': form}) My template file using bootstrap looks like this: {% extends 'demo/base.html' %} {% load bootstrap3 … -
django view redirects to URL it shouldn't
I have the following view def edit_booking(request, pk=None): if not request.user.is_authenticated: raise Http404 agent = Agent.objects.get(user=request.user) booking = get_object_or_404(Booking,pk=pk) form = BookingForm(request.POST or None, instance=booking) if form.is_valid(): instance = form.save(commit=False) instance.save() return HttpResponseRedirect(instance.get_absolute_url()) elif form.errors: messages.error(request,"There was a problem, please try again") context = { "form": form, } return render(request,'booking_form.html', context I use the following urls.py urlpatterns = [ url(r'^booking/create', create_booking, name="create-booking"), url(r'^booking/$', booking_list, name="booking-list"), url(r'^booking/(?P<pk>\d+)/$', booking_detail, name="booking-detail"), url(r'^booking/(?P<pk>\d+)/edit', edit_booking, name="edit-booking"), ] For some reason when I try to submit the form after editing some booking (e.g. http://127.0.0.1:8000/booking/24/edit) I am automatically redirected to (http://127.0.0.1:8000/booking/24/). As far as I can tell django is not processing any further code in the view. I tried to figure out with simple print("something") to see where in the code it ends up but it just goes to the url right away as soon as I submit from the template. For completeness sake this is the template: {% extends 'base.html' %} <div class="col-sm-6 col-sm-offset 3"> {% block content %} <form method="POST" action=".">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Save"/> </form> {% endblock %} </div> -
How to Make an API call to third party service while onboarding users in django app registration
I'm trying to use timekit.io calendars in my python/django app. Evrything works as should with regards registering new users using the built in django.contrib.auth but while onbaording new users I'd like to create a timekit user in the same workflow and get back api token to save on the user model. Onboarding & user creation Timekit can be used without your users even knowing about us, as user creation and provisioning can be done 100% through the API. In the onboarding flow in your app, you can simply add an API call to Timekit where you create the user (with the email, password, timezone etc. provided through your own screens) and save the resulting API token - more on that below. User API tokens (credentials) Whenever you create a new user (plain user or Google connected), you will receive an API token in the response. We recommend you save this API token in your own database, on your user model, as you will have to use the token for authentication to the Timekit API for all subsequent requests. I've done some very basic api stuff but have no idea how to do this in the sign-up process of my app. … -
Django Postgres Dropping original role not working
I'm following this tutorial to enhance PostgreSQL security in my webapp. https://github.com/sellonen/django-security-tips The beginning of the tutorial requires creating two roles: We'll have two roles, djangouser and djangomigrator. The djangouser will be used by your application in production, and djangomigrator will be used to perform migrations. The djangouser will need permissions to select, insert, delete, and update rows on all the tables. Done running the following commands: CREATE ROLE djangomigrator LOGIN ENCRYPTED PASSWORD 'migratorpass'; CREATE ROLE djangouser LOGIN ENCRYPTED PASSWORD 'userpass'; CREATE SCHEMA playschema AUTHORIZATION djangomigrator; GRANT USAGE ON SCHEMA playschema TO djangouser; ALTER ROLE djangouser SET SEARCH_PATH TO playschema; ALTER ROLE djangomigrator SET SEARCH_PATH TO playschema; The issue is before I created this role, I also have a role called postgres. I think it is also my username too to log in? I try to Drop this role but obvious it has more power than djangouser and djangomigrator. Am I suppose to Drop the postgres role as part of this tutorial or? If I'm trying to be secure I want to make sure I'm doing it all correctly and not having additional roles. -
PIL Library not loaded: /opt/local/lib/libjpeg.9.dylib
I have a perfectly running website designed in django, but accidentally i uninstalled homebrew and hence all the packages postgres, Pillow etc., had been lost and hence installed all of them again, but when i run the django runserver i got the below error Unhandled exception in thread started by <function wrapper at 0x1071c11b8> Traceback (most recent call last): File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/utils/autoreload.py", line 93, in wrapper fn(*args, **kwargs) File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 101, in inner_run self.validate(display_num_errors=True) File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate num_errors = get_validation_errors(s, app) File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors self._populate() File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _populate self.load_app(app_name) File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app models = import_module('%s.models' % app_name) File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module __import__(name) File "/Users/shivakrishna/shiva/app/post-web-1.6/modes/directory/models.py", line 24, in <module> from PIL import Image, ImageDraw, ImageFont File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/Image.py", line 67, in <module> from PIL import _imaging as core ImportError: dlopen(/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: /opt/local/lib/libjpeg.9.dylib Referenced from: /Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/_imaging.so Reason: image not found I tried everything that was available on stackoverflow posts related to it like brew uninstall libjpeg brew install libjpeg But none of them worked, and my brew list boost gdal gmp liblwgeom libxml2 mysql postgis …