Title
stringlengths
11
150
A_Id
int64
518
72.5M
Users Score
int64
-42
283
Q_Score
int64
0
1.39k
ViewCount
int64
17
1.71M
Database and SQL
int64
0
1
Tags
stringlengths
6
105
Answer
stringlengths
14
4.78k
GUI and Desktop Applications
int64
0
1
System Administration and DevOps
int64
0
1
Networking and APIs
int64
0
1
Other
int64
0
1
CreationDate
stringlengths
23
23
AnswerCount
int64
1
55
Score
float64
-1
1.2
is_accepted
bool
2 classes
Q_Id
int64
469
42.4M
Python Basics and Environment
int64
0
1
Data Science and Machine Learning
int64
0
1
Web Development
int64
1
1
Available Count
int64
1
15
Question
stringlengths
17
21k
PySerial - Max baud rate for platform (windows)
41,058,265
2
3
3,411
0
python,pic,pyserial,ftdi
So I found that the rounded numbers didn't work i.e. 100000, 200000, 250000 but the multiples of 115200 do. i.e. 230400, 460800 I tried to use 230400 at first but the baud rate my microcontroller can produce is either 235294 or 222222. 235294 yields an error of -2.1% and 222222 yields an error of 3.55%. I naturally picked the one with the lower error however it didn't work and didn't bother trying 222222. For some reason 222222 works when 235294 though. So I don't actually have to use the 250000 baud rate I initially thought I'd have to. I still don't know why pyserial doesn't work with those baud rates when putty does, so clearly my laptop can physically do it. Anyway will know in future to try more standard baud rates as well as when using microcontrollers which can't produce the exact baud rate required to try frequencies both above and below.
0
0
0
1
2016-12-07T16:45:00.000
1
0.379949
false
41,022,923
0
0
1
1
I'm trying to get pySerial to communicate with a microcontroller over an FTDI lead at a baud rate of 500,000. I know my microcontroller and FTDI lead can both handle it as can my laptop itself, as I can send to a putty terminal at that baud no problem. However I don't get anything when I try to send stuff to my python script with pySerial, although the same python code works with a lower baud rate. The pySerial documentation says: "The parameter baudrate can be one of the standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. These are well supported on all platforms. Standard values above 115200, such as: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 also work on many platforms and devices." So, I'm assuming why it's not working is because my system doesn't support it, but how do I check what values my system supports/is there anything I can do to make it work? I unfortunately do need to transmit at least 250,000 and at a nice round number like 250,000 or 500000 (to do with clock error on the microcontroller). Thanks in advance for your help!
microservices and multiple databases
41,049,986
2
3
426
1
python,django,rabbitmq,celery
I am wondering if there is any better way to do this? "better" is entirely subjective. if it meets your needs, it's fine. something to consider, though: don't store the same information in more than one place. if you need an address, look it up from the service that provides address, every time. this may be a performance hit, but it eliminates the problem of replicating the data everywhere. another option would be a more proactive approach, as suggested in comments. instead of creating a task list for changes, and doing that periodically, send a message across rabbitmq immediately when the change happens. let every service that needs to know, get a copy of the message and update it's own cache of info. just remember, though. every time you have more than one copy of the information, you reduce the "correctness" of the system, as a whole. it will always be possible for the information found in one of your apps to be out of date, because it did not get an update from the official source.
0
0
0
0
2016-12-08T16:06:00.000
1
0.379949
false
41,043,800
0
0
1
1
i have written MicroServices like for auth, location, etc. All of microservices have different database, with for eg location is there in all my databases for these services.When in any of my project i need a location of user, it first looks in cache, if not found it hits the database. So far so good.Now when location is changed in any of my different databases, i need to update it in other databases as well as update my cache. currently i made a model (called subscription) with url as its field, whenever a location is changed in any database, an object is created of this subscription. A periodic task is running which checks for subscription model, when it finds such objects it hits api of other services and updates location and updates the cache. I am wondering if there is any better way to do this?
Google App Engine SDK path in linux for pycharm?
41,059,077
3
2
1,232
0
python,google-app-engine,pycharm,google-cloud-platform
The correct path to use is the platform/google_appengine/ directory, within the google-cloud-sdk installation directory,
0
1
0
0
2016-12-09T11:09:00.000
2
1.2
true
41,059,076
0
0
1
1
While configuring pycharm (professional) for Google App engine it asks for App Engine SDK path, while google now gives everything bundled in a Google cloud SDK. On choosing the cloud SDK directory, pycharm is saying it's invalid. What is the correct path for Google App engine SDK?
Python/ Django- Internal Server Error after performing a soft reset
41,061,561
0
0
429
0
python,django,git
If you're getting a 'bad gateway', that means you're using something like Nginx or Apache to route requests to your app. A Bad Gateway error means that Nginx (substitute Apache if appropriate, I'll just use nginx here) isn't getting a response from the app server - your runserver equivalent isn't serving the app, or the app is returning a 500 error. The app server is usually served with gunicorn, uwsgi or sometimes just plain ol' runserver (but please don't do this in production!) You can access your nginx logs at /var/log/nginx/error.log - it'll probably say connect() failed (110: Connection timed out) while connecting to upstream, with an IP address. SSH to your server, run the virtualenv if you have one. If gunicorn is running, stop it. Do which gunicorn (again, substitute uwsgi if appropriate) to get the location, and run that manually: /etc/gunicorn/gunicorn -b 127.0.0.1:8000 -w 1 myapplication.wsgi and note the error message. You can also get this by doing runserver to see what's happening - if the app loads, then go to the website and see what the error message is in your terminal console. It's probably a misconfiguration that's stopping the app from running - that's where you'll get your more detailed debug information.
0
0
0
0
2016-12-09T12:44:00.000
1
0
false
41,060,813
0
0
1
1
I recently made some changes to my Python/ Django project, and this caused one of the pages to display a 'Bad Gateway' message in the browser. I was unable to resolve this, so tried doing a 'soft reset' to the last working commit I had made. However, I am now getting an Internal Server Error when trying to view the website on the live server. The error message doesn't give any more information than this... but when I view my project locally in the browser, it works as expected. I've tried committing my local version, pushing it to the server, and then pulling it on the server again, but on the master branch on my local machine and on the server, I get a message telling that there's "nothing to commit, working directory clean". How can I resolve this Internal Server Error to ensure that my site is accessible again?
Link excel calculator to online HTML app?
41,067,457
0
0
63
0
python,html,css,excel,calculator
Does your work have office 365? You can host the excel file online for everyone to access. It works just like normal excel does but it is througt the online interface. Buttons and everything should work. Math isn't hard to do with javascript and you can learn super quickly on codeacademy (it's the first thing they teach) and how to display those numbers. Including prompting users for input if you want to go that route.
0
0
0
0
2016-12-09T19:03:00.000
1
1.2
true
41,067,232
0
0
1
1
I am trying to convert a large excel calculator into an online website for people to freely use. I have been working on this project for a few months now, and the equations within the excel sheets that are used to derive the answers are too complicated for me to program it from the ground up. Are there any easy ways to take an excel calculator (workbook with 5 sheets) and turn it into a web app? Any assistance or guidance would be appreciated. I have also tried opening the document in python using OpenpyXL and manipulating it that way, but it doesn't work. Web design is totally out of my area of expertise, but I told my employer I would try anyway. Again, I appreciate any assistance.
How to find if a model was saved from Django Admin, or elsewhere
41,083,650
1
2
808
0
python,django,django-admin
Since you don't need to create the related model thanks to the presence of the InlineAdmin perhaps it would be better for you to remove the post_save signal receiver rather than adding more code inside post_save to determine where the save originated from. That way you can just place a call to create_related_models in your serializer's create method to achieve the same objective.
0
0
0
0
2016-12-10T06:58:00.000
2
1.2
true
41,073,034
0
0
1
1
Is there a way to identify if the current save() or post_save happened via Django Admin? I want to do something differently for models saved via Admin, than models saved from my Django Rest Framework API. Specifically, I have a create_related_objects I call on post_save of model Transaction, to create related object CalendarInfo. But when creating Transaction via Admin, because the related CalendarInfo object is an inline, I don't need to call that create_related_objects on the Transaction model's post_save.
Install Flask in Python 3.4+ NOT for python2.7
41,091,835
0
0
1,368
0
python,flask,dependencies,virtualenv
If you are using Pycharm just switch to python 3, and there is a list of packages installed. Hit add(+), and look for flask You can switch to python 3 by hitting file-> setting -> Project:Projectname -> Project Interpreter
0
0
0
0
2016-12-11T21:31:00.000
2
0
false
41,091,357
1
0
1
1
So, I know how to actually install flask, via pip install Flask But, I'm running a virtualenv with python3.4. The problem is, Flask is in fact installed. The problem is though, it is installed for python2.7 and not python3.4 . I did run this command with the virtualenv activated via source bin/activate , but it seems to install it for python2.7 even though a virtualenv running python3.4 is activated. How do I fix this? im pulling my hair out over this. Thanks
How to run python, java, php, nodejs,ruby applications on same vps?
41,095,058
0
2
900
0
python,ruby,node.js,apache,nginx
Any user can run any service on a VPS. Just make sure that you are not conflicting with available ports in your services.
0
0
0
0
2016-12-12T03:17:00.000
3
0
false
41,093,725
0
0
1
1
How to run python(Django,Flask), Java(spring),PHP, Nodejs(express),Ruby(rails) application on same VPS.If it is possible on VPS, can we do similar on Reseller Hosting where we have SSH Access. I have readed on some other Articles they.. suggests to Use "Virtual Host" in Apache. Also which one is better NGINX or Apache for same..?
I accidentally deleted django_admin_log and now i can not use the django admin
47,960,936
0
1
2,274
1
python,django,django-admin
After ./manage.py sqlmigrate admin 0001, please run python manage.py migrate.
0
0
0
0
2016-12-12T05:56:00.000
3
0
false
41,094,926
0
0
1
2
I get this error "ProgrammingError at /admin/ relation "django_admin_log" does not exist LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_ad..." django_admin_log table does not exist in the database. Does anyone know how I can create it? I am not worried about deleting the data for my app. when i try './manage.py sqlmigrate admin 0001' or './manage.py sqlmigrate admin 0001' i get " BEGIN; -- Create model LogEntry CREATE TABLE "django_admin_log" ("id" serial NOT NULL PRIMARY KEY, "action_time" timestamp with time zone NOT NULL, "object_id" text NULL, "object_repr" varchar(200) NOT NULL, "action_flag" smallint NOT NULL CHECK ("action_flag" >= 0), "change_message" text NOT NULL, "content_type_id" integer NULL, "user_id" integer NOT NULL); ALTER TABLE "django_admin_log" ADD CONSTRAINT "django_admin_content_type_id_c4bce8eb_fk_django_content_type_id" FOREIGN KEY ("content_type_id") REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED; ALTER TABLE "django_admin_log" ADD CONSTRAINT "django_admin_log_user_id_c564eba6_fk_auth_user_id" FOREIGN KEY ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED; CREATE INDEX "django_admin_log_417f1b1c" ON "django_admin_log" ("content_type_id"); CREATE INDEX "django_admin_log_e8701ad4" ON "django_admin_log" ("user_id"); COMMIT;" but i still get the same error? i use postgresql if anyone cares.
I accidentally deleted django_admin_log and now i can not use the django admin
60,692,503
2
1
2,274
1
python,django,django-admin
experienced the same issue, the best way is to copy the CREATE TABLE log, login to your database ./manage.py dbshell and Paste the content over there without adding the last line (COMMIT ) it will solve the problem and manually create the table for you.
0
0
0
0
2016-12-12T05:56:00.000
3
0.132549
false
41,094,926
0
0
1
2
I get this error "ProgrammingError at /admin/ relation "django_admin_log" does not exist LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_ad..." django_admin_log table does not exist in the database. Does anyone know how I can create it? I am not worried about deleting the data for my app. when i try './manage.py sqlmigrate admin 0001' or './manage.py sqlmigrate admin 0001' i get " BEGIN; -- Create model LogEntry CREATE TABLE "django_admin_log" ("id" serial NOT NULL PRIMARY KEY, "action_time" timestamp with time zone NOT NULL, "object_id" text NULL, "object_repr" varchar(200) NOT NULL, "action_flag" smallint NOT NULL CHECK ("action_flag" >= 0), "change_message" text NOT NULL, "content_type_id" integer NULL, "user_id" integer NOT NULL); ALTER TABLE "django_admin_log" ADD CONSTRAINT "django_admin_content_type_id_c4bce8eb_fk_django_content_type_id" FOREIGN KEY ("content_type_id") REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED; ALTER TABLE "django_admin_log" ADD CONSTRAINT "django_admin_log_user_id_c564eba6_fk_auth_user_id" FOREIGN KEY ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED; CREATE INDEX "django_admin_log_417f1b1c" ON "django_admin_log" ("content_type_id"); CREATE INDEX "django_admin_log_e8701ad4" ON "django_admin_log" ("user_id"); COMMIT;" but i still get the same error? i use postgresql if anyone cares.
How to limit number of active logins in Flask
59,997,976
0
3
1,075
0
python,authentication,flask,flask-security
There could be several ways off the top of my head you approach this, none of them striking a nice balance between simplicity and effectiveness: One way could be to add a last_seen field to your User. Pick some arbitrary number(s) that could serve as a heuristic to determine whether someone is "active". Any sufficiently long gap in activity could trigger a reset of the active_login_count. This obviously has many apparent loopholes, the biggest I see at the moment being, users could simply coordinate logins and potentially rack up an unlimited number of active sessions without your application being any the wiser. It's a shame humans in general tend to use similar "logical" mechanisms to run their entire lives; but I digress... You could make this approach more sophisticated by trying to track the user's active ip addresses. Add an active_ips field and populate a list of (n) ips, perhaps with some browser information etc to try and fingerprint users' devices and manage it that way. Another way is to use an external service, such as a Redis instance or even a database. Create up to (n) session ids that are passed around in the http headers and which are checked every time the api is hit. No active session id, or if the next session id would constitute a breach of contract, no access to the app. Then you simply clear out those session ids at regular intervals to keep them fresh. Hopefully that gives you some useful ideas.
0
0
0
0
2016-12-13T15:32:00.000
1
0
false
41,124,843
0
0
1
1
I'm trying to write a basic Flask app that limits the number of active logins a user can have, a la Netflix. I'm using the following strategy for now: Using Flask_Security store a active_login_count field for my User class. every time a successful login request is completed, the app increases the active_login_count by 1. If doing so makes the count greater than the limit, it calls logout_user() instead. This is a bad solution, because if the user loses her session (closed the incognito mode without logging out), the app hasn't been able to decrement her login count, and so, future logins are blocked. One solution is to store the sessions on the server, but I don't know how I would go about authenticating valid sessions. Flask_Sessions is something I'm looking into, but I have no idea how to limit the number of active sessions. As per my understanding, in the default configuration, Flask generates new session cookies on every request to prevent CSRF attacks. How would I go about doing that?
PyCharm is terribly slow when editing HTML / CSS / JS
41,154,218
6
6
2,026
0
javascript,python,html,pycharm,jetbrains-ide
There are two solutions: You can disable HTML / CSS / JS inspections in Preferences -> Editor -> Inspections. If your project has a decent amount of third-party libraries (jquery, bootstrap etc.), this might be the reason. Don't index directories with these libraries: right click on a folder and then choose Mark Directory As -> Excluded. Don't forget to clear the cache: File -> Invalidate Caches / Restart.
0
0
0
0
2016-12-14T23:51:00.000
1
1.2
true
41,154,217
1
0
1
1
PyCharm becomes nearly unresponsive in 5 minutes of editing HTML / CSS / JS code – even typing a single character causes a several seconds lag. However, everything is absolutely fine when I work with Python. I don't close PyCharm for days and it works smooth. Restarting PyCharm helps only for a few minutes. I'm on PyCharm 5.0.5 Professional & OS X 10.11.
Transfer PDF files between servers in python
41,170,783
1
0
1,341
0
python,api,pdf
I wanted to share my solution to this, but give credit to @CoolqB for the answer. The key was including 'rb' to properly read the binary file and including the codecs library. Here are the final code snippets: Client request: response = requests.get('https://www.mywebsite.com/_api_call') Server response: f = codecs.open(file_name, 'rb').read() return f Client handle: with codecs.open(file_to_write, 'w') as f: f.write(response.content) f.close() And all is right with the world.
0
0
1
0
2016-12-15T00:10:00.000
2
0.099668
false
41,154,360
0
0
1
2
We have two servers (client-facing, and back-end database) between which we would like to transfer PDFs. Here's the data flow: User requests PDF from website. Site sends request to client-server. Client server requests PDF from back-end server (different IP). Back-end server sends PDF to client server. Client server sends PDF to website. 1-3 and 5 are all good, but #4 is the issue. We're currently using Flask requests for our API calls and can transfer text and .csv easily, but binary files such as PDF are not working. And no, I don't have any code, so take it easy on me. Just looking for a suggestion from someone who may have come across this issue.
Transfer PDF files between servers in python
41,154,455
1
0
1,341
0
python,api,pdf
As you said you have no code, that's fine, but I can only give a few suggestions. I'm not sure how you're sending your files, but I'm assuming that you're using pythons open function. Make sure you are reading the file as bytes (e.g. open('<pdf-file>','rb')) Cut the file up into chunks and send it as one file, this way it doesn't freeze or get stuck. Try smaller PDF files, if this works definitely try suggestion #2. Use threads, you can multitask with them. Have a download server, this can save memory and potentially save bandwidth. Also it also lets you skip the PDF send back, from flask. Don't use PDF files if you don't have to. Use a library to do it for you. Hope this helps!
0
0
1
0
2016-12-15T00:10:00.000
2
1.2
true
41,154,360
0
0
1
2
We have two servers (client-facing, and back-end database) between which we would like to transfer PDFs. Here's the data flow: User requests PDF from website. Site sends request to client-server. Client server requests PDF from back-end server (different IP). Back-end server sends PDF to client server. Client server sends PDF to website. 1-3 and 5 are all good, but #4 is the issue. We're currently using Flask requests for our API calls and can transfer text and .csv easily, but binary files such as PDF are not working. And no, I don't have any code, so take it easy on me. Just looking for a suggestion from someone who may have come across this issue.
Bitwise in a client - server scenario miscalculating
41,157,447
0
0
35
0
python-2.7,sockets,actionscript-3,bit-shift,bitwise-or
the only way i know, is sending negative number from server for getting a same result, otherwise not possible to reversing it through server (i guess)
0
0
0
0
2016-12-15T02:47:00.000
1
0
false
41,155,598
0
0
1
1
I have been tasked with creating a server for a client. I have all of the clients' code, so using it, I must create a server. The client has a particular piece of code in a function called readInt(num1); return num1 << 24 | num1 << 16 | num1 << 8 | num1, which is called every time the client expects a type = int in the data received from a packet, and I just can't haggle with it. I tried what comes to mind first - just reverse it, right? If the int needs to be 3, do 3 >> 24, but no yield. My mind doesn't work well mathematically, and I'm not a good problem solver, so if I want, say 3 on the server to read as 3 on the client, what formula would I use server-side to achieve this? The client is in Adobe ActionScript 3, and the server in Python 2.7.12.
Does uber have an API which let user download invoice pdf?
41,212,414
1
0
106
0
python,uber-api
"Does uber have an API which let user download invoice pdf?" - No, that API does not exist.
0
0
1
0
2016-12-15T11:59:00.000
1
1.2
true
41,163,658
0
0
1
1
I have been searching for a way to get my past ride invoice. Is there any api which i can use to get my rides info/invoice. as i don't want to click on every ride and then. Just want to automate the boring stuff.
what is _origin in odoo
41,179,576
2
1
2,580
0
python-2.7,openerp,odoo-10
In an onchange context it is the old value/record which was used before the change.
0
0
0
0
2016-12-15T13:10:00.000
1
1.2
true
41,165,008
0
0
1
1
in odoo sale order line there is an onchange method _onchange_product_uom_qty() where they used a condition self.product_uom_qty < self._origin.product_uom_qty Now my question is what does self._orgin is used for what does it return? Note: 1. you can also find the origin in hr_appraisal module inside the onchange_colleagues method and somewhere in purchase 2. I does not mean this origin- "source document"`
Running Python scripts inside Android Studio
41,166,600
6
9
25,025
0
python,android-studio
If you only need to run the scripts and not to edit them, the easiest way to do so is to configure an external tool through Settings | Tools | External Tools. This doesn't require the Python plugin or any Python-specific configuration; you can simply specify the command line to execute. External tools appear as items in the Tools menu, and you can also assign keyboard shortcuts to them using Settings | Keymap.
1
0
0
1
2016-12-15T14:19:00.000
1
1.2
true
41,166,406
0
0
1
1
I am running Android Studio 2.2.3 I need to run Python scripts during my development to process some data files. The final apk does not need to run Python in the device. At the moment I run the scripts from a terminal or from PyDev for Eclipse, but I was looking for a way of doing it from Android Studio. There seems to be a way to do this, as when I right-click on a .py file and select the 'Run' option, an 'Edit configuration' dialog opens where I can configure several options. The problem is that I cannot specify the Python interpreter, having to select it from a combo box of already configured Python SDKs. While there is no interpreter selected, there is an error message stating "Error: Please select a module with a valid Python SDK". I managed to create Java modules for my project, but not Python ones (I do have the Python Community Edition plugin installed).Does anybody know how to achieve this?. TIA.
How do I configure the sqlite3 module to work with Django 1.10?
41,196,939
1
0
197
1
linux,django,python-3.x,ubuntu,sqlite
I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.
0
0
0
0
2016-12-16T05:17:00.000
1
0.197375
false
41,177,692
0
0
1
1
So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet. Please let me know how I can fix this issue so that I can use Django on my computer. :~$ python Python 3.5.2 (default, Nov 6 2016, 14:10:16) [GCC 6.2.0 20161005] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module> from sqlite3.dbapi2 import * File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: No module named '_sqlite3' >>> exit()
Usa parameter as collection name in a scrapy project
41,194,752
0
0
79
0
python,mongodb,scrapy
I've got an answer. for example: using -s collection_name=abc for scrapy crawl command, then get the parameter in pipelines.py using param = settings.get('collection_name'). This is also found in stackoverflow, but can't remember which ticket. Hope this would help some one facing same problem.
0
0
0
0
2016-12-16T07:52:00.000
1
0
false
41,179,622
0
0
1
1
The spider is to crawl info on a certain B2B website, and I want it to be a webserver, where user sumbit a url then the spider starts crawl. The url seems like: apple.b2bxxx.com, which is a minisite on a B2B website, where all the products are listed. The "apple" might be different because different companies use different names for there minisite, and duplication is not allowed. On the backend, it's MongoDB to store the data scraped. What I have done, is that, I can collect info on the given url, but all data are stored in the same db.collection. I know I can get parameters using "-a" for running scrapy, but how should I use it? Should I change the pipelines.py or the spider python file? Any suggestions?
Scrapy and Selenium: Make scrapy wait for selenium?
46,603,023
0
0
505
0
python,selenium,scrapy,web-crawler
You can use DOWNLOAD_DELAY = 0.25 in settings.py,that the downloader should wait before downloading consecutive pages from the same website. Another way you can use time.sleep() for delaying spider to get response from selenium.
0
0
1
0
2016-12-16T13:38:00.000
1
0
false
41,185,693
0
0
1
1
I have a spider that I am using to crawl a site. I only need javascript for one piece of my item. So I scrape part of the site with scrapy then open the URL in selenium. While the URL is opening scrapy continues. How do I make scrapy to wait on my selenium logic to finish? Thanks in advance.
Git- made changes on a local branch, checked out master, and master is now broken
41,188,434
2
1
110
0
python,django,git,master
Possible causes: (Git) You forgot to git add files in the conceptCalendar branch, and they are still lying around when you checkout master. (Python) You have stale .pyc files in your project. Remove them. (Django) You forgot to makemigrations in the conceptCalendar branch (Django) You ran migrate on the conceptCalendar branch, your database schema has changed, but now the code on master reflects the old schema. Rebuild your database, or migrate backwards. I'm betting my money on this last point. From the error you posted, i'm thinking that maybe a Form is extending ModelForm for a Model that changed in the other branch. Check that all fields exist in the underlying model, and in the database.
0
0
0
0
2016-12-16T16:11:00.000
1
1.2
true
41,188,326
0
0
1
1
I am working on a Python/ Django project, using Git to manage my version control. I recently made some changes on a branch called conceptCalendar3, and the changes I made broke my site. I committed the changes to that branch, and then checked out master, which, I had branched from in order to create the conceptCalendar3 branch. However, when I now to try to view my site from the localhost, on master branch (on which I have not made any changes since it was last working), I now get a message in the browser telling me that: This site can't be reached localhost refused to connect The Python console is displaying a lot of output with error messages that I've not seen before: File "/Users/.../Documents/Dev/moonhub/moon/moon/urls.py", line 27, in url(r'^costing/', include('costing.urls', namespace="costing")), File "/Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/conf/urls/init.py", line 52, in include urlconf_module = import_module(urlconf_module) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/Users/.../Documents/Dev/moonhub/moon/costing/urls.py", line 2, in from . import views File "/Users/.../Documents/Dev/moonhub/moon/costing/views.py", line 2900, in from projects.views import get_project_folder File "/Users/elgan/Documents/Dev/moonhub/moon/projects/views.py", line 38, in from .forms import * File "/Users/.../Documents/Dev/moonhub/moon/projects/forms.py", line 1207, in class PostDepMeetingForm(ValidatedForm): File "/Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/forms/models.py", line 257, in new raise FieldError(message) django.core.exceptions.FieldError: Unknown field(s) (meeting_date_time) specified for Survey The 'field' that it seems to be complaining about, meeting_date_time is one that I added on the conceptCalendar3 branch- but it doesn't exist in the code on the master branch... I have tried running git pull origin master to ensure that I have the latest version of code from the live version of the project, but this tells me that everything is up-to-date. So why can't I view a version of my site locally, and why am I getting these errors in the console? Edit I tried checking out an old commit, and at one point was in a detached head state- could it be that I am still in this detached head state, and so some of my code is point to master, but some of it is pointing to conceptCalendar? If that's the case, how would I check, and how would I resolve it?
Python reliable project setup: write data from a serial port to a database in a certain time interval
41,216,333
0
0
120
1
python,django,cron,serial-port
For detecting system shutdown compare time stamps of last reading taken to current reading's time stamp. If they differ by more than 15 minutes than something went wrong during the operation.
0
0
0
0
2016-12-18T12:48:00.000
1
0
false
41,208,473
0
0
1
1
The application should read data from a serial port every 15 minutes (using the Modbus Protocol) and put them into a database. The data can then be viewed and manipulated in a web interface. I'm using Windows (no server) with a RAID system to prevent data loss. My current setup looks like this: using pyserial and minimalmodbus for reading the data and putting them into a MySQL database setting a cron job to run the script every 15 minutes (alternatives?) using Django in order to have a neat interface where one can view stats and download the data as a *.csv file My questions are: Does this setup makes sense concerning reliability; do you have any improvements? How can i detect if the system has experienced a shutdown and i lost some data?
Override settings.py for testing
41,211,379
0
1
431
0
python,testing,settings
I suppose the easiest way would be to move your settings.py to another folder for safekeeping and then make a new one, and edit that for debugging.
0
0
0
1
2016-12-18T18:10:00.000
2
0
false
41,211,357
0
0
1
1
I have my project settings in settings.py file. There are database names, user names, host names etc. defined there. In project files I do import settings and then use the constants where needed like settings.HOST. For unit testing I would like to use different settings. How should I override the settings? I am not using django.
Deploying a Flask app with root privileges
41,215,183
2
3
4,412
0
python,apache,flask,mod-wsgi
I would not run the web server as root for security reasons. Instead, I suggest to: Add the web user to /etc/sudoers - no password. Ideally, only allow the commands you want to run as root. run the command with sudo [command] You mention deployment, if you are packaging this into an rpm, I would put the sudo definitions in /etc/sudoers.d/youpackage Another option would be to split you app and use some sort of messaging system - either by having rows in a database table or use a messaging server such as rabbit mq (there are other servers but I find it very easy to setup). A separate process running as root would do the actual turning on/off the lights. Your frontend would simply send a message like "lights off" and the other process -which could be running as root- would get a message when needed. The advantage with this approach is that the web process never has any root privilege and even if it has a hole, damage is limited.
0
0
0
1
2016-12-19T02:32:00.000
1
1.2
true
41,215,036
0
0
1
1
I host a flask web app on a Raspberry Pi that has controls for my LED light strip. It all works great when I run the server with python as the root user, but I am having difficulty deploying it with Apache mod_wsgi. I want to use htttps, so deploying it seems to be necessary, but Apache doesn't seem to allow running servers with root privileges. Root is necessary to control the lights through a library that is imported in the flask server. Is there any way to deploy a flask server with root privileges? If not, it it possible to use https (from letsencrypt.org) without deploying? Are there any other ways to get around this problem?
Django view execution order for same url pattern requests?
41,219,364
4
1
64
0
python,django,django-views
Django doesn't do anything at all. It is entirely up to the server, which has already determined (according to its configuration) whether to run Django in multiple processes and/or threads, and so distributes incoming requests among those.
0
0
0
0
2016-12-19T09:19:00.000
1
0.664037
false
41,219,281
0
0
1
1
Let we say two users access the same urls that lead two requests were send to django views. The question is, how does django deal with these two requests? Does them be handled in two different threads simultaneously or when one end it request-middleware-response life cycle then the other be handled?
Redirects in Django
41,260,630
1
0
46
0
python,django,module,connection,access-denied
I find an answer for the first part of my question. I just used the import login_required. Just before the function homepage in /helpdesk/public.py and the function index in /helpdesk/kb.py, I put @login_required(login_url='/helpdesk/login/?next=/helpdesk/) and it worked ! Now I try to find the answer of the second part (redirection).
0
0
0
0
2016-12-20T15:50:00.000
1
1.2
true
41,246,248
0
0
1
1
I'm working on the Helpdesk module from Django. I want people who try to access 192.168.x.xxx:8000/helpdesk/ are redirected to the login page: 192.168.x.xxx:8000/helpdesk/login/?next=/helpdesk/ I also want people who try to access an nonexistant page to be redirected to: the homepage if connected, or the login page if not connected.
Accessing Google App Engine Python App code in production
41,268,471
1
5
1,805
0
google-app-engine,google-app-engine-python
If you are using the standard environment, the answer is no, you can't really inspect or see the code directly. You've mentioned looking at it via Stackdriver Debugger, which is one way to see a representation of it. It sounds like if you have a reason to be looking at the code, then someone in your organization should grant you the appropriate level of access to your source code management system. I'd imagine if you're deployment practices are mature, then they'd likely branch the code to map to your deployed versions and you could inspect in detail locally.
0
1
0
0
2016-12-21T00:05:00.000
2
0.099668
false
41,253,187
0
0
1
1
(Background: I am new to Google App Engine, familiar with other cloud providers' services) I am looking for access/view similar to shell access to production node. With a Python/Django based Google App Engine App, I would like to view the code in production. One view I could find is the StackDriver 'Debug' view. However, apparently the code shown in the Debug view doesn't reflect the updated production code (based on what is showing on the production site, for example, the text on the home page different). Does Google App Engine allow me to ssh into the VM where the application/code is running? If not, how can check the code that's running in production? Thanks.
django press Enter and it show ^M
41,256,129
6
9
786
0
python,django
Better to reset the console frequently. This is not a big problem but due to multiple terminals being not reset for long durations, such problem occurs.
0
0
0
0
2016-12-21T04:00:00.000
2
1.2
true
41,254,869
0
0
1
1
I want to change my models in django when I execute python manage.py makemigrations ,it asks a question: Did you rename the demoapp.Myblog model to Blog? [y/N] y^M^M^M that I input y and press Enter,but it adds ^M to the line I've looked around and apparently but I've got no choices can anybody tell me how to fix it?
Virtual Environment for Python Django
41,279,917
7
8
15,405
0
python,django,web-applications,web
Well, this is one of the most common questions among beginners. I, myself have faced the question and did build multiple projects without worrying about the virtual environment. But, of late, I have realized the importance of using virtual environments. Some of the benefits of using virtual environments are: Dependency Management: Prevent conflicts between dependencies of multiple projects. Ease of installation and setting up new project on different machines: Store your dependencies in requirements.txt file and run pip install -r requirements.txt to install the dependencies wherever you want.
0
0
0
0
2016-12-22T09:17:00.000
6
1.2
true
41,279,547
1
0
1
4
I'm currently a novice in web programming. I've been working on this Django project lately, and I've been reading about virtual environments. At the start of my project, I was unable to set up a virtual environment, and so I proceeded with the project without it. My questions are Whether or not this virtual environment is really necessary? If I want to make more Django projects in the future, will I need this virtual environment to differentiate the projects since right now I'm running all the commands in the command prompt from my main C: directory? Does this virtual environment differentiate multiple projects or does it separate each project with respect to the version of Django/Python it's coded with or both? I'm wondering because I currently input commands such as python manage.py runserver (without the virtual environment) in my main C:drive directory. So does that mean I can't do multiple projects at once without a virtual environment for each? Can I still work on multiple projects without a virtual environment? (I've been confused about this especially) Should I just try to set up a virtual environment for my next project or can I still do it for this current one (I'm halfway through the project already, I've already made models, views, templates, etc.)? Any answers to clarify my confusion is greatly appreciated!
Virtual Environment for Python Django
58,122,857
0
8
15,405
0
python,django,web-applications,web
first we create virtual wrapper pip install virtualenv wrapper-win and after make wrapper environment now create a virtual env- mkvirtualenv envname (command run only 64 bit python) And if you want to start virtual env then set your workplace(Directory) using Command Prompt and write command workon envname
0
0
0
0
2016-12-22T09:17:00.000
6
0
false
41,279,547
1
0
1
4
I'm currently a novice in web programming. I've been working on this Django project lately, and I've been reading about virtual environments. At the start of my project, I was unable to set up a virtual environment, and so I proceeded with the project without it. My questions are Whether or not this virtual environment is really necessary? If I want to make more Django projects in the future, will I need this virtual environment to differentiate the projects since right now I'm running all the commands in the command prompt from my main C: directory? Does this virtual environment differentiate multiple projects or does it separate each project with respect to the version of Django/Python it's coded with or both? I'm wondering because I currently input commands such as python manage.py runserver (without the virtual environment) in my main C:drive directory. So does that mean I can't do multiple projects at once without a virtual environment for each? Can I still work on multiple projects without a virtual environment? (I've been confused about this especially) Should I just try to set up a virtual environment for my next project or can I still do it for this current one (I'm halfway through the project already, I've already made models, views, templates, etc.)? Any answers to clarify my confusion is greatly appreciated!
Virtual Environment for Python Django
52,409,650
0
8
15,405
0
python,django,web-applications,web
Virtual environment creates virtual installation of python and packages on your computer . Say,if you have your web application .With pass of time the packages get updated and there are changes that sometimes break backwards compaatibility that your web application or web project may depend on so what do you do if you want to test out the new features of a package update but you also don't want to break your web application. After all you can't just take down your web site every time a package gets updated .Well that's where the virtual environment comes in . You can create a virtual environment that contains the newer version of the package or the virtual environment for your older version of the package however luckily Anaconda makes this really easy for us .(A virtual handler is already included in Anaconda.)
0
0
0
0
2016-12-22T09:17:00.000
6
0
false
41,279,547
1
0
1
4
I'm currently a novice in web programming. I've been working on this Django project lately, and I've been reading about virtual environments. At the start of my project, I was unable to set up a virtual environment, and so I proceeded with the project without it. My questions are Whether or not this virtual environment is really necessary? If I want to make more Django projects in the future, will I need this virtual environment to differentiate the projects since right now I'm running all the commands in the command prompt from my main C: directory? Does this virtual environment differentiate multiple projects or does it separate each project with respect to the version of Django/Python it's coded with or both? I'm wondering because I currently input commands such as python manage.py runserver (without the virtual environment) in my main C:drive directory. So does that mean I can't do multiple projects at once without a virtual environment for each? Can I still work on multiple projects without a virtual environment? (I've been confused about this especially) Should I just try to set up a virtual environment for my next project or can I still do it for this current one (I'm halfway through the project already, I've already made models, views, templates, etc.)? Any answers to clarify my confusion is greatly appreciated!
Virtual Environment for Python Django
41,280,016
3
8
15,405
0
python,django,web-applications,web
In java all libs used can be packed into a war or jar file. The advantage is that you don't need to worry about the environments of the OS. Python is a pure dynamic language. Without virtual environment, all the python libs need to be installed into system path and shared among all python project. Imagine that you are developing a django 1.10 project. You find a demo project. You want to run it on your machine. But it is compatible only with django 1.8. You can not install two version of the same lib in the same machine, so you get stuck. Virtual environment solves problem like this. But of course virtual environment is not perfect. There are python libs like mysql-python which depends on libmysqld. If those libs are used in your project, it cannot be totally independent with the settings in OS. The best practice I think is to use virtual machine combined with docker. IDE like pycharm supports running remotely via docker
0
0
0
0
2016-12-22T09:17:00.000
6
0.099668
false
41,279,547
1
0
1
4
I'm currently a novice in web programming. I've been working on this Django project lately, and I've been reading about virtual environments. At the start of my project, I was unable to set up a virtual environment, and so I proceeded with the project without it. My questions are Whether or not this virtual environment is really necessary? If I want to make more Django projects in the future, will I need this virtual environment to differentiate the projects since right now I'm running all the commands in the command prompt from my main C: directory? Does this virtual environment differentiate multiple projects or does it separate each project with respect to the version of Django/Python it's coded with or both? I'm wondering because I currently input commands such as python manage.py runserver (without the virtual environment) in my main C:drive directory. So does that mean I can't do multiple projects at once without a virtual environment for each? Can I still work on multiple projects without a virtual environment? (I've been confused about this especially) Should I just try to set up a virtual environment for my next project or can I still do it for this current one (I'm halfway through the project already, I've already made models, views, templates, etc.)? Any answers to clarify my confusion is greatly appreciated!
Python/Django - Where do I have to make methods that perform like DML?
41,287,774
2
0
117
0
python,django,database,standards
A common philosophy in Django is "fat models, thin views", so preferably you would put as much of this DML functionality as functions on your model classes. Since models.py already defines the structure of your data, it makes sense to put functions that manipulate your data in the same file as much as possible.
0
0
0
0
2016-12-22T16:25:00.000
1
1.2
true
41,287,609
0
0
1
1
'Methods that perform like DML' means methods that change data in the database. Is there a standard or guideline for that? Below are my own guesses. Collect all functions in file of which name is like 'data_access.py' Contain functions in each class of models.py There is no standard. No one will blame even if I make them in views.py Above all are wrong.
django - underscoring foreign keys - pros and cons
41,290,255
0
1
76
0
python,django,pep8
There certainly is something you can do about it, if it bothers you that much. All relationship fields that automatically define a reverse relation also allow you to override that default by specifying related_name. So if you really don't like profile.profileattributegroup, define the one-to-one field with related_name='profile_attribute_group'.
0
0
0
0
2016-12-22T17:26:00.000
1
0
false
41,288,716
0
0
1
1
As PEP8 states, one should name classes that have several words with camelcase (e.g. ProfileAttributeGroup), and use underscores for variables (profile_attribute_group). However when it comes to django and reverse relations (and templates), we are forced to use lowercased name of classes. For example, if our ProfileAttributeGroup has a one-to-one key to a Profile model, the reverse lookup would be profile.profileattributegroup. Okay, we can override that one; but this lowercasing also happens in DetailView and UpdateView templates and in sql joins (e.g. someattr.filter(profileattributegroup__isnull=False)), and there's nothing we can do about it. This makes me think that it makes sense to just lowercase foreign key names, without adding any underscores there. This way I won't have to remember when to use profile_attribute_group or profileattributegroup. But explicit ignoring of underscores contradicts PEP8. My question is, has anyone else had my doubts? And are there any future downsides of ignoring underscores that I haven't thought about?
TensorFlow from Google - Data Security
50,601,700
0
0
861
0
python,machine-learning,tensorflow,deep-learning,google-developer-tools
Doesn't TF actually also uses google's models from cloud? I'm pretty sure google uses cloud data to provide better models for TF. I'd recommend you to stay away from it. Only by writing your models from scratch you will learn to do useful stuff with it long term. I can also recommend weka for java, it's open source and you can only look at the code of the models there an implement it yourself adjusting for your needs.
0
0
0
0
2016-12-23T09:57:00.000
2
0
false
41,299,126
0
1
1
1
Does anyone have any idea whether Google collects data that one supplies to Tensorflow? I mean it is open source, but it falls under their licences.
How do i retrieve browsers history in python django?
41,331,613
0
0
399
0
django,python-2.7
There is no way to do what you want, by design.
0
0
0
0
2016-12-26T09:25:00.000
2
0
false
41,328,993
0
0
1
1
I want to display all the Internet History Information of a system using Python?
How to profile django channels?
46,773,111
0
18
1,604
0
python,django,profiling,django-channels,daphne
Why not stick a monitoring tool something like Kibana or New Relic and monitor why and what's taking so long for a small payload response. It can tell you the time spent on Python, PostgreSQL and Memcache (Redis).
0
0
0
0
2016-12-26T12:49:00.000
2
0
false
41,331,567
0
0
1
1
My technology stack is Redis as a channels backend, Postgresql as a database, Daphne as an ASGI server, Nginx in front of a whole application. Everything is deployed using Docker Swarm, with only Redis and Database outside. I have about 20 virtual hosts, with 20 interface servers, 40 http workers and 20 websocket workers. Load balancing is done using Ingress overlay Docker network. The problem is, sometimes very weird things happen regarding performance. Most of requests are handled in under 400ms, but sometimes request can take up to 2-3s, even during very small load. Profiling workers with Django Debug Toolbar or middleware-based profilers shows nothing (timing 0.01s or so) My question: is there any good method of profiling a whole request path with django-channels? I would like how much time each phase takes, i.e when request was processed by Daphne, when worker started processing, when it finished, when interface server sent response to the client. Currently, I have no idea how to solve this.
Django 1.10 Create Model Tables Automatically
41,338,383
1
0
292
1
database,sqlite,python-3.x,django-models
I think it's not a good idea to create a table for each user. This may cause bad performance and low security. Why don't you create a table named userInfo and put user.userID as a foreign key?
0
0
0
0
2016-12-27T02:16:00.000
2
0.099668
false
41,338,208
0
0
1
1
I am wondering if there is any way to create a new model table in SQLite with Django 1.10 (like writing general python code) without having to specify in the models.py. The situation is if there is a new member registered on my website, then I will create a new model table for them to hold their data. Specifically: step 1: John Doe registered on my site step 2: The system create a model table named db_johnDoe (with same set of fields as of the others) step 3: The system can insert and edit data of the db_johnDoe according to John's behavior on the website. Any idea? Thanks a lot.
Django: Get user's input in textarea and display them on page
41,341,521
0
0
375
0
python,html,django
In your view add handle for POST requests and in that case render your template with template variable of your POST data.
0
0
0
0
2016-12-27T07:45:00.000
1
1.2
true
41,341,113
0
0
1
1
How to get input from textarea and display them onto my webpage immediately after submit on Django?
How to check if there are pending migrations when using SQLAlchemy/Alembic?
41,357,149
7
8
4,164
1
python,sqlalchemy,flask-sqlalchemy,alembic,flask-migrate
You can figure out if your project as at the latest migration with the current subcommand: Example output when you are at the latest migration: (venv) $ python app.py db current f4b4aa1dedfd (head) The key thing is the (head) that appears after the revision number. That tells you that this is the most recent migration. Here is how things change after I add a new migration, but before I upgrade the database: (venv) $ python app.py db current f4b4aa1dedfd And after I run db upgrade I get: (venv) $ python app.py db current f3cd9734f9a3 (head) Hope this helps!
0
0
0
0
2016-12-27T10:24:00.000
3
1
false
41,343,316
0
0
1
1
We're using SQLAlchemy and Alembic (along with Flask-SQLAlchemy and Flask-Migrate). How to check if there are pending migrations? I tried to check both Alembic's and Flask-Migrate's documentation but failed to find the answer.
AWS RDS save snapshot of selected tables
41,363,444
1
0
540
1
python,amazon-web-services,snapshot,boto3,rds
This is not possible using the AWS RDS snapshot mechanism, and it isn't possible using the AWS SDK. It is possible using the API for the specific database engine you are using. You would need to specify what database you are using for further help.
0
0
0
0
2016-12-28T11:25:00.000
1
0.197375
false
41,361,091
0
0
1
1
I'm trying to save a snapshot of several tables programatically in python, instead of all DB. I couldn't find the API (in boto/boto3) to do that. Is it possible to do?
How to send bulk sms on whatsapp
41,365,717
0
0
1,399
0
python,whatsapp
The error you get clearly points out the nature of the challenge you are facing: it has to do with your version of yowsup-cli; it's an old version. It means that your project requires a version of yowsup-cli higher than what you currently have so as to work effectively as require. What you need to do so as to resolve it is: to update your yowsup-cli application to a more recent version.
0
0
1
1
2016-12-28T15:25:00.000
2
0
false
41,364,998
0
0
1
2
I want to send bulk SMS on WhatsApp without creating broadcast list. For that reason, I found pywhatsapp package in python but it requires WhatsApp client registration through yowsup-cli. So I've run yowsup-cli registration -r sms -C 00 -p 000000000000 which resulted in the error below: INFO:yowsup.common.http.warequest:{"status":"fail","reason":"old_version"} status: fail reason: old_version What did I do wrong and how can I resolve this?
How to send bulk sms on whatsapp
41,424,293
0
0
1,399
0
python,whatsapp
The problem is with the http headers that are sent to whatsapp servers, these are found in env/env.py The name of headers are manually provided, therefore due to new updates whatsapp servers only serve or authenticate to updated devices which is identified with their http/https/etc headers, in this case you need to update some constants in the above file(env/env.py) in your yowsup folder.
0
0
1
1
2016-12-28T15:25:00.000
2
0
false
41,364,998
0
0
1
2
I want to send bulk SMS on WhatsApp without creating broadcast list. For that reason, I found pywhatsapp package in python but it requires WhatsApp client registration through yowsup-cli. So I've run yowsup-cli registration -r sms -C 00 -p 000000000000 which resulted in the error below: INFO:yowsup.common.http.warequest:{"status":"fail","reason":"old_version"} status: fail reason: old_version What did I do wrong and how can I resolve this?
Python Package Paths :: Finding Directories that Should Be .py Files
41,373,629
2
2
45
0
python,django
If you're looking for the source of module foo.bar, it can be one of the two: foo/bar.py foo/bar/__init__.py Also note that often upper-level modules re-export selected names imported from deeper-down modules: a name may be merely imported, not otherwise defined; e.g. django.db does a lot of this.
0
0
0
0
2016-12-29T04:00:00.000
1
0.379949
false
41,372,955
0
0
1
1
As I work through the Django tutorials, I like to see with my own eyes the module and class/attribute that I am inheriting via import by going to the source code at Github. However, and I have attached pics to illustrate that I (think) I went to the right place, but the files seem to be missing. For example, in Django tutorial Part 1: from django.conf.urls import include, url So I go to Github django code and I find: django/django/conf/urls What I find is that urls is a directory with only files : __init__.py, i18n.py and static.py. There is no urls.py file which might have url() or include() methods. Same with models.Models. from django.db import models On django Github site I follow the directories... django/django/db/models  models is a directory, not a file with a class Model() So, what am I missing here? Looking forward to a few bread crumbs :)
How to solve [Errno 11] Resource temporarily unavailable using uwsgi + nginx
44,000,160
0
0
1,657
0
python,django,uwsgi
You can increase 'listen' value in uwsgi configure file. The default value is 100 which is too small.
0
1
0
0
2016-12-29T09:46:00.000
2
0
false
41,377,059
0
0
1
1
I am using uwsgi with this configuration : net.core.somaxconn = 1024 net.core.netdev_max_backlog=1000 I got resource temporarily unavailable issue. How to resolve this issue? df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 7.8G 2.1G 5.6G 28% / devtmpfs 1.9G 12K 1.9G 1% /dev tmpfs 1.9G 16K 1.9G 1% /dev/shm
installing sklearn version 0.18.1 in Apache web server
41,383,430
0
0
362
0
python,apache,flask,scikit-learn
Use anaconda. It will save you so much time with these annoying dependency issues.
0
0
0
0
2016-12-29T13:25:00.000
1
0
false
41,380,710
0
1
1
1
I am trying to install the latest version (0.18.1) of sklearn for use in a web app I am hosting my webapp with apache web server and flask I have tried sudo apt-get -y install python3-sklearn and this works but installs an older version of sklearn (0.17) I have also tried pip3 and easy_install and these complete the install but are not picked up by flask or apache. I get the following error log on my apache server [Thu Dec 29 13:07:45.505294 2016] [wsgi:error] [pid 31371:tid 140414290982656] [remote 90.201.35.82:25030] from sklearn.gaussian_process import GaussianProcessRegressor [Thu Dec 29 13:07:45.505315 2016] [wsgi:error] [pid 31371:tid 140414290982656] [remote 90.201.35.82:25030] ImportError: cannot import name 'GaussianProcessRegressor' This is because I am trying to access some features of sklearn which are not present in 0.17 but are there in 0.18.1 Any ideas?
Flask with mod_wsgi - Cannot call my modules
41,394,185
0
0
1,008
0
python,flask,undefined,global,mod-wsgi
No main function call with mod_wsgi was the right answer. I do not implemented my required modules in the wsgi file, but on top of the flask app.
0
1
0
0
2016-12-29T14:32:00.000
1
0
false
41,381,705
0
0
1
1
I have changed my application running with flask and python2.7 from a standalone solution to flask with apache and mod_wsgi. My Flask app (app.py) includes some classes which are in the directory below my app dir (../). Here is my app.wsgi: #!/usr/bin/python import sys import logging logging.basicConfig(stream=sys.stderr) sys.stdout = sys.stderr project_home = '/opt/appdir/Application/myapp' project_web = '/opt/appdir/Application/myapp/web' if project_home not in sys.path: sys.path = [project_home] + sys.path if project_web not in sys.path: sys.path = [project_web] + sys.path from app import app application = app Before my configuration to mod_wsgi my main call in the app.py looks like that: # Main if __name__ == '__main__' : from os import sys, path sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) from logger import Logger from main import Main from configReader import ConfigReader print "Calling flask" from threadhandler import ThreadHandler ca = ConfigReader() app.run(host="0.0.0.0", threaded=True) I was perfectly able to load my classes in the directory below. After running the app with mod_wsgi I get the following error: global name \'Main\' is not defined So how do I have to change my app that this here would work: @app.route("/") def test(): main = Main("test") return main.responseMessage()
Differences between rendering HTML in PyCharm and a text editor (Sublime Text)
41,388,131
0
0
114
0
python,html,css,pycharm
Let me try a lucky guess since I don't know what is exactly rendering different: it could be the Encoding of the file, you can try and change in Sublime selecting a different enconding type to save the file to match the file saved in pycharm. File>Save with encoding>[select] If both are completely equal is the only thing that I can imagine.
0
0
0
0
2016-12-29T22:22:00.000
2
0
false
41,388,006
0
0
1
2
I've got exactly the same files (HTML + CSS), in both PyCharm and Sublime Text, and the results of rendering these in Google Chrome is completely different. Editing CSS doesn't have any affect on the results of rendering the HTML. I have to make the project using Python Flas, but I want to start from HTML and CSS. Does anybody know why have I different results from the same files?
Differences between rendering HTML in PyCharm and a text editor (Sublime Text)
41,388,349
0
0
114
0
python,html,css,pycharm
When we run PyCharm project it give us the same link and we have to clear cache or cookies every time we open this link
0
0
0
0
2016-12-29T22:22:00.000
2
1.2
true
41,388,006
0
0
1
2
I've got exactly the same files (HTML + CSS), in both PyCharm and Sublime Text, and the results of rendering these in Google Chrome is completely different. Editing CSS doesn't have any affect on the results of rendering the HTML. I have to make the project using Python Flas, but I want to start from HTML and CSS. Does anybody know why have I different results from the same files?
Web Dialog box used to capture a full file path / UNC
41,450,857
0
1
135
0
javascript,jquery,python,jqwidget
I had to resort to this. The application's user interface is posting to methods back on the site's controllers. Then code executing on the site's server (Python) is providing the user's interface lists of folders and files on the file server's shares. With some effort I will be able to provide the user with a rich and comprehensive UX that will effectively be the same originally desired. Or at least enough so. What I will not be able to provide is a folder-file lists of the user's local hard drive. And any drives mapped between the user's workstation and the file server will not be represented from the web server to the file server. Meaning the user will have to learn to live without the mapped drive letters which they have become accustomed to.
0
0
0
0
2016-12-31T02:39:00.000
1
1.2
true
41,404,967
0
0
1
1
I'm building a browser application in web2py (Python based CMS). One requirement this application has is to enable is the user to browse to a folder within the local network or local drive. The user selects a folder, that selection becomes a string that I record in the application's database. File selection is entirely off the table. I don't care at all about file selection. I only need to select one and only one folder. And get the one folder's fullpath/UNC as a string, collection is strings, object, or whatever that I can then assemble the fullpath as a string. How can I develop a browser user interface screen object of some sort that enables the user to browser to and select a folder ( c:\folder\folder -or- \\server\share\folder ...) Then capture that string in a variable I can write to a databases? I'm finding there are a lot of impediments to just such use of a browser application (didn't used to be that way). I get the security concerns but I also can't believe all similar enterprise uses of a browser are being torn down and made impossible (again, because it didn't used to be that way). I don't want to dictate implementation. So spitball ideas if you like. Get out of the box of this tech stack if you like. But browser based is HIGHLY compelling (if I were to do this as a desktop app or something else I wouldn't even need to post this question). The current tech stack of the application is: browser (open to suggestions but Chrome is the preference), JavaScript, jQuery, JQWidgets, Python, MSSQL (server hosted, not CE/local). But none of these elements are hard limitations. Except IE/Edge. We'll never use that. If you can point me to fiddle, GitHub, ... examples that would be greatly appreciated. Is there a particular JavaScript library, browser addin, Python import, ... I should research? Would .Net be better suited to champion this challenge? Is there a better forum you know of where I should post this question? Thanks
Updating which python my django app uses
41,433,294
1
0
96
0
django,python-2.7
Create a new virtualenv using Python 2.7. Use the -p flag to point to the python installation you want for that virtual environment, and then pip install django within that virtual environment.
0
0
0
0
2017-01-02T19:40:00.000
1
0.197375
false
41,432,445
1
0
1
1
The django app running on localhost in a virtualenv uses the default python version 2.7.3 that is under /usr/bin/ but I installed Python 2.7.9 under ~/.opt/bin/python2.7. I updated the $PATH but I want the django app to use the locally installed python version by default. Please help me understand how to make that happen. Thank you.
Large memory Python background jobs
41,469,303
0
5
1,222
0
python,mongodb,heroku,flask,python-rq
It turns out that the solution that worked for is to save the data to Amazon S3 storage, and then pass the URI to function in the background task.
0
0
0
0
2017-01-04T10:35:00.000
2
0
false
41,461,708
0
0
1
2
I am running a Flask server which loads data into a MongoDB database. Since there is a large amount of data, and this takes a long time, I want to do this via a background job. I am using Redis as the message broker and Python-rq to implement the job queues. All the code runs on Heroku. As I understand, python-rq uses pickle to serialise the function to be executed, including the parameters, and adds this along with other values to a Redis hash value. Since the parameters contain the information to be saved to the database, it quite large (~50MB) and when this is serialised and saved to Redis, not only does it take a noticeable amount of time but it also consumes a large amount of memory. Redis plans on Heroku cost $30 p/m for 100MB only. In fact I every often get OOM errors like: OOM command not allowed when used memory > 'maxmemory'. I have two questions: Is python-rq well suited to this task or would Celery's JSON serialisation be more appropriate? Is there a way to not serialise the parameter but rather a reference to it? Your thoughts on the best solution are much appreciated!
Large memory Python background jobs
41,469,731
7
5
1,222
0
python,mongodb,heroku,flask,python-rq
Since you mentioned in your comment that your task input is a large list of key value pairs, I'm going to recommend the following: Load up your list of key/value pairs in a file. Upload the file to Amazon S3. Get the resulting file URL, and pass that into your RQ task. In your worker task, download the file. Parse the file line-by-line, inserting the documents into Mongo. Using the method above, you'll be able to: Quickly break up your tasks into manageable chunks. Upload these small, compressed files to S3 quickly (use gzip). Greatly reduce your redis usage by requiring much less data to be passed over the wires. Configure S3 to automatically delete your files after a certain amount of time (there are S3 settings for this: you can have it delete automatically after 1 day, for instance). Greatly reduce memory consumption on your worker by processing the file one line at-a-time. For use cases like what you're doing, this will be MUCH faster and require much less overhead than sending these items through your queueing system. Hope this helps!
0
0
0
0
2017-01-04T10:35:00.000
2
1.2
true
41,461,708
0
0
1
2
I am running a Flask server which loads data into a MongoDB database. Since there is a large amount of data, and this takes a long time, I want to do this via a background job. I am using Redis as the message broker and Python-rq to implement the job queues. All the code runs on Heroku. As I understand, python-rq uses pickle to serialise the function to be executed, including the parameters, and adds this along with other values to a Redis hash value. Since the parameters contain the information to be saved to the database, it quite large (~50MB) and when this is serialised and saved to Redis, not only does it take a noticeable amount of time but it also consumes a large amount of memory. Redis plans on Heroku cost $30 p/m for 100MB only. In fact I every often get OOM errors like: OOM command not allowed when used memory > 'maxmemory'. I have two questions: Is python-rq well suited to this task or would Celery's JSON serialisation be more appropriate? Is there a way to not serialise the parameter but rather a reference to it? Your thoughts on the best solution are much appreciated!
How do I use crawler if I know the target web-page and file extension but not knowing the file name?
41,653,258
0
1
50
0
python,html,nginx,web-crawler
You can't crawl webpages if you don't know how to get to them. If I understood what you meant, you want to access pages that are accessible in a directory whose index page is not (because you get a 403). Before you give up, you can try the following: check if the main search engines link to the pages inside the directory that you seem to know about (because if you know you have access to those .html you probably know at least one of them). The page that includes that link may include other links to files inside that directory as well. For instance, in google, use the link: operator: link:www.abc.com/a/b/the_file_you_know_exists check if the website is indexed in the main search engines. For instance, in google, use the site: operator: site:www.abc.com/a/b/ check if the website is archived in archive.org: http://web.archive.org/web/*/www.abc.com/a/b/ check if you can find it in other web archives using memento: http://timetravel.mementoweb.org/reconstruct/*/www.abc.com/a/b/ try to find other possible filenames such as index1.html, index_old.html, index.html_old, contact.html and so on. You could create a long list of the possible filenames to try but this also depends on what you know about the website. This may give you possible pages from that website that still exist or existed in the past.
0
0
0
0
2017-01-04T14:54:00.000
1
0
false
41,466,768
0
0
1
1
I have a web-page here that I need to crawl. It looks like this: www.abc.com/a/b/, and I know that under the /b directory, there are some files with .html extensions I need. I know that I have access to those .html files, but I have no access to www.abc.com/a/b/. So, without knowing the .html file name, how can I crawl those .html pages?
Error Making POST to ServiceM8
41,469,658
1
0
41
0
python,django,python-requests
I was trying to pass the company id as company_uuid. I changed it to just company_id, and it worked perfectly.
0
0
0
0
2017-01-04T17:04:00.000
1
0.197375
false
41,469,446
0
0
1
1
I'm getting the following error making a POST request to ServiceM8: {'Content-Type': 'text/html;charset=UTF-8', 'Content-Length': '343', 'Connection': 'keep-alive', 'Date': 'Wed, 04 Jan 2017 16:57:31 GMT', 'Server': 'Apache', 'X-Frame-Options': 'SAMEORIGIN', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 49ccc390fa499ab821b632cf67d38720.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'DCkbBH5hfQ-ZyeyefPZJAyaVhKar_oD3n_VDZ8TYS97CyLpG4r5YGQ=='} I'm currently using: Django==1.10.4 requests==2.12.4
Django: Concurrent access to settings.py
41,549,703
1
0
143
0
python,django,concurrency
as e4c5 mentioned, conventionally settings.py is pretty light on logic. The loading mechanism for settings is pretty obscure and, I personally, like to stay away from things that are difficult to understand and interact with :) You absolutely have to care about concurrency. How are you running your application? It's tricky because in the dev env you have a simple server and usually handle only a handful of requests at the same time (and a couple years ago the dev server was single threaded) If you're running your application using a forking server, how will you share data between processes? one process won't even see the other processes settings.py changes. I'm not even sure of how it would look like with a threading server, but it would probably at least require a source code audit of your web server to understand the specifics of how requests are handled and how memory is shared. Using a DB is by far the easiest solution, (you should be able to use an in memory db as an option too memcache/redis/etc). DB's provide concurrency support out the box and will be a lot more easier to reason about and provides primitives for concurrent accessing of data. And in the case of redis, which is single threaded you won't even have to worry about concurrent accesses to your shared IP addresses
0
0
0
0
2017-01-05T12:28:00.000
2
1.2
true
41,485,130
1
0
1
2
I am not sure whether I have to care about concurrency, but I didn't find any documentation about it. I have some data stored at my settings.py like ip addresses and each user can take one or give one back. So I have read and write operations and I want that only one user read the file at the same moment. How could I handle this? And yes, I want to store the data at the settings.py. I found also the module django-concurrency. But I couldn't find anything at the documentation.
Django: Concurrent access to settings.py
41,485,205
1
0
143
0
python,django,concurrency
And yes, I want to store the data at the settings.py. No you definitely don't want to do that. the settings.py file is configuring django and any pluggable apps that you may use with it. it's not intended to be used as a place for dumping data. Data goes into a database. And don't forget that the settings.py file is usually read only once.
0
0
0
0
2017-01-05T12:28:00.000
2
0.099668
false
41,485,130
1
0
1
2
I am not sure whether I have to care about concurrency, but I didn't find any documentation about it. I have some data stored at my settings.py like ip addresses and each user can take one or give one back. So I have read and write operations and I want that only one user read the file at the same moment. How could I handle this? And yes, I want to store the data at the settings.py. I found also the module django-concurrency. But I couldn't find anything at the documentation.
Troubleshooting API timeout from Django+Celery in Docker Container
41,668,121
0
1
472
0
python,django,docker,containers,celery
You can shell into the running container and check things out. Is the celery process still running, etc... docker exec -ti my-container-name /bin/bash If you are using django, for example, you could go to your django directory and do manage.py shell and start poking around there. I have a similar setup where I run multiple web services using django/celery/celerybeat/nginx/... However, as a rule I run one process per container (kind of exception is django and gunicorn run in same container). I then share things by using --volumes-from. For example, the gunicorn app writes to a .sock file, and the container has its own nginx config; the nginx container does a --volumes-from the django container to get this info. That way, I can use a stock nginx container for all of my web services. Another handy thing for debugging is to log to stdout and use docker's log driver (splunk, logstash, etc.) for production, but have it log to the container when debugging. That way you can get a lot of information from 'docker logs' when you've got it under test. One of the great things about docker is you can take the exact code that is failing in production and run it under the microscope to debug it.
0
1
0
0
2017-01-05T12:33:00.000
1
0
false
41,485,251
0
0
1
1
I have a micro-services architecture of let say 9 services, each one running in its own container. The services use a mix of technologies, but mainly Django, Celery (with a Redis Queue), a shared PostgreSQL database (in its own container), and some more specific services/libraries. The micro-services talk to each other through REST API. The problem is that, sometimes in a random way, some containers API doesn't respond anymore and get stuck. When I issue a curl request on their interface I get a timeout. At that moment, all the other containers answer well. There is two stucking containers. What I noticed is that both of the blocking containers use: Django django-rest-framework Celery django-celery An embedded Redis as a Celery broker An access to a PostgreSQL DB that stands in another container I can't figure out how to troubleshoot the problem since no relevant information is visible in the Services or Docker logs. The problem is that these API's are stuck only at random moments. To make it work again, I need to stop the blocking container, and start it again. I was wondering if it could be a python GIL problem, but I don't know how to check this hypothesis... Any idea about how to troubleshot this?
Use django for one page on a website?
41,490,025
2
1
2,061
0
python,django
If all you wanted to do was create a static page (something simple that queries a database and displays results with no user input) then PHP would definitely be much easier. It's much, much, MUCH easier to deploy than web apps-- just drop your .php files in /var/www/html and you're set. Apache runs on anything. Once you're in the realm of needing user accounts, management, etc. or possibly even expansion of scope in the future then Django becomes a more likely candidate. I love Django but deployment of Python/Ruby apps can be a major pain (if not impossible) depending on many factors in your target environment. It looks deceptively easy to get something running when you're using the built-in webserver where everything just works, but in production you may find your host doesn't offer (or you can't compile) mod_wsgi, only has mod_python (incompatible with modern Django), won't run nginx, can't use gunicorn, etc. Every cheap web host offers PHP support out of the box. If you want support for apps written in Python/Ruby, sometimes you need to pay for additional services (if not running a VPS or EC2 instance). Basically, there are more factors involved than just the number of pages you intend to write. You really need to evaluate what you're buying into with either avenue.
0
0
0
0
2017-01-05T15:47:00.000
1
0.379949
false
41,489,105
0
0
1
1
I have a small app I would like to build as a project to learn more about web development. Its an app where people can register etc, and add information about themselves (database needed) and their location on a webmap (using leaflet library). The app will be a single page application that the user navigate to via a link on the site that today is already live. I got a comment from one i know not to use php. Since I am learning python I was thinking maybe to use that for the server side bits. Is it a good idea to use django or other python framework when it will only be used on a single page of the site, is it even possible (very green on this)? Or should i just stick to php for a project this size? Any input would appreciated
Django/Python Library for importing and producing Excel documents?
41,498,821
1
0
199
1
python,django,excel
I think a combination of Pandas and openpyxl will do the trick!
0
0
0
0
2017-01-06T04:11:00.000
2
0.099668
false
41,498,803
0
0
1
1
Looking for an Excel library for Django and Python with specific requirements. There looks to be a number of libraries for Django and Python that enable the user to upload an Excel document into the database. What I am wondering is if there is a library that allows you to create an Excel document and export with conditional formatting, live formulas, creating tabs, and VLOOKUPS? The company I work for produces Excel reports for our analysts to review that requires these types of things. Researching as we are exploring other solutions than using Access, which is it pretty easy to control Excel from.
Temporary failure in name resolution -wget in linux
41,500,665
0
1
5,012
0
python,linux,api,wget
This is tricky not knowing with which options you are calling wget and no log output, but since it seems to be a dns issue I would explicitly pass the --dns-servers=your.most.reliable.server to wget. If it persists I would also pass --append-output=logfile and examine logfile for further clues.
0
1
1
0
2017-01-06T06:49:00.000
2
0
false
41,500,455
0
0
1
2
Im running python code solution (automation) in linux As part of the test im calling different api (rest) and connecting to my sql db. I'm running the solution 24/7 The soultion does Call api with wget Every 1 min samples the db with query for 60 min max Call api again with wget Every 1 min samples dc for 10 mins max. This scenario runs 24/7 Problem is that after 1 hr/ 2hr (inconsistency-can happen after 45 mins for instance) the solution exit with error Temporary failutre in name resolution. It can happen even after 2 perfect cycle as I described above. After this failure I'm trying to call with wget tens of times and ends with the same error. After some time it covered by it self. Want to mention that when it fails with wget on linux, Im able to call the api via POSTMAN via windows with no problem. The api calls are for our system (located in aws) and im using dns of our elb.. What could be the oroblem for this inconsistency? Thanks
Temporary failure in name resolution -wget in linux
62,781,058
0
1
5,012
0
python,linux,api,wget
You can ignore the fail: wget http:/host/download 2>/dev/null
0
1
1
0
2017-01-06T06:49:00.000
2
0
false
41,500,455
0
0
1
2
Im running python code solution (automation) in linux As part of the test im calling different api (rest) and connecting to my sql db. I'm running the solution 24/7 The soultion does Call api with wget Every 1 min samples the db with query for 60 min max Call api again with wget Every 1 min samples dc for 10 mins max. This scenario runs 24/7 Problem is that after 1 hr/ 2hr (inconsistency-can happen after 45 mins for instance) the solution exit with error Temporary failutre in name resolution. It can happen even after 2 perfect cycle as I described above. After this failure I'm trying to call with wget tens of times and ends with the same error. After some time it covered by it self. Want to mention that when it fails with wget on linux, Im able to call the api via POSTMAN via windows with no problem. The api calls are for our system (located in aws) and im using dns of our elb.. What could be the oroblem for this inconsistency? Thanks
Can I use xvfb with AWS Lambda?
41,510,034
1
2
2,074
0
python,amazon-web-services,aws-lambda
No, this breaks the lambda paradigm of having a fully built container ready to go. Also, anything you'd do with xvfb is probably going to be slow. As a general rule lambdas should execute in under a second, otherwise you should just have a server. I would recommend creating a docker container and making an auto-scaling group.
0
0
1
0
2017-01-06T16:25:00.000
2
0.099668
false
41,509,856
0
0
1
1
I would like to offload some code to AWS Lambda that grabs a part of a screenshot of a URL and stores that in S3. It uses chromium-browser which in turn needs to run in xvfb on Ubuntu. I believe I can just download the Linux 64-bit version of chromium-browser and zip that up with my app. I'm not sure if I can do that with xvfb. Currently I use apt-get install xvfb, but I don't think you can do this in AWS Lambda? Is there any way to use or install xvfb on AWS Lambda?
flask: command not found - flask 0.12
41,521,516
5
3
9,753
0
python,flask
Fixed by running python3 -m flask.
0
0
0
0
2017-01-07T12:22:00.000
2
1.2
true
41,521,392
1
0
1
1
I have just installed a fresh copy of Ubuntu 16.04 LTS, and installed flask using pip3 install flask. When I run pip3 list Flask 0.12 appears in the list. However, when I attempt to run flask, I get the error flask: command not found. I have also installed using pip and not pip3 but to no avail. Any suggestions?
Can you put static folder in project root, rather than app root?
41,525,185
1
1
70
0
python,django,python-2.7
Django doesn't say any such thing. Put the static folder wherever you want, as long as you include it in STATICFILES_DIRS so that collectstatic will find it.
0
0
0
0
2017-01-07T18:29:00.000
2
0.099668
false
41,524,979
0
0
1
1
For example, if I want to use the same style.css for all my apps, where should I put the static folder? I'm pretty sure Django site says to put it in the application folder? But what if I have multiple apps?
Why doesn't "python" command work in virtualenv?
41,533,415
0
2
99
0
python,django,virtualenv
Because of the way virtualenvs work, Django was not 'installed' in said env. The reason ./manage.py startapp firstapp worked is because the ./ indicated that it was an executable file, and hence handled by the system as such. That way, modules are accessible, as the program is ran outside of the env Hope this helped!
0
0
0
0
2017-01-08T12:26:00.000
1
1.2
true
41,532,668
1
0
1
1
Before asking, I should mention that this is NOT a problem or a bug, this is just a question to widen my knowledge. When I was working on a Django project (I'm quite new to all these things so don't beat, please) I activated my virtualenv, installed django module and started a new Django project by using django-admin.py startproject myproject . That worked. But then I cd to myproject and tried to run python manage.py startapp firstapp, and failed. I caught ImportError: no module named 'django'. The problem was solved by simply typing ./manage.py startapp firstapp . What the heck is that? Why doesn't python command work? Python version is 3.5.2.
Dedicated web service for web app (Python/Django)
41,542,658
0
2
347
0
python,django,rest
By creating dedicated API's will help you in future if you decide to build mobile application, that case no need to write new API's as you can consume your existing API's. By doing this your are not repeating your server side codes. Only have to write the client side code. And coming to performance only load time will be more as it has to load HTML, JS and CSS after subsequent requests will be more faster
0
0
0
0
2017-01-08T12:31:00.000
1
0
false
41,532,714
0
0
1
1
Let's assume that I want to create a simple todo list web application. I am thinking about creating RESTful web services which will be used my the web application and which will be providing all functionalities concerning managing todo list and tasks. I have two concerns: Is there a sense in creating dedicated web service assuming web service will be only used by my web application? Web service and web application will be on the same server and there have to be a lot of 'views' duplication. Web application will only delegate request to web service, process the response, and return a web page. Assuming I decided for this kind of architecture: dedicated web service + web application, what is the best practice for calling web service from views in web application? They will be just two different apps within Django project. request?
How don't change '/media/' on heroku after "git push ..."
41,545,127
2
0
125
0
python,django,git,heroku,git-push
/media is for user-uploaded files. These must not be stored in the Heroku filesystem. Heroku creates a new dyno each time you deploy your code, as well as whenever you run a management command and at irregular times otherwise. Each new dyno has its own filesystem which is not shared with other ones and only contains the files from your git repo. You must configure Django to upload media files somewhere permanent, such as S3.
0
0
0
0
2017-01-09T09:35:00.000
1
1.2
true
41,544,873
0
0
1
1
Help me please. I have django app on Heroku. I want that after $ git push heroku master folder /media/ on Heroku don't change. Thank you.
Should I add Django admin static files to my git repo?
41,558,803
31
24
7,555
0
python,django,git,django-admin
While you can absolutely check these files in, I typically recommend not checking in the collected static files into git (we use .gitignore to ignore them). Instead, we call collectstatic during our build/deploy steps so that if anyone ever adds new static files, they are collected and copied to the proper output directory for serving by nginx or sent up to s3. If you want to check them into git, I would recommend having collectstatic as a precommit hook so that no one accidentally forgets to run it when adding a new static file.
0
0
0
0
2017-01-09T22:45:00.000
1
1.2
true
41,558,258
0
0
1
1
I ran manage.py collectstatic on my webapp and now I have a new static folder with only Django admin files (so far I've been using just CDNs for my project CSS and JS files). Should I track these admin static files on my git repo? What's the best practise?
Python objects lose state after every request in nginx
41,559,760
2
1
210
0
python,django,nginx,wsgi,gunicorn
Gunicorn has a preforking worker model -- meaning that it launches several independent subprocesses, each of which is responsible for handling a subset of the load. If you're relying on internal application state being consistent across all threads involved in offering your service, you'll want to turn the number of workers down to 1, to ensure that all those threads are within the same process. Of course, this is a stopgap -- if you want to be able to scale your solution to run on production loads, or have multiple servers backing your application, then you'll want to be modify your system to persist the relevant state to a shared store, rather than relying on content being available in-process.
0
0
0
1
2017-01-10T00:47:00.000
1
1.2
true
41,559,470
0
0
1
1
This is really troublesome for me. I have a telegram bot that runs in django and python 2.7. During development I used django sslserver and everything worked fine. Today I deployed it using gunicorn in nginx and the code works very different than it did on my localhost. I tried everything I could since I already started getting users, but all to no avail. It seems to me that most python objects lose their state after each request and this is what might be causing the problems. The library I use has a class that handles conversation with a telegram user and the state of the conversation is stored in a class instance. Sometimes when new requests come, those values would already be lost. Please has anyone faced this? and is there a way to solve the problem quick? I am in a critical situation and need a quick solution
Making Django's CBV's get an instance method
41,565,380
0
0
65
0
python,django,django-class-based-views
As I said, get is an instance method. But you are confusing responsibilities here. A class should have one responsibility only. The view class has the responsibility of responding to the request and returning a response; this is quite separate from the connection to the instrument. That should be a separate class, which is instantiated at module level and used within the view class.
0
0
0
0
2017-01-10T07:49:00.000
1
0
false
41,563,696
0
0
1
1
I'm currently building a Django app which uses a singleton object. I want to save this object as a CBV variable because I dont want to initialize it for every 'get' call. My question in short - can you make a CBV's get function an instance method instead of a classmethod? And if so, can I save a variable as an instance variable? EDIT - A better explanation to my question: I created a class that handles a serialized connection with an electronic measurment instrument. This class must have only 1 instance (singleton), if another instance will be created a memory leak will crash python. I want to use it with django in the following way: Get request to a certain url address -> The view will ask the instrument class instance for data-> Instance responds with data -> View returns a JsonResponse with the data. I think the best way to do it is making the CBV's get method (whose related to the url im getting from) an instance method, but its not such a good practice.. How should I do it?
Define own header in webpy
41,726,066
1
1
253
0
python,web.py
Headers aren't part of web.input(), they're part of the "environment". You can add headers, to be sent to your client using web.header('My-Header', 'header-value'). You can read headers sent by your client using: web.ctx.env.get('MY_HEADER') (Note all-caps, and use of underline rather than dash).
0
0
1
0
2017-01-10T10:08:00.000
1
0.197375
false
41,566,222
0
0
1
1
I look after many links to find how can I define my proprietary header in webpy. Can you help me, please. I need to define my own http header like ("X-UploadedFile") and then use it with web.input()
Debugging Bokeh serve application using PyCharm
44,185,703
5
11
4,506
0
python,bokeh
bokeh can also be run via python -m bokeh given that, you could open up the Run/Debug Configuration dialog and set your interpreter options to -m bokeh serve --show and your script will run as-is
0
0
0
0
2017-01-10T13:43:00.000
6
0.16514
false
41,570,318
0
0
1
1
Bokeh serve allows to write fast web apps with plots and widgets. How can I debug the python code when I use bokeh serve --show code.py?
Django - make admin fields invisible to some users
41,578,308
3
0
248
0
python,django
Just don't give them superuser rights. Superuser means they have all rights automatically, which isn't what you want. Then add edit, add, delete rights for the models they are allowed to edit, add and delete. You can create a group that you give these rights to, then add the users to that group. If a user doesn't have add, edit or delete rights to a model, the model isn't shown in the admin.
0
0
0
0
2017-01-10T20:25:00.000
1
1.2
true
41,577,756
0
0
1
1
TL;DR I'd like to be able to disable certain models per-user in /admin view. Specifically: I'm looking to make admin models invisible to some staff users, so that they can have a sort of customized dashboard. There's all sorts of fields that change how to present, search, query, etc. models based on whatever you want, but I can't find anything to allow me to determine whether or not to even show models on the /admin page without resorting to blacklisting individual permissions (of which there are hundreds), and I'd like to be able to make some models only available to superusers and not staff. Any thoughts? Thanks!
Python module installed in site-packages folder, but getting error "No module ..."
41,579,312
-1
0
443
0
python-3.x,module
You are getting the error because you used pip. pip basically is for version 2 of python. for using it for pip3, you should first install pip3 package. Then copy all your dependencies to python3 libraries. Hope that answers the question.
0
0
0
0
2017-01-10T21:44:00.000
1
1.2
true
41,578,978
1
0
1
1
Using the Mac Os Terminal, I downloaded the Jupyter lightning module using "pip install lightning-python" in the /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages directory. However, when I try to import it, I get the error, No module named 'lightning' and when I list out the files in the site-packages directory, the module doesn't appear.
pip install Django on python3.6
41,588,975
1
12
22,964
0
python,django,python-3.x,pip,python-3.6
As is common with these sort of pip issues, before you install, check where pip is pointing to with pip -V. If that points to Python 2, you can then try pip3 -V; if that points to an older version of Python 3, go for pip3.6. As a final approach, you can always go through python itself with python3.6 -m pip install ...
0
0
0
0
2017-01-11T10:53:00.000
5
0.039979
false
41,588,925
1
0
1
2
If I run pip install Django I get Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pip syntax to install the last version of Django on python 3.6?
pip install Django on python3.6
41,588,953
4
12
22,964
0
python,django,python-3.x,pip,python-3.6
If you have pip3 then directly use pip3 install Django Else try to use virtualenv for your python version as : pip -p python3.6 virtualenv name then you can install any version of Django on it.
0
0
0
0
2017-01-11T10:53:00.000
5
0.158649
false
41,588,925
1
0
1
2
If I run pip install Django I get Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pip syntax to install the last version of Django on python 3.6?
Changing Database in run time and making the changes reflect in Django in run time
41,592,978
0
0
43
1
python,django,django-1.10
Django's ORM might not be the right tool for you if you need to change your schema (or db) online - the schema is defined in python modules and loaded once when Django's web server starts. You can still use Django's templates, forms and other libraries and write your own custom DB access layer that manipulates a DB dynamically using python.
0
0
0
0
2017-01-11T12:32:00.000
1
0
false
41,591,079
0
0
1
1
I am developing a Cloud based data analysis tool, and I am using Django(1.10) for that. I have to add columns to the existing tables, create new tables, change data-type of columns(part of data-cleaning activity) at the run time and can't figure out a way to update/reflect those changes, in run time, in the Django model, because those changes will be required in further analysis process. I have looked into 'inspectdb' and 'syncdb', but all of these options would require taking the portal offline and then making those changes, which I don't want. Please can you suggest a solution or a work-around of how to achieve this. Also, is there a way in which I can select what database I want to work from the list of databases on my MySQL server, after running Django.
Get system time w/timezone in Django bypassing default timezone
41,604,291
1
3
772
0
python,django,date,datetime
Django seems to be putting its timezone in the TZ environment variable. Try del os.environ['TZ'] then using tzlocal.
0
0
0
0
2017-01-11T13:40:00.000
3
1.2
true
41,592,506
0
0
1
1
As long as I'm using plain ol' Python shell, the datetime.datetime.now() command works fine to get system's local (non-UTC) time. But I'm working on a Django project where the time zone is changed in settings.py with TIME_ZONE = 'UTC'. I've tried many solutions from django.utils timezone to tzlocal module, but none of them works. All of them return either incorrect or UTC time. All of the solutions work if I change the timezone in settings.py to my local timezone. But I can't do that, so is there any way to bypass the default timezone option in settings.py? Or any way the settings.py's timezone can be automatically updated? If I remove the TIME_ZONE line, I don't know why, but it seems to get a random timezone. EDIT - I know that the timezone can be entered manually with pytz, but I don't want to do that. I want to get the local system timezone, but WITHOUT Django's moderation of the timezone. Thanks.
Using Selenium Scripts in a Python unit test
41,607,809
1
0
81
0
python,unit-testing,selenium,selenium-webdriver,selenium-ide
If you are recording scripts in Python formatting, those are already converted to unit test cases. Save each scripts and run them in batch mode.
0
0
1
1
2017-01-12T01:15:00.000
1
1.2
true
41,603,576
0
0
1
1
I have recorded some Selenium Scripts using the Selenium IDE Firefox add-on. I'd like to add these to the unit test cases for my Django project. Is it possible to somehow turn these into a Python unit test case?
Is a separate Python instance started for each instance of a Django application via Apache?
41,621,883
2
1
57
0
python,django,apache
Neither of these things. Depending on how your server is configured, it will start up multiple processes and/or threads to handle multiple requests. Each of those will handle a single request at a time; however each process stays alive at the end of a request and continues to run in order to handle subsequent requests.
0
0
0
0
2017-01-12T19:45:00.000
2
1.2
true
41,621,666
0
0
1
2
I'm a little confused as to how Apache manages separate "instances" of a Django application. Let's say I do the following: Go to the URL of my Django application Open up a new browser tab In the new tab, also go to the URL of my Django application Are two Python instances started, one for each browser tab? The application contains a form that a user fills out. After they submit the form, a POST request is sent back to the view. The view then calls another function to do something with the POST data. Let's say I do that in the first browser tab. While that function is running, if I submit the form now in the second browser tab, will running that function be blocked until the function is done running in the first tab? Or are separate Python instances started? I'm just trying to figure out if I need to start a separate process each time the function is called from the view, in order to support multiple "instances" of the application (e.g., either in separate browser tabs or multiple users accessing the application simultaneously). Thanks for any clarification!
Is a separate Python instance started for each instance of a Django application via Apache?
41,621,708
0
1
57
0
python,django,apache
In the scenario you outlined there should be one instance of Django running on the server. It just happens to be managing two sessions.
0
0
0
0
2017-01-12T19:45:00.000
2
0
false
41,621,666
0
0
1
2
I'm a little confused as to how Apache manages separate "instances" of a Django application. Let's say I do the following: Go to the URL of my Django application Open up a new browser tab In the new tab, also go to the URL of my Django application Are two Python instances started, one for each browser tab? The application contains a form that a user fills out. After they submit the form, a POST request is sent back to the view. The view then calls another function to do something with the POST data. Let's say I do that in the first browser tab. While that function is running, if I submit the form now in the second browser tab, will running that function be blocked until the function is done running in the first tab? Or are separate Python instances started? I'm just trying to figure out if I need to start a separate process each time the function is called from the view, in order to support multiple "instances" of the application (e.g., either in separate browser tabs or multiple users accessing the application simultaneously). Thanks for any clarification!
How to view source code and project directories of AWS Beanstalk application?
41,682,747
9
3
2,471
0
python,amazon-web-services,amazon-elastic-beanstalk
Sign into AWS Console, click Services in top left, then click Elastic Beanstalk (under Compute), then click on your application (not applicationName-env, but just ApplicationName). Next, click Application Versions on the left hand side and you'll see a list of applications. Under the Source section, you can access the source code of your applcation.
0
0
0
0
2017-01-16T01:35:00.000
1
1.2
true
41,668,312
0
0
1
1
I just launched an AWS beanstalk django application after going through the steps provided by AWS. I used the default settings to create the application (the default "Welcome" page for Django). Is there any way for me to download or view the source code and project directories from the AWS console, or any other location?
Setting a remote control panel page for home automation
41,681,979
1
0
164
0
php,python,web,automation
The web site could be created in any number of languages, PHP being one good choice. The server could be local, or if you want to be able to interface globally, on a hosted server. How your Arduino connects to the server is the most telling part. If you use a WiFi or Ethernet shield, you can have it poll the server to get information (ie. turn something on/off) and to post info (ie. temp/humidity). In you want the server to be the controlling factor, have it use curl to poll a web server on the Arduino. The Arduino would respond with data, look for parameters for control, etc. I've written several projects that use the Arduino and Witty ESP8266 micro-controllers and interface with a web server. It's not that hard if you know everything you need to know about creating a web site, writing Arduino code, and HTTP communications. If you don't, there's a steep learning curve.
0
0
0
1
2017-01-16T16:35:00.000
1
1.2
true
41,680,964
0
0
1
1
I have a long term project, for learning purposes, which is creating a virtual assistent, such as Siri or Google Now, but to control my home automation. I'll have an arduino controling some hardware (such lamps, sensors, etc.), and the assistent I'll write in Python. Until this step, I have the knowledge to do this. But thinking forward, when this is functional, would be great if I could add the feature to control remotely by mobile app and/or webpage, and not just by my desktop. The problem is I don't know which knowledge I need have to do this. I want to have a web page, or a mobile app that show me this webpage, where I can program buttons to turn on/off stuff, check the sensors data, etc. I should like to use PHP, cause as I said, this is for learning purposes. I supose that I'll need set a server in my home, and then access him through this app/page. So, which programming skills I need to accomplish this (considering that arduino runs in C and the assistent will be scripted in Python)? Thanks.
Import Error on using pydoc
56,145,781
2
4
6,605
0
python,pydoc
When you get the import error from Pydoc, there are some steps you can find out the bug. Step Check the Python version of your files/packages and Pydoc are mapping. Some environment exist Python2 and Python3 at the same time. Basically, the alias pydoc is for Python 2, and pydoc3.X is for Python 3. Check the import file exists. Sometime you just import nonexistent file/module. Check the file/module can be imported by python. If you are documentizing your custom module in Python 2, please check __init__.py exist in your every directory of the main source code.
0
0
0
0
2017-01-17T08:51:00.000
4
0.099668
false
41,692,655
1
0
1
1
I have following files in same folder: config.py, init.py, asc.py and mainfile.py contents of init.py file: from mainfile import * config and asc files are imported in mainfile.py. I am creating html using pydoc as: python -m pydoc -w mainfile.py I am getting error as: <type 'exceptions.ImportError'>: No module named config If i will remove config, it works fine and html gets created but does not work with config file. What is the problem?
Running PyDev refactor from java code?
41,715,898
0
0
78
0
java,python,eclipse,plugins,pydev
If you mean in an Eclipse plugin with a dependency on PyDev, then yes, it should be possible... Take a look at the test-cases for this: com.python.pydev.refactoring.refactorer.refactorings.renamelocal.RenameClassRefactoringTest
0
0
0
0
2017-01-17T18:34:00.000
1
1.2
true
41,704,515
1
0
1
1
Is possible to call the pydev refactor (passing a new/old class name) from a Java code, such as clicking in a button in an Eclipse plugin?
Upgrading Facebook Ads token to "Basic"
41,785,371
0
1
75
0
python,facebook,facebook-graph-api,facebook-ads-api
Okay, so I just ended up filling the form and when asked for instructions of how to run the demo I explained that the app wasn't "demonstrable". And the app tier was upgraded automatically.
0
0
0
0
2017-01-18T22:20:00.000
1
1.2
true
41,730,490
0
0
1
1
I am developing an app using the Facebook Ads api. Initially it is just a Python script which downloads ads performance information from my client and stores it in a database, where it is combined with information from other sources in order to provide better reporting for them. It is not a web app (yet). It is just a Python script, working for a single business user account (yet!). The developer token clearly isn't enough because it limits access to 5 Ads Accounts. I would like to upgrade to basic account however the approval form requires things such as providing a video demo, website of the app, privacy policy, etc. The app doesn't have those because it is not intended for general use (yet!!). It seems that only an app focused on other Facebook users can apply to a Basic access token. Is this so? How can I upgrade my access token if my app is just a Python script running on a server? Thank you! :-)
python mechanize Http error 100
45,281,197
0
0
57
0
python-2.7,python-3.x
First verify if the login is being done by checking the redirected link with print br.geturl() If it is logging in and you're have an http error in your console use exceptions for the http error which will redirect you to your page
0
0
0
0
2017-01-19T02:12:00.000
1
0
false
41,732,616
0
0
1
1
I am having trouble logging in my Microsoft account using python mechanize utility. user-name and password are working fine. Problem comes when submitting the form, I get an interim response page with title: "continue" . and URL: some interim_URL. Question is how do I move to my intended URL? br.open("intended_URL") doesn’t work at all.
Accessing templatetags globally for django project
41,748,047
2
0
579
0
python,django,django-templates
Template tags need to be in an app. But once they are, they can be used by templates in any app. There is no need to do anything to make them available globally.
0
0
0
0
2017-01-19T17:25:00.000
2
1.2
true
41,747,991
0
0
1
1
I tried to add the path under INSTALLED_APPS and to create a folder of template tags and reuse them in multiple apps. But it is not working. Is there a smart way to work it out? All I need is to place templatetags for whole project in single directory accessible globally.
HTTP POST Data from Arduino to Django Database
41,748,434
0
1
1,484
0
django,postgresql,python-3.x,post,arduino
1)Depends, if your arduino is on the same local network than your Django Server then you don't need a public IP, otherwise you would have to forward your Django Server IP & port so its accesible from internet. 2) Not really, you can do a traditional POST request to a normal view on Django.
0
0
0
1
2017-01-19T17:43:00.000
1
1.2
true
41,748,325
0
0
1
1
I know it is frowned upon to post questions without code, but I have been stuck for days thinking of how to handle this issue and cant think of a solution. My setup is this: Arduino Mega w/ 4G + GPS Shield from Cooking Hacks Django Server set up with Python Postgresql Database Because the 4G + GPS shield has the capability for http commands, I want to use http POST to send gps data to my Django Server and store that information in my Postgresql database. Another thing to keep in mind is I am running a Django test server on my Localhost, so I need to POST to that local host. Because I am not posting through a form and it is not synchronous I am really confused as to how the Django server is supposed to handle this asynchronous POST. It will look like this (I imagine): Arduino (POST) --> Django Server (Localhost) --> Postgresql Database So I have 2 questions: 1) In order to successfully send a POST to my local Django Server, should my host be my public router IP and the Port be the same as that which I am running my server on? Is there something else I am missing? 2) Do I need to use Django REST Framework to handle the POST request? if not, how would I implement this in my views.py? I am trying to get a reference point on the problem in order to visualize how to do it. I DONT need coded solutions. Any help on this would be greatly appreciated, and if you have any other questions I will be quick to answer.
Benefits of foreign key over integerfield
41,751,929
1
0
61
0
python,django,database
Deleted objects If you ever decided to delete the original post, you'd need a separate query to handle whatever you expect to do with the cloned posts instead of using the on_delete kwarg of a FK. Its an extra query As noted in the comments, foreign keys allow you to traverse the relationships directly through the ORM relationship methods. Data structure visualisation tools These won't be able to traverse any further down from an integer field since it will believe it is at a leaf node. Throughout all of this though, the elephant in the room is that a "clone" is still just duplicated data so I wonder why you don't just let a blog post be referenced more than once then you don't need to worry about how you store clones.
0
0
0
0
2017-01-19T19:11:00.000
1
0.197375
false
41,749,825
0
0
1
1
I'm not sure if this is an appropriate question here. I know the answer but I don't really know why, and I need proof when I raise this to my team. We have a number of Blog Posts on a Django Site. It's possible to "clone" one of those blog posts to copy it to another site. The way the current developer did that was to take the pk of the original post and store it as an IntegerField on the cloned post as clone_source. Therefore to get a story's clones, we do: clones = BlogPost.all_sites.filter(clone_source=pk) It seems to me that this would be much better structured as a foreign key relationship. Am I right? Why or why not?
How to pass java literals from python dictionary
41,764,528
0
0
52
0
java,python,json
while passing json to java api from python replace null with None ,true with True and false with False. It will work
0
0
1
0
2017-01-20T05:33:00.000
2
0
false
41,756,756
1
0
1
2
I am trying to give rest call to java API using python. Java API needs JSON input with java literals like {a:null,b:true,c:false}, While parsing the JSON from python it is not allowing to do so because python needs null,true and false to be inside double quotes like "null","true","false". what is the solution?
How to pass java literals from python dictionary
41,756,812
0
0
52
0
java,python,json
The JSON syntax expects values to be quoted. It means that the problem comes from the java JSON api. What API do you use ?
0
0
1
0
2017-01-20T05:33:00.000
2
0
false
41,756,756
1
0
1
2
I am trying to give rest call to java API using python. Java API needs JSON input with java literals like {a:null,b:true,c:false}, While parsing the JSON from python it is not allowing to do so because python needs null,true and false to be inside double quotes like "null","true","false". what is the solution?
Django source code won't update on server
57,338,131
0
1
666
0
python,django,apache,wsgi
For those of you with cPanel, if you go under "Setup Python App" and click "Restart" it should update. Saved me about 5 times.
0
0
0
0
2017-01-20T05:37:00.000
3
0
false
41,756,800
0
0
1
1
I have a Django website running and any updates I make to the source code won't update. (Reason I'm changing the file is because one line of code is generating an error. What's weird is I commented out this line of code that causes the error, but the code still runs and thus still causes the error. In the django.log it shows that line causing the error still, but it also shows it commented out now. So the error log shows my new source code, but the application itself isn't executing the new code) I am very new to Django, so I don't really know what's going on here (not my website, I got thrown on this project for work.) Researching around for this, I have already tried to restart apache: $ sudo apachectl restart $ sudo service apache2 restart and I've also tried to touch the wsgi.py file: $ touch wsgi.py and I have even deleted the .pyc file. Nothing has worked and the old line of code is still executing, even though the logs show it commented out. Not sure where else to check or what else I'm missing.
Django select field with thousands of choices creating thousands of database queries
41,783,265
0
3
530
0
python,sql,django
unicode gets a field from these other models (self.foreign_key_field.field_to_print_out). This is where the other queries are made, not from the call to unicode or checking if its a b or a c. Had your unicode method reference only local fields this wouldn't have been an issue, but as you have noticed fields that require a join are not done automatically to save some performance on things that may not even be required. If you use django-debug-toolbar, you should notice that the 1000 queries are the retrieval of the related object, not the list of a objects. So yes, as you've pointed out, select_related would help here since this is you telling django that you do require these fields.
0
0
0
0
2017-01-21T18:54:00.000
1
1.2
true
41,783,198
0
0
1
1
I have two models, model B and model C, which both extend model A. In a form I have a model select field for model A - this obviously loads all instances of model B and C which was my intention. So this dropdown is over 1000 'A Objects'. I am using hasattr() to determine if they're B or C, which then uses the unicode method from those classes to display the object in string from in the dropdown. This creates thousands of SQL queries which takes around a minute to process. Right now my solution is to query the database 3 times (to get all A, B and C objects, and then loop over A and decide if each oject is of type B or C and push the correct unicode string into a list which is used in the dropdown. I then clean the data and select the right object when saving the form. This is hackey (to me). I was wondering if anyone knows of an efficient way of populating a dropdown with thousands of model object choices when that model is a Base Model for other models. Cheers, Dean
Django/ Python- should I run makemigrations on a local branch, or only on master?
41,811,454
0
1
655
0
python,django,git,migrate,makemigrations
Running makemigrations will automatically create python files in the "migrations" folder of the app where you modified the model. These files must be versionned in git because they cannot be dissociated from your modifications of the model. Then, when you will merge your branch, both the modification in the model and the corresponding migration will be in the git tree. So the next call to migrate will synchronize the DB with the current state described by your models.
0
0
0
0
2017-01-23T16:36:00.000
2
0
false
41,811,185
0
0
1
1
I am working on a project that has been written in Python/ Django, and have recently made some changes to one of the models. I want to test the changes that I have made now, before I go any further into the development of this new feature, but I am aware that I will need to run python manage.py makemigrations & python manage.py migrate before the changes that I have made to the models take effect. I am doing the development on a separate git branch to master, but am a bit unsure what the best practice is here in terms of running migrations on different branches (I am relatively new to both Python/ Django & Git). Would it be sensible to run makemigrations on my development branch, and testing it there, the same way I have been testing the bug fixes that I have worked on so far, or will I need to merge my development branch with master before running makemigrations? I know that if I do run the migrations on my development branch, I will need to run them again on master once I have merged my changes, but I was just wondering if there are any dangers to this approach, or things I should look out for?
Should we store session privileges in python shelve or as session variables?
41,957,026
5
3
226
0
python,session,flask,shelve
I recommend take a look at NoSQL storage engines like Memcached or Redis. They give you several advantages: Place at a separate machine, so if you need to scale your app you'll be able to do it. Extra interface to check what is stored in them. Ability to flush if you really need once. You can connect other apps to the these programs, so you can share sessions across several apps (however it's not recommended for big fast developing apps and keeping complicated structures).
0
0
0
0
2017-01-25T07:23:00.000
2
1.2
true
41,845,657
1
0
1
1
Writing a web based flask api application with several modules. I would like to incorporate different permissions and privileges for different user logins for the different modules. Query is whether these privileges should be stored as session dictionaries or as shelve values? Which is more efficient and faster? Why would there be a preference of one over the other in this context?
How can I run a simple python script hosted in the cloud on a specific schedule?
50,078,814
0
0
549
0
python,amazon-web-services,heroku,cron
Update: AWS does now support Python 3.6. Just select Python 3.6 from the runtime environments when configuring.
0
1
0
0
2017-01-25T16:49:00.000
3
0
false
41,857,126
0
0
1
1
Say I have a file "main.py" and I just want it to run at 10 minute intervals, but not on my computer. The only external libraries the file uses are mysql.connector and pip requests. Things I've tried: PythonAnywhere - free tier is too limiting (need to connect to external DB) AWS Lambda - Only supports up to Python 2.7, converted my code but still had issues Google Cloud Platform + Heroku - can only find tutorials covering deploying applications, I think these could do what I'm looking for but I can't figure out how. Thanks!
PDF Attachment Downloader not working with base64 Encoding
41,858,705
1
0
405
0
python,python-2.7,pdf,base64,imaplib
email.header.decode_header() was exactly what I needed. Thanks so much! Added the following lines: filename = part.get_filename() if decode_header(filename)[0][1] is not None: filename = str(decode_header(filename)[0][0]).decode(decode_header(filename)[0][1]) filename_zero, fileext = os.path.splitext(filename) filename = str(var_seq) + "_" + filename_zero + fileext
0
0
0
0
2017-01-25T17:27:00.000
1
1.2
true
41,857,884
0
0
1
1
I have a program that will pull file attachments into a network share. I have this working in both single part and multi-part email messages. I have recently received a mutlipart that is showing as : Content-Type: application/pdf Content-Disposition: attachment; filename="=?utf-8?B?SW52b2ljZShzKS5wZGY=?=" Content-Transfer-Encoding: base64 This is failing at the file write due to the filename. Here is the code where I'm writing the PDF: fp = open(os.path.join(path, filename), 'wb') fp.write(part.get_payload(decode=True)) fp.close() However I think that part is working properly and it's failing on the file write... I'm not sure how to translate that filename into readable text. Here is the code I'm using to determine the filename: filename = part.get_filename() filename_zero, fileext =os.path.splitext(filename) filename = str(var_seq) + "_" + filename_zero + fileext Any insight into what I'm missing is greatly appreciated.