Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
MYSQL- python pip install error
I tried to get build an app on Django and I wanted to use MySQL as the database. After setting up the settings.py right, I tried to migrate. Then I got the obvious error saying that MySQL is not installed. So inorder to install MySQL, I ran: sudo -H pip install MySQL-python I get the following error: Collecting MySQL-python Using cached MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/tmp/pip-build-zAMhWo/MySQL-python/setup.py", line 17, in <module> metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 25, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-zAMhWo/MySQL-python/ How do I fix this? -
Mass removal of certain objects from m2m relation
I want to remove large sets of objects from a m2m relation. Therefore I do at the moment a simple loop: objs = Foobar.objects.filter(to_remove=1) for obj in objs: rel_foobar.remove(q) Is there a faster alternative because this needs very long to execute? modals.py rel_foobar = models.ManyToManyField(Foobar) -
ckeditor: Cannot set property 'dir' of undefined (django + zinnia)
I am experiencing this strange error only on my production environment. It works fine locally and on staging. I'm using Django==1.10.5 & django-blog-zinnia==0.18.1 with zinnia-wysiwyg-ckeditor==1.3. I believe this issue happened recently when we upgraded from Django==1.8 to the latest. When I try to create a blog entry, I can't edit the content because the ckeditor instance does not load. The errors are: https://luxglove.com/admin/zinnia/entry/81/change/config.js/change/ 404 (Not Found) https://luxglove.com/admin/zinnia/entry/81/change/lang/en.js/change/ GET https://luxglove.com/admin/zinnia/entry/81/change/skins/moono-lisa/editor.css/change/ Uncaught TypeError: Cannot set property 'dir' of undefined The URL is /admin/zinnia/entry/81/change/ So this very much looks like ckeditor.js is trying to load additional static files based on the current URLs and somehow it injects the filenames into the current URL. As a workaround, I ssh-ed into the server and manipulated /static/ckeditor/ckeditor/ckeditor.8bd276b5ef4c.js and added this line at the very top: window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/'; This solves the issue. The big question is: Why does this only happen on one of my machines, why does Django/zinnia not set CKEDITOR_BASEPATH correctly by itself? I will now try to override the admin/change_form.html template and add that JS snippet to force-set the BASEPATH but that can't be the correct solution. I'm posting this here because I am not sure if this is an issue in Django, … -
Django collectstatic error: No such file or directory: '/app/appName/static'
I've been getting this collectstatic error when I run the following in command line: C:\Users\Steven\site1>heroku run python manage.py collectstatic Running python manage.py collectstatic on my-compository... up, run.9943 (Free) You have requested to collect static files at the destination location as specified in your settings: /app/mynotes/staticfiles This will overwrite existing files! Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle collected = self.collect() File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, in collect for path, storage in finder.list(self.ignore_patterns): File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list for path in utils.get_files(storage, ignore_patterns): File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files directories, files = storage.listdir(location) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 399, in listdir for entry in os.listdir(path): OSError: [Errno 2] No such file or directory: '/app/mynotes/static' I haven't been able to figure out what was wrong after much searching. Here's a slight preview of my directory structure: -site1 - mynotes - settings.py - staticfiles (empty) … -
how to set sentry timezone?
I am getting this Feb 21, 2017 1:55:04 AM UTC showing in sentry.io but then I want the timezone showing America/Vancouver so the issue showing in sentry.io would match my timezone correctly. But somehow I don't seem to find anywhere to set this timezone. I thought it was using the server timezone so I set the timezone on server to America/Vancouver already but still no luck. Can someone please give me a hand? -
NGINX--Connect to UNIX sock failed
Checked out a few other similar issues here, but can't diagnose the issue. My site has been occasionally going down with a 502 Bad Gateway Error. I found the following in my error log. Note i'm using a VPS server on Ubuntu 16.04 using Gunicorn/NGINX. 2017/02/21 01:08:29 [crit] 1247#1247: *1 connect() to unix:/home/django/chrisblog/chrisblog.sock failed (2: No such file or directory) while connecting to upstream, client: 173.48.32.62, server: 45.32.201.31, request: "GET /redditclone/ HTTP/1.1", upstream: "http://unix:/home/django/chrisblog/chrisblog.sock:/redditclone/", host: "pythoncreate.com" 2017/02/21 01:10:36 [crit] 1575#1575: *1 connect() to unix:/home/django/chrisblog/chrisblog.sock failed (2: No such file or directory) while connecting to upstream, client: 173.48.32.62, server: 45.32.201.31, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/chrisblog/chrisblog.sock:/", host: "pythoncreate.com" 2017/02/21 01:48:04 [crit] 2342#2342: *2 connect() to unix:/home/django/chrisblog/chrisblog.sock failed (2: No such file or directory) while connecting to upstream, client: 173.48.32.62, server: 45.32.201.31, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/chrisblog/chrisblog.sock:/", host: "pythoncreate.com" When i go to check the gunicorn status i get the following so it looks like maybe it is failing for some reason?: gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2017-02-21 01:46:08 UTC; 7min ago Main PID: 2245 (code=exited, status=203/EXEC) Feb 21 01:46:08 mydjangoblog systemd[1]: Started gunicorn daemon. Feb 21 01:46:08 mydjangoblog … -
Is Django compatible with Microsoft Server 2003?
I have a group project where we have to create a web application using an external server and database. The database is SQL Server 2008 and the server itself is Microsoft Server 2003. We are planning to run this using apache and django running python 2.7.13. Will Django be compatible with this old server? Thanks in advance. -
Sending Array Using Ajax to Django App
So I have some jquery and ajax that collects data from checkbox values. This part is working, I used alert to debug the array to see if the appropriate values are being collected when the checkboxes are ticked. var myCheckboxes = new Array(); $("input:checked").each(function() { myCheckboxes.push($(this).val()); }); $.ajax({ type:'POST', url:'createEvent/', data:{ name: name, myCheckboxes: myCheckboxes, } }); However on my receiving end I have: def createEvent(request): if request.method == "POST": member = request.POST.getlist('myCheckboxes') print(member) Member is an empty array. What am I doing wrong? I can't seem to find the answer. -
Django json, Resource interpreted as Document but transferred with MIME type application/json:
I've been trying to create a register form for django 1.10 and it almost works fine except that when I make the post works fine, but redirects to the url of the ajax post and in Chrome inspector I see something like this: Resource interpreted as Document but transferred with MIME type application/json: "http://127.0.0.1:8500/reg/". And then displays my json response: {"reg": "ok", "email": "logdo@fujasldm.com"} Because of that undesired redirection I can't handle the response on the page that I have my form. This is my ajax: $('#botonregistro').on('submit', function(e) { e.preventDefault(); console.log("reg!") // sanity check $.ajax({ url: "/reg/", // the endpoint type: "POST", // http method data: { username: $('#id_username').val(), password: $('#id_password').val(), email: $('#id_email').val(), sexo: $('#id_sexo').val(), interes: $('#id_interes').val() }, // data sent with the post request success: function(response) { $('.home-reg-form').empty(); console.log(json); console.log("success"); }, error: function(response) { $('.home-reg-form').empty(); $('.home-reg-form').html("<div class='alert-box alert radius' data-alert>Oops! We have encountered an error: <a href='#' class='close'>&times;</a></div>"); // add the error to the dom } }); }); And this is my view from the post url: def reg_ajax(request): if request.method == 'POST': uname = request.POST.get('username') email = request.POST.get('email') psw = request.POST.get('password') user = User.objects.create_user(username=uname, email=email, password=psw) response = JsonResponse({'reg':'ok', 'email': email}) return response else: response = JsonResponse({'reg':'error'}) return … -
Django Channels. How to respond to a WebSocket open request with a subprotocol?
In JavaScript a browser can specify a sub-protocol as the second parameter in a WebSocket creation: socket=new WebSocket(url, subprotocol) Experimenting with Chrome, this is correctly sent to the server as a Sec-WebSocket-Protocol element in the header. Using Django channels, a simple consumer def ws_add(message): message.reply_channel.send({"accept": True,}) gives the error WebSocket connection to 'xxx' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received. What is the correct way to accept that connection request in Django channels' ws_add function? -
Select a Value from Database and Return another Value in Django
In my models.py, I have two CharFields set that the Admin can log into and input. One has a friendly name and the other has a file path directory attached to it: models.py class IssuingCA (models.Model) ICA_name = models.CharField(max_length=200) filepath = models.CharField(max_length=200) def __str__(self): return self.ICA_name In my views.py, I reference these fields so that I can use them in a drop-down <select> tag later: views.py from .models import IssuingCA --snip-- """This is the main page""" def index(request): issuers = IssuingCA.objects.order_by('ICA_name') issuerOptions = {'issuers': issuers} return render(request, 'index.html', issuerOptions) --snip-- """This is the results page""" def results(request): issuer = request.POST['selectedIssuer'] return render(request, 'results.html', {'issuer': issuer} In my html code, I create a for loop for each ICA_name from my model. index.html --snip-- <select name="selectedIssuers"> {% for icas in issuers %} <option>{{ icas }}</option> {% endfor %} </select> results.html --snip-- This is your result:<br /> <textarea rows="10" cols="200">{{ issuer }}</textarea> --snip-- Right now, when I submit this data and return it via a simple post, it returns the ICA_name field I selected as expected. How can I get the result to show the matching filepath when the ICA_name is selected? I eventually want to pass this data (the filepath) onwards to … -
django adding query for id
My call is venues = ExtCalendar.objects.all() but I get an error (1054, "Unknown column 'ext_calendar.id' in 'field list'") Even though the ext_calendar table does not have this column My model: class ExtCalendar(models.Model): source_id = models.CharField(max_length=255) ext_type = models.CharField(max_length=32) ext_id = models.CharField(max_length=255) out_id = models.CharField(max_length=255, blank=True, null=True) confidence = models.FloatField(blank=True, null=True) data = models.CharField(max_length=8192, blank=True, null=True) ext_name = models.CharField(max_length=255, blank=True, null=True) out_name = models.CharField(max_length=255, blank=True, null=True) last_out_id = models.CharField(max_length=32, blank=True, null=True) status = models.CharField(max_length=10) out_formatted = models.CharField(max_length=1024, blank=True, null=True) ext_formatted = models.CharField(max_length=1024, blank=True, null=True) class Meta: db_table = 'ext_calendar' unique_together = (('source_id', 'ext_type', 'ext_id'),) def __unicode__(self): return self.ext_id The return value of venues is a QuerySet containing an incorrect query of: SELECT `ext_calendar`.`id`, `ext_calendar`.`source_id`, `ext_calendar`.`ext_type`, `ext_calendar`.`ext_id`, `ext_calendar`.`out_id`, `ext_calendar`.`confidence`, `ext_calendar`.`data`, `ext_calendar`.`ext_name`, `ext_calendar`.`out_name`, `ext_calendar`.`last_out_id`, `ext_calendar`.`status`, `ext_calendar`.`out_formatted`, `ext_calendar`.`ext_formatted` FROM `ext_calendar` So how do I remove id from the query? -
Django Breakpoints Not Working PyCharm
I'm trying to debug a Django project in PyCharm. I've set a breakpoint at the point where Django tells me that the exception is coming from. When I hit debug though, the break point turns grey, and the debugger doesn't catch it. But this is exactly the line which is causing the error, it you believe my stack trace. Traceback: File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 217. response = self.process_exception_by_middleware(e, request) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 215. response = response.render() File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/response.py" in render 109. self.content = self.rendered_content File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/response.py" in rendered_content 86. content = template.render(context, self._request) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/backends/django.py" in render 66. return self.template.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render 208. return self._render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in _render 199. return self.nodelist.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render 994. bit = node.render_annotated(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated 961. return self.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/loader_tags.py" in render 174. return compiled_parent._render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in _render 199. return self.nodelist.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render 994. bit = node.render_annotated(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated 961. return self.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/defaulttags.py" in render 315. return nodelist.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render 994. bit = node.render_annotated(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/base.py" in render_annotated 961. return self.render(context) File "/Users/ThatOtherBatman/anaconda/envs/ProjectFoo/lib/python3.5/site-packages/django/template/defaulttags.py" in render 439. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app) … -
Travis-CI Django Error
I would like to add continuous integraiton for my site in Django. However on build I get: python manage.py migrate rpi_csdt_community Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management It logs: Successfully installed ... Django-1.9.5. So I am guessing it's not locating the django directory correctly. I know that typically Django uses folder ./python for it's dependencies etc. Here is the build script: language: python python: - 2.7 services: postgresql env: - DJANGO=1.9.5 before_install: - DJANGO_SETTINGS_MODULE=rpi_csdt_community.settings - PYTHONPATH=$HOME/builds/CSnap/rpi_csdt_community - PIP_USE_MIRRORS=true install: - sudo $(type -P npm) install -g less - sudo $(type -P npm) install -g yuglify - sudo pip install Django==$DJANGO - sudo pip install setuptools --upgrade - sudo pip install --upgrade -r libraries-vcs.txt - sudo pip install -r libraries.txt - sudo pip install -r libraries-heroku.txt before_script: - psql -c "CREATE DATABASE mydb;" -U postgres script: - python manage.py migrate - python manage.py test rpi_csdt_community - python manage.py test project_share -
Unable to parse querydict for FormParser and MultiPartParser containing multiple images
I hv this model : class Person(models.Model): name = models.CharField(max_length=100) image = models.ImageField(upload_to = 'pic_folder/') class PersonViewset(viewsets.ModelViewSet): serializer_class = PersonSerializer parser_classes = (FormParser, MultiPartParser) queryset = Person.objects.all() model = Person def update(self, request, *args, **kwargs): instance = self.get_object() serializer = self.serializer_class(instance, data=request.data, partial=True) class PersonSerializer(serializers.ModelSerializer): class Meta: model = Person def create(self, validated_data): return Person.objects.create(**validated_data) def update(self, instance, validated_data): instance.name = validated_data.get('name', instance.name) instance.image = validated_data.get('image', instance.name) The problem is when I use postman to upload files using multi-part input the validated_data in the update method above comes as blank. The value of request.data in view has correct multivalue dict with both the images (i uploaded thru postman) appearing as data but how do I deserialize querydict(request.data) and set it explicitly for the data=request.data to work? Any help is greatly appreciated. -
Most efficient way to query by nearest float value?
I have the following model: class PlatformVersion(models.Model): platform = models.ForeignKey(Platform) version = models.FloatField(db_index=True) display_version = models.CharField(max_length=32, db_index=True) is_enabled = models.BooleanField(default=False) Initial DB seeding code: def add_version(self, platform, version, display_version): try: return PlatformVersion.objects.get(platform=platform, version=version) except PlatformVersion.DoesNotExist: return PlatformVersion.objects.create(platform=platform, version=version, display_version=display_version, is_enabled=True) self.add_version(platform, 9.0, '9.0') self.add_version(platform, 9.1, '9.1') self.add_version(platform, 9.2, '9.2') self.add_version(platform, 9.3, '9.3') As you can see, I'm adding minor versions only, skipping versions like 9.0.1, 9.0.2, etc. And I have the following use-case: client sends request with platform version, that could be, for example, 9.0, 9.0.0 or 9.0.1 or 10.0 (missing in DB at all), etc. I need then to query the following PlatformVersion instance from DB: for 9.0 -> 9.0 for 9.0.0 -> 9.0 for 9.0.1 -> 9.0 for 9.0.999 -> 9.0 for 9.1.1 -> 9.1 for 10.0 (10.* missing in DB) -> closest version = 9.3 for my initial seed data. I'm sure I can write such code by myself, but there will be a really huge amount of such queries per second, so I care about efficiency. Can you please suggest best option for performance? -
Signals on Django-paypal not firing
Im having trouble with getting the signals of my django app being fired. I have my settings.py Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'shop', 'cart', 'orders', 'paypal.standard.ipn', 'payment', ) My views.py file from decimal import Decimal from django.conf import settings from django.core.urlresolvers import reverse from django.shortcuts import render, get_object_or_404 from paypal.standard.forms import PayPalPaymentsForm from orders.models import Order from django.views.decorators.csrf import csrf_exempt @csrf_exempt def payment_done(request): return render(request, 'payment/done.html') @csrf_exempt def payment_canceled(request): return render(request, 'payment/canceled.html') def payment_process(request): order_id = request.session.get('order_id') order = get_object_or_404(Order, id=order_id) host = request.get_host() paypal_dict = { 'business': settings.PAYPAL_RECEIVER_EMAIL, 'amount': '%.2f' % order.get_total_cost().quantize(Decimal('.01')), 'item_name': 'Order {}'.format(order.id), 'invoice': str(order.id), 'currency_code': 'USD', 'notify_url': 'http://{}{}'.format(host, reverse('paypal-ipn')), 'return_url': 'http://{}{}'.format(host, reverse('payment:done')), 'cancel_return': 'http://{}{}'.format(host, reverse('payment:canceled')), } form = PayPalPaymentsForm(initial=paypal_dict) return render(request, 'payment/process.html', {'order': order, 'form':form}) The signals.py file from django.shortcuts import get_object_or_404 from paypal.standard.models import ST_PP_COMPLETED from paypal.standard.ipn.signals import valid_ipn_received, invalid_ipn_received from orders.models import Order from django.template.loader import render_to_string from django.core.mail import EmailMessage from django.conf import settings import weasyprint from io import BytesIO def payment_notification(sender, **kwargs): ipn_obj = sender print(ipn_obj.payment_status) if ipn_obj.payment_status == ST_PP_COMPLETED: # payment was successful order = get_object_or_404(Order, id=ipn_obj.invoice) # mark the order as paid order.paid = True order.save() # create invoice e-mail subject = 'My Shop … -
Receiving Checkbox Values Using Ajax
I have the following checkbox definitions: {% for member in team_profile %} <div class="checkbox"> <label> <input type="checkbox" id="checkboxes" value="{{ member.user_id }}">{{ member.first_name }}</label> </div> {% endfor %} Where team_profile just contains a bunch of member names. So the I would like to get the value={{member.userid}} stuff. So for my jquery i have: var myCheckboxes = new Array(); $("input:checked").each(function() { data['myCheckboxes[]'].push($(this).val()); }); $.ajax({ type:'POST', url:'createEvent/', data:{ name: name, myCheckboxes: myCheckboxes, } }); So I want to collect all the values and store them in an array called myCheckboxes. But I am getting an error data is not defined. Is there any other way to do this? Thanks, Andy -
Navigating Many to Many Relationships Django
I need get the list of Items name and qty for a given menu. how can i query and return a QuerySet with the needed columns.? i only get the list of menus but still cannot get qty. should i do multiple queries or try using raw sql class Item(models.Model): name = models.CharField(max_length=20) class Meals(models.Model): name = models.CharField(max_length=50) ingredients = models.ManyToManyField(Item, through='MealRecipe') class Menu(models.Model): name = models.CharField(max_length=50) meals = models.ManyToManyField(Meals,through='CompMenu') class CompMenu(models.Model): TYPE_COMP = ( ('B', 'Breakfast'), ('L', 'Lunch'), ('D', 'Dinner') ) menu = models.ForeignKey(Menu) meal = models.ForeignKey(Meals) type = models.CharField(max_length=1, choices=TYPE_COMP) class MealRecipe(models.Model): Meal = models.ForeignKey(Meal) item = models.ForeignKey(Item) qty = models.IntegerField() -
issue with downloading psycopg2
I have pip, setuptool, and Django downloaded, but when I run the command pip install psycopg2 I get this error Collecting psycopg2 Using cached psycopg2-2.6.2.tar.gz Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info/psycopg2.egg-info writing pip-egg-info/psycopg2.egg-info/PKG-INFO writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt' warning: manifest_maker: standard file '-c' not found Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/vp/pqjbpqdx4w99f2bct1w8b2rm0000gn/T/pip-build-zwp1Ph/psycopg2/ Anyone know why? -
What am I missing here? Apache keeps serving default page
I have configured my Django site but Apache keeps serving the default apache's page. What am I missing here? My setup is Django 1.10 on CentOS server with python3.5. /home/sbsadmin/myproject db.sqlite3 manage.py myproject __init__.py __pycache__ settings.py urls.py wsgi.py myprojectenv static templates /etc/httpd/conf.d/wsgi.conf LoadModule wsgi_module /etc/httpd/modules/mod_wsgi.so <VirtualHost *:80> ServerName example.com ServerAlias www.example.com ServerAdmin username@example.com DocumentRoot /home/sbsadmin/myproject/ #ErrorLog /var/www/html/example.com/logs/error.log #CustomLog /var/www/html/example.com/logs/access.log combined WSGIScriptAlias / /home/sbsadmin/myproject/myproject/wsgi.py # Alias /robots.txt /var/www/html/example.com/public_html/robots.txt # Alias /favicon.ico /var/www/html/example.com/public_html/favicon.ico # Alias /images /var/www/html/example.com/public_html/images # Alias /static /var/www/html/example.com/public_html/static <Directory /home/sbsadmin/myproject/> Order allow,deny Allow from all </Directory> </VirtualHost> httpd -M | grep wsgi output [root@webserver conf.d]# httpd -M | grep wsgi wsgi_module (shared) [root@webserver conf.d]# -
Django imageField url on html
I've this hiearchy: -mega_series -myApp -series -static -series -covers -models.py -views.py ... -manage.py On the model I store the image like that: class Serie (models.Model): serie_cover = models.ImageField(upload_to='series/static/series/covers') serie_name = models.CharField(max_length=100) The images once uploaded via admin site goes correctly to path: mega_series/series/static/series/covers/ And this is how I acces it via html: <img src="{{serie.serie_cover}}" width="150" height="250" /> The result url that I got is the following: http://127.0.0.1:8000/series/series/static/series/covers/juego_de_tronos.jpg Why i got /series/series? -
Can I Run Multiple Django Projects on One Website?
i'm a bit of a newcomer to Django/Python but trying to figure something out--hope you can help. I'm trying to create a personal website with a page dedicated to some of the Python and Django projects that I've completed through several different online courses. I'm just having a tough time figuring out the best way to link through and assemble the project directories on my server. My first project is just the files for my blog itself. I've created a new directory in the same home root as the blog project housing another of my django projects. Just looking for a bit of assistance on how i link out to the second project from my blog. I thought i could use the urls.py file for my blog to redirect link to the second project (ie projects/project2) utilizing a views definition from the views.py file for one of the apps in the blog. But then--i'm getting tripped up on how to render that link to the second project. Any forward guidance is greatly appreciated. -
Docker messed with local django/postgres projects. Can't run project on localhost
I stocked at postgresql/django issue. After attempt of running the localhost server got the following error django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host "172.17.0.1", database "closerdb", SSL off According to many similar issues and answers last lines at pg_hba.conf look this way: host all all 0.0.0.0/0 md5 local replication postgres trust host replication postgres 127.0.0.1/32 trust host replication postgres 172.17.0.1 trust host replication postgres ::1/128 trust I have restarted postgres after editing .conf file, but error remains. I supposed that it was cause by docker installation, because normally django project has to run on loclahost(127.0.0.1) and 172.17.0.1 is a default docker ip. How to fix all that and avoid such problems in future? -
Does Django change/adjust the resolution of HTML being served ? Ideas?
So I am a little baffled with the behaviour that I am experiencing. I noticed that if I open a html file directly by clicking on it the resolution of the file (font size , spacing ) is somewhat different (larger) from the same HTML file when it is served by Django.I wanted to know why this might be happening. The files dont make use of any local css files.So why are fonts larger when the html file is clicked directly ? This is the code I am using in the html <!doctype html> <html> <head> <meta charset="utf-8"> <title>Login</title> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> </head> <div class="full header"> <div class="menu-toggle"> <div></div> <div></div> <div></div> </div> <div class="container"> <div class="menu-area"> <ul> <li><a href="#">Downloads</a></li> <li><a href="#">Account</a></li> <li><a href="#">Admin</a></li> <li><a href="#">Contact us</a></li> </ul> </div> </div> </div> <div class="login-page-full"> <div class="login-wapper"> <div class="login-wapper-left"> <h2>Welcome to<br> My Test Application</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor<br> incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis<br> nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu<br> fugiat nulla pariatur.</p> </div> <div class="login-form-right"> …