Search Results

Search found 4109 results on 165 pages for 'django paypal'.

Page 56/165 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • Django and mod_python intermittent error?

    - by Peter
    I have a Django site at http://sm.rutgers.edu/relive/af_api/index/. It is supposed to display "Home of the relive APIs". If you refresh this page many times, you can see different renderings. 1) The expected page. 2) Django "It worked!" page. 3) "ImportError at /index/" page. If you scroll down enough to ROOT_URLCONF part, you will see it says 'relive.urls'. But apparently, it should be 'af_api.urls', which is in my settings.py file. Since these results happen randomly, is it possible that either Django or mod_python is working unstably?

    Read the article

  • use qt and django to create desktop apps

    - by sandra
    Hi guys, I had this idea of creating desktop apps using django. The principe being: - Write the django app, and use something like cherrypy to serve it. - Write a Qt app in C++ to access it and this by using QtWebview (webkit) I'd like to "bundle" this in a single app. The lighter, the better :) So here are my questions and if you have better ideas and suggestions, please share them :) Is it possible to serve a django app with a c++ one? (a c++ server embedding python)? anyone did this before? Do you have some articles, blog posts? Thanks a lot!

    Read the article

  • Django nose to run only project tests

    - by patroqueeet
    I added nose, django-nose, nose-exclude, coverage to my buildout.cfg and ran buildout. Furthermore I added the TEST_RUNNER and the NOSE_ARGS to my settings.py. In the last step I created a exclude_dirs.txt and included it into the NOSE_ARGS. That worked so far. Finally I ran bin/django testto run the tests of my project. I found out that every app inside INSTALLED_APP is run and that even parts of the django core models are run. How can I limit this to my project only without exernal packages?

    Read the article

  • Autocomplete with Django, jQuery and google app engine

    - by Ron
    Hey guys, I'm new to Django and jQuery, but I have a lot of python experience. I'm basically trying to write an HTML form, with one text box for now, that as you type in it, shows you auto completion options. this will be used for finding restaurants, and I intend to use the Yelp API for that. can someone please point me out in a direction of a tutorial on how to do this - specifically with regards to the Django / HTML / jQuery rather than how to work with the Yelp API? Are there any tutorials I should read? All tutorials I have found are very basic ones that build forms from the Django data models.. Thanks!

    Read the article

  • Including a Django app's url.py is resulting in a 404

    - by 828
    I have the following code in the urls.py in mysite project. /mysite/urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^gallery/$', include('mysite.gallery.urls')), ) This results in a 404 page when I try to access a url set in gallery/urls.py. /mysite/gallery/urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^gallery/browse/$', 'mysite.gallery.views.browse'), (r'^gallery/photo/$', 'mysite.gallery.views.photo'), ) 404 error Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^gallery/$ The current URL, gallery/browse/, didn't match any of these. Also, the site is hosted on a media temple (dv) server and using mod_wsgi

    Read the article

  • trying to load css/images in django

    - by tipu
    I looked http://docs.djangoproject.com/en/dev/howto/static-files/ already, but am still confused on how to get css/image files loaded. On my server, the images folder and css file are located at /srv/twingle/search my urls.py 1 from django.conf.urls.defaults import * 2 3 # Uncomment the next two lines to enable the admin: 4 # from django.contrib import admin 5 # admin.autodiscover() 6 7 urlpatterns = patterns('twingle.search.views', 8 url(r'^$', 'index'), 9 url(r'^search/(?P<param>\w+)$', 'index'), 10 ) 11 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', 12 {'document_root': '/srv/twingle/search'}), 13 I try to access my css as follows, <link rel="stylesheet" type="text/css" href="/site_media/style.css" /> That's exactly how the tutorial says to do it, but it doesn't work. Any suggestions?

    Read the article

  • Django: how to create sites dynamically?

    - by Leandro Ardissone
    Hi, I need to create an application for the company where I can create sites dynamically. For example, I need an admin interface (Django's admin is enough) where I can setup a new site and add some settings to it. Each site must hold a domain (domains can be manually added to apache conf, but if Django can handle it too would be awesome). Each site must be independent of the others, I mean, I shouldn't be able to see the data content of other sites but I can share same applications/models. I've seen the Django's Sites framework, but I'm not sure if it's possible to implement that way. Should I use Sites framework or create a new app that can handle sites better? What do you think?

    Read the article

  • server reboot has caused django project to lose directories

    - by wmfox3
    A fully functional Django project as well as a couple in development have all broken following the rebooting of the server. In addition to some pieces of the Django admin returning errors as well as missing .js and .css files, I'm getting errors like this when viewing pages that include images uploaded through the admin. Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: (2, 'No such file or directory') Exception Location: /usr/lib/pymodules/python2.6/django/template/debug.py in render_node, line 81 Python Executable: /usr/bin/python Python Version: 2.6.4 So did the reboot stomp on some part of my configuration/setup or did it fail to restart a critical piece?

    Read the article

  • Django: automatically import MEDIA_URL in context

    - by pistacchio
    Hi, like exposed here, one can set a MEDIA_URL in settings.py (for example i'm pointing to Amazon S3) and serve the files in the view via {{ MEDIA_URL }}. Since MEDIA_URL is not automatically in the context, one have to manually add it to the context, so, for example, the following works: #views.py from django.shortcuts import render_to_response from django.template import RequestContext def test(request): return render_to_response('test.html', {}, context_instance=RequestContext(request)) This means that in each view.py file i have to add from django.template import RequestContext and in each response i have to explicitly specify context_instance=RequestContext(request). Is there a way to automatically (DRY) add MEDIA_URL to the default context? Thanks in advance.

    Read the article

  • Django: url and content creation results in 500 and no apache error log entry

    - by user1684082
    If i try to open a created url i get an 500 error. My procedure was: First python manage.py startapp black I added in project/settings.py under INSTALLED_APPS 'black', I added in project/urls.py url(r'^test/', include('black.urls')), Content of black/urls.py is: from django.conf.urls import patterns, url from black import views urlpatterns = patterns('', url(r'^$', views.index, name='index') ) And content of black/views.py: from django.http import HttpResponse def index(request): return HttpResponse("SHOW ME: BLACK") After all i synced the database. I can't see any error in apache-error-log and also not in my posted django files. What could cause this?

    Read the article

  • PHP CURL sending POST to Django app issue

    - by Felipe Pelá
    This code in PHP sends a HTTP POST to a Django app using CURL lib. I need that this code sends POST but redirect to the page in the same submit. Like a simple form does. The PHP Code: $c = curl_init(); curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); curl_setopt($c, CURLOPT_URL, "http://www.xxx.com"); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, 'Var='.$var); curl_exec($c); curl_close ($c); In this case, the PHP is sending the HTTP POST, but is not redirecting to the page. He is printing the result. My URL still .php and not a django/url/ I need be redirected to the django URL with the Post like a simple form in HTML does. Any Idea? Thanks.

    Read the article

  • Can Django flush its database(s) between every unit test

    - by mikem
    Django (1.2 beta) will reset the database(s) between every test that runs, meaning each test runs on an empty DB. However, the database(s) are not flushed. One of the effects of flushing the database is the auto_increment counters are reset. Consider a test which pulls data out of the database by primary key: class ChangeLogTest(django.test.TestCase): def test_one(self): do_something_which_creates_two_log_entries() log = LogEntry.objects.get(id=1) assert_log_entry_correct(log) log = LogEntry.objects.get(id=2) assert_log_entry_correct(log) This will pass because only two log entries were ever created. However, if another test is added to ChangeLogTest and it happens to run before test_one, the primary keys of the log entries are no longer 1 and 2, they might be 2 and 3. Now test_one fails. This is actually a two part question: Is it possible to force ./manage.py test to flush the database between each test case? Since Django doesn't flush the DB between each test by default, maybe there is a good reason. Does anyone know?

    Read the article

  • Design Documents for Python/Django?

    - by british_trader
    After working on a Django project for a while, I now have to do some design documents for it (UML type stuff). However the code doesn't have classes, but instead uses views.py with modules in it... What would be the best way to show the design of my application from the initial __init__.py, to the urls.py where the HTML requests are then filtered to the specific urls.py in each of the packages and then handled by the views.py? i.e. django-app urls.py views.py settings.py manager.py __init__.py django-package urls.py views.py

    Read the article

  • django/apache permissions problem

    - by Kevin
    I'm running a django project on Centos 5.4 and serving it with httpd/mod_wsgi. I can't figure out the correct permissions for /home/website/django_project so that I don't get a 403 error. In my httpd.conf the user and group to run httpd as is apache. The group django is set up with website and apache as members. The owner of /home/website and all subdirs is website:django, and the permissions are rwxrwx---. Right now the project works fine with the dev server, but if I try to view it through apache, I get a 403 error. chmod -R o+rx /home/website/django_project fixes the problem, but this obviously isn't a good solution. Thanks

    Read the article

  • Django logging in and out - doesn't work if prepend_www set

    - by ropz
    I'm a Django beginner. My site - let's call it abc.com - works fine, letting users log in and out (having originally registered via Django registratiaon). If it's relevant, my virtuahosts file has ServerName abc.com and ServerAlias www.abc.com directives. I don't want my visitors to sense that both abc.com and www.abc.com exist, and so discovered Django's prepend_www setting, which works as intended. In addition to working as intended, however, there's a side effect that disables logging in and out when visiting the www. variant of my site.

    Read the article

  • How to solve 404 for static files with Django and Nginx?

    - by Lucio
    I setup a Trusty VM with Django + Nginx (other stuffs too). The server is working, I get the "Welcome to Django" page. But when I enter to servername/admin it loads the HTML page but fails to load the static content. And the admin page have this links to static content: <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" /> <link rel="stylesheet" type="text/css" href="/static/admin/css/login.css" /> Both of the CSS files give me 404, as the Nginx log shows: 192.168.56.1 - - [05/Jun/2014:12:04:09 -0300] "GET /admin HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0" 192.168.56.1 - - [05/Jun/2014:12:04:09 -0300] "GET /admin/ HTTP/1.1" 200 833 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0" 192.168.56.1 - - [05/Jun/2014:12:04:10 -0300] "GET /static/admin/css/base.css HTTP/1.1" 404 142 "http://ubuntu-server/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0" 192.168.56.1 - - [05/Jun/2014:12:04:10 -0300] "GET /static/admin/css/login.css HTTP/1.1" 404 142 "http://ubuntu-server/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0" I think that the error is on my nginx.conf file, but do not know how to solve it.

    Read the article

  • Paypal development. encrypt transactions. php p12

    - by ninchen
    when i take a look at the paypal documentation, they say "Note that the PayPal SDK for PHP does not require SSL encryption". https://developer.paypal.com/docs/classic/api/apiCredentials/#encrypting-your-certificate Is the statement of this phrase, that i don't have to create a p12 certificate when working with php, but use the public_key.pem and paypal_public_key.pem? If yes: Is it secure enough to create the encrypted form input elements without p12 certificate? If no: What do they mean? :-) Before this question came up, i've tested this little programm. http://www.softarea51.com/blog/how-to-integrate-your-custom-shopping-cart-with-paypal-website-payments-standard-using-php/ There is a config file paypal-wps-config.inc.php where i can define the paths to my certificates. // tryed to use // 'paypal_cert.p12 '; $config['private_key_path'] = '/home/folder/.cert/pp/prvkey.pem'; // must match the one you set when you created the private key $config['private_key_password'] = ''; //'my_password'; When i try to use the p12 certificate, openssl_error_string() returns "Could not sign data: error:0906D06C:PEM routines:PEM_read_bio:no start line openssl_pkcs7_sign When i instead use the prvkey.pem without password all works fine. Here is the function, which signs and encrypt the data. function signAndEncrypt($dataStr_, $ewpCertPath_, $ewpPrivateKeyPath_, $ewpPrivateKeyPwd_, $paypalCertPath_) { $dataStrFile = realpath(tempnam('/tmp', 'pp_')); $fd = fopen($dataStrFile, 'w'); if(!$fd) { $error = "Could not open temporary file $dataStrFile."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } fwrite($fd, $dataStr_); fclose($fd); $signedDataFile = realpath(tempnam('/tmp', 'pp_')); **// here the error came from** if(!@openssl_pkcs7_sign( $dataStrFile, $signedDataFile, "file://$ewpCertPath_", array("file://$ewpPrivateKeyPath_", $ewpPrivateKeyPwd_), array(), PKCS7_BINARY)) { unlink($dataStrFile); unlink($signedDataFile); $error = "Could not sign data: ".openssl_error_string(); return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($dataStrFile); $signedData = file_get_contents($signedDataFile); $signedDataArray = explode("\n\n", $signedData); $signedData = $signedDataArray[1]; $signedData = base64_decode($signedData); unlink($signedDataFile); $decodedSignedDataFile = realpath(tempnam('/tmp', 'pp_')); $fd = fopen($decodedSignedDataFile, 'w'); if(!$fd) { $error = "Could not open temporary file $decodedSignedDataFile."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } fwrite($fd, $signedData); fclose($fd); $encryptedDataFile = realpath(tempnam('/tmp', 'pp_')); if(!@openssl_pkcs7_encrypt( $decodedSignedDataFile, $encryptedDataFile, file_get_contents($paypalCertPath_), array(), PKCS7_BINARY)) { unlink($decodedSignedDataFile); unlink($encryptedDataFile); $error = "Could not encrypt data: ".openssl_error_string(); return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($decodedSignedDataFile); $encryptedData = file_get_contents($encryptedDataFile); if(!$encryptedData) { $error = "Encryption and signature of data failed."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($encryptedDataFile); $encryptedDataArray = explode("\n\n", $encryptedData); $encryptedData = trim(str_replace("\n", '', $encryptedDataArray[1])); return array("status" => true, "encryptedData" => $encryptedData); } // signAndEncrypt } // PPCrypto The main questions: 1. Is it possible to use p12 cert with php, or is it secure enough to work without it? 2. Why i become an error when using openssl_pkcs7_sign Please help. Greetings ninchen

    Read the article

  • Trouble getting SSL to work with django + nginx + wsgi

    - by Kevin
    I've followed a couple of examples for Django + nginx + wsgi + ssl, but I can't get them to work. I simply get an error in my browser than I can't connect. I'm running two websites off the host. The config files are identical except for the ip addresses, server names, and directories. When neither use SSL, they work fine. When I try to listen on 443 with one of them, I can't connect to either. My config files are below, and any suggestions would be appreciated. server{ listen xxx.xxx.xxx.xxx:80; server_name sub.domain.com; access_log /home/django/logs/nginx_customerdb_http_access.log; error_log /home/django/logs/nginx_customerdb_http_error.log; location / { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; } location /site_media/ { alias /home/django/customerdb_site_media/; } location /admin-media/ { alias /home/django/django_admin_media/; } } server{ listen xxx.xxx.xxx.xxx:443; server_name sub.domain.com; access_log /home/django/logs/nginx_customerdb_http_access.log; error_log /home/django/logs/nginx_customerdb_http_error.log; ssl on; ssl_certificate sub.domain.com.crt; ssl_certificate_key sub.domain.com.key; ssl_prefer_server_ciphers on; location / { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Protocol https; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; } location /site_media/ { alias /home/django/customerdb_site_media/; } location /admin-media/ { alias /home/django/django_admin_media/; } } <VirtualHost *:8080> ServerName xxx.xxx.xxx.xxx ServerAlias xxx.xxx.xxx.xxx LogLevel warn ErrorLog /home/django/logs/apache_customerdb_error.log CustomLog /home/django/logs/apache_customerdb_access.log combined WSGIScriptAlias / /home/django/customerdb/apache/django.wsgi WSGIDaemonProcess customerdb_wsgi processes=4 threads=5 WSGIProcessGroup customerdb_wsgi SetEnvIf X-Forwarded-Protocol "^https$" HTTPS=on </VirtualHost> UDPATE: the existence of two sites (on separate IPs) on the host is the issue. if i delete the other site, the setting above mostly work. doing so also brings up another issue: chrome doesn't accept the site as secure saying that some content is not encrypted.

    Read the article

  • Django | Apache | Deploy website behind SSL

    - by planet260
    So here are my requirements. I have a website built in Django. I deployed it on Apache Ubuntu. Before there was no SSL involved so the deployment was pretty simple. But now the requirements are changed. Now I have to take a few actions like signup and login behind SSL and present the admin panel and other normally via HTTP. By following the this tutorial I have set-up Apache and SSL and generated certificates for SSL communication. But I am not sure how to proceed, ie. how to serve only a few of my actions through SSL. Below is my configuration. The normal actions are working fine but I don't know how to configure SSL calls. WSGIScriptAlias / /home/ubuntu/myproject/src/myproject/wsgi.py WSGIPythonPath /home/ubuntu/myproject/src <VirtualHost *:80> ServerName mydomain.com <Directory /home/ubuntu/myproject/src/myproject> <Files wsgi.py> order deny,allow Allow from all </Files> </Directory> Alias /static/admin/ "/home/ubuntu/myproject/src/static/admin/" <Directory "/home/ubuntu/myproject/src/static/admin/"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> <Location "/login"> RewriteEngine on RewriteRule /admin(.*)$ https://mydomain.com/login$1 [L,R=301] </Location> </VirtualHost> <VirtualHost *:443> ServerName mydomain.com SSLEngine on SSLOptions +StrictRequire SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key <Directory /home/ubuntu/myproject/src/myproject> <Files wsgi.py> order deny,allow Allow from all </Files> </Directory> Alias /static/admin/ "/home/ubuntu/myproject/src/static/admin/" <Directory "/home/ubuntu/myproject/src/static/admin/"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> </VirtualHost> Can you please help me out on how to achieve this? What am I doing wrong? I have read a lot of tutorials but honestly I am not really good at configurations. Any help is appreciated.

    Read the article

  • Paying by Cash

    - by David Dorf
    I'll grant you paying by cash in the context of stores isn't particularly interesting, but in my quest to try new payment methods I decided to pay by cash at an online store. Using a credit card means I have to hoist myself off the couch, find the card, and enter all those digits. Google Checkout certainly makes that task easier by storing my credit card information, but what happens to all those people that don't have a credit card? What about the ones that are afraid to use credit cards over the internet. There are three main options for cash payment, not all of which are accepted by every merchant. The most popular is PayPal. The issue I have with them is that returns and disputes have to be handled with PayPal, not the merchant. I once used PayPal at a shady online store and lost my money. Yeah, my bad but they wouldn't help me at all. PayPal was purchased by eBay in 2002. BillMeLater is best for larger purchases, because at checkout they actually run a credit check to make sure you're credit worthy. Assuming you are, they pay the merchant on your behalf and mail you a bill, which you better pay quickly or interest will start to accrue. That's nice for the merchant because they get paid right away, and I presume there's no charge-backs. BillMeLater was purchased by eBay in 2008. Last night I tried eBillMe for the first time. After checkout, they send you a bill via email and expect you to pay either via online banking (they provide the instructions to set everything up) or walk-in locations across the US (typically banks). The process was quick and easy. The merchant doesn't ship the product until the bill is paid, so there's a day or two delay. For the merchant there are no charge-backs, and the fees are less than credit cards. For the shopper, they provide buyer protection similar to that offered by credit cards, and 1% cashback on purchases. Once the online bill-pay is setup, its easy to reuse in the future. Seems like a win-win for merchants and shoppers.

    Read the article

  • Authorize.net CIM or using the module's storage

    - by CQM
    this site is intended to allow users to sign up and pay for a service, they will be able to pay using Paypal and Authorize.net since I am using two different payment gateways, it makes me wonder where I want to keep the user information. Authorize.net offers CIM, but some users will pay with paypal therefore Authorize.net won't have all user's information Would the best solution then be to not use CIM and store everything within my member database module? for the record I am using OSE for Joomla for my subscriber service

    Read the article

  • Can't get python.manage.py syncdb to work

    - by Diego
    I just created my first django app, initialized variables DATABASE_ENGINE and DATABASE_NAME in settings.py, but now when I run python manage.py syncdb, I get the following error Can somebody help? Does this have to do with having two python versions installed? I'm a django/python noob, please help. thanks!! my-computer:~/Django-1.1.1 mycomp$ python manage.py syncdb /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'manage.py': [Errno 2] No such file or directory my-computer:~/Django-1.1.1 mycomp$ export PATH=/Users/mycomp/bin:$PATH

    Read the article

  • How to serve static files for multiple Django projects via nginx to same domain

    - by thanley
    I am trying to setup my nginx conf so that I can serve the relevant files for my multiple Django projects. Ultimately I want each app to be available at www.example.com/app1, www.example.com/app2 etc. They all serve static files from a 'static-files' directory located in their respective project root. The project structure: Home Ubuntu Web www.example.com ref logs app app1 app1 static bower_components templatetags app1_project templates static-files app2 app2 static templates templatetags app2_project static-files app3 tests templates static-files static app3_project app3 venv When I use the conf below, there are no problems for serving the static-files for the app that I designate in the /static/ location. I can also access the different apps found at their locations. However, I cannot figure out how to serve all of the static files for all the apps at the same time. I have looked into using the 'try_files' command for the static location, but cannot figure out how to see if it is working or not. Nginx Conf - Only serving static files for one app: server { listen 80; server_name example.com; server_name www.example.com; access_log /home/ubuntu/web/www.example.com/logs/access.log; error_log /home/ubuntu/web/www.example.com/logs/error.log; root /home/ubuntu/web/www.example.com/; location /static/ { alias /home/ubuntu/web/www.example.com/app/app1/static-files/; } location /media/ { alias /home/ubuntu/web/www.example.com/media/; } location /app1/ { include uwsgi_params; uwsgi_param SCRIPT_NAME /app1; uwsgi_modifier1 30; uwsgi_pass unix:///home/ubuntu/web/www.example.com/app1.sock; } location /app2/ { include uwsgi_params; uwsgi_param SCRIPT_NAME /app2; uwsgi_modifier1 30; uwsgi_pass unix:///home/ubuntu/web/www.example.com/app2.sock; } location /app3/ { include uwsgi_params; uwsgi_param SCRIPT_NAME /app3; uwsgi_modifier1 30; uwsgi_pass unix:///home/ubuntu/web/www.example.com/app3.sock; } # what to serve if upstream is not available or crashes error_page 400 /static/400.html; error_page 403 /static/403.html; error_page 404 /static/404.html; error_page 500 502 503 504 /static/500.html; # Compression gzip on; gzip_http_version 1.0; gzip_comp_level 5; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; # Some version of IE 6 don't handle compression well on some mime-types, # so just disable for them gzip_disable "MSIE [1-6].(?!.*SV1)"; # Set a vary header so downstream proxies don't send cached gzipped # content to IE6 gzip_vary on; } Essentially I want to have something like (I know this won't work) location /static/ { alias /home/ubuntu/web/www.example.com/app/app1/static-files/; alias /home/ubuntu/web/www.example.com/app/app2/static-files/; alias /home/ubuntu/web/www.example.com/app/app3/static-files/; } or (where it can serve the static files based on the uri) location /static/ { try_files $uri $uri/ =404; } So basically, if I use try_files like above, is the problem in my project directory structure? Or am I totally off base on this and I need to put each app in a subdomain instead of going this route? Thanks for any suggestions TLDR: I want to go to: www.example.com/APP_NAME_HERE And have nginx serve the static location: /home/ubuntu/web/www.example.com/app/APP_NAME_HERE/static-files/;

    Read the article

  • Looking for a good example usage of get_or _create in Django views and raising a Form error

    - by Rik Wade
    I am looking for a good example of how to achieve the following: I would like to use get_or_create to check whether an object already exists in my database. If it does not, then it will be created. If it does exist, then I will not create the new object, but need to raise a form error to inform the user that they need to enter different data (for example, a different username). The view contains: p, created = Person.objects.get_or_create( email = registration_form.cleaned_data['email'], defaults = { 'creationDate': datetime.datetime.now(), 'dateOfBirth': datetime.date(1970,1,1) }) So 'p' will contain the existing Person if it exists, or the new Person if not. I would like to act on the boolean value in 'created' in order to skip over saving the Person and re-display the registration_form and raise an appropriate form validation error. The alternative I'm considering is doing a check in a custom Form validation method to see whether a Person exists with the data in the provided 'email' field, and just raising a validation error.

    Read the article

  • Django QuerySet API: How do I join iexact and icontains?

    - by Zeynel
    Hello, I have this join: lawyers = Lawyer.objects.filter(last__iexact=last_name).filter(first__icontains=first_name) This is the site If you try Last Name: Abbas and First Name: Amr it tells you that amr abbas has 1 schoolmates. But if you try First name only it says that there are no lawyers in the database called amr (obviously there is). If I change (last__iexact=last_name) to (last__icontains=last_name) then leaving Last Name blank works fine and amr is found. But with last__icontains=last_name if you search for "collin" you also get "collins" and "collingwood" which is not what I want. Do you know how I can use iexact and also have it ignored if it is blank? Thanks This is the view function: def search_form(request): if request.method == 'POST': search_form = SearchForm(request.POST) if search_form.is_valid(): last_name = search_form.cleaned_data['last_name'] first_name = search_form.cleaned_data['first_name'] lawyers = Lawyer.objects.filter(last__iexact=last_name).filter(first__icontains=first_name) if len(lawyers)==0: form = SearchForm() return render_to_response('not_in_database.html', {'last': last_name, 'first': first_name, 'form': form}) if len(lawyers)>1: form = SearchForm(initial={'last_name': last_name}) return render_to_response('more_than_1_match.html', {'lawyers': lawyers, 'last': last_name, 'first': first_name, 'form': form}) q_school = Lawyer.objects.filter(last__icontains=last_name).filter(first__icontains=first_name).values_list('school', flat=True) q_year = Lawyer.objects.filter(last__icontains=last_name).filter(first__icontains=first_name).values_list('year_graduated', flat=True) lawyers1 = Lawyer.objects.filter(school__iexact=q_school[0]).filter(year_graduated__icontains=q_year[0]).exclude(last__icontains=last_name) form = SearchForm() return render_to_response('search_results.html', {'lawyers': lawyers1, 'last': last_name, 'first': first_name, 'form': form}) else: form = SearchForm() return render_to_response('search_form.html', {'form': form, })

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >