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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Are "Field" and "Fields" reserved words in Django or Python?
| 24,553,843 | 2 | 3 | 1,219 | 0 |
python,django
|
little explanation with fun
Answer is Simply No,
Because Language only has the authority to own anything.Python is the owner of the house
The Django guy is paying rent to Python guy. So, How Django guy can reserve the objects of the house?
same logic is applied here too
| 0 | 0 | 0 | 0 |
2014-07-02T16:19:00.000
| 2 | 0.197375 | false | 24,536,240 | 0 | 0 | 1 | 1 |
I'm developing a django project for agriculture. I want to name an app "fields" and inside the app "fields" I want to name a model "Field" (referring to a farmer field).
I tried it and it works, so I assume that "fields" and "Field" are not reserved words in Django or Python. But I was just wondering if using these words can be problematic in the future or it's just fine?
And the general question:
Is there any way to check if a word is reserved in Django or Python?
|
integrating with existing html page django-page-cms
| 24,554,222 | 0 | 0 | 64 | 0 |
python,django
|
First you need to create page in admin console. Then add the placeholder in your template
like what tutorial saying
{% get_page "news" as news_page %}
{% for new in news_page.get_children %}
<li>
{{ new.publication_date }}
{% show_content new body %}
{% endfor %}
| 0 | 0 | 0 | 0 |
2014-07-03T11:51:00.000
| 1 | 1.2 | true | 24,552,964 | 0 | 0 | 1 | 1 |
I have installed django-page-cms successfully i think. Like other cms, it is also for creating new pages. But I already have html pages in my project. How to integrate with that?
They want me to put place holder in html page, like:
{% load pages_tags %}
but I think this will bring the content from the already created page in admin
Can anyone tell me how to integrate with my existing pages?
|
Difficulty accessing local webserver
| 24,558,290 | 0 | 1 | 184 | 0 |
android,python,solr,webserver,tokyo-tyrant
|
Both "localhost" and "127.0.0.1" are local loopback interfaces only: they only make sense within the same machine. From your Android device, assuming it's on the same wifi network as your machine, you'll need to use the actual IP address of your main machine: you can either find that from the network settings of that machine, or from your router's web interface.
| 0 | 1 | 1 | 0 |
2014-07-03T15:25:00.000
| 4 | 0 | false | 24,557,707 | 0 | 0 | 1 | 3 |
I have an Echoprint local webserver (uses tokyotyrant, python, solr) set up on a Linux virtual machine.
I can access it through the browser or curl in the virtual machine using http//localhost:8080 and in the non-virtual machine (couldn't find out how to say it better) I use the IP on the virtual machine also with the 8080 port.
However, when I try to access it through my android on the same wifi I get a connection refused error.
|
Difficulty accessing local webserver
| 24,635,024 | 0 | 1 | 184 | 0 |
android,python,solr,webserver,tokyo-tyrant
|
In case someone has the same problem, I solved it.
The connection has to be by cable and on the VMware Player settings the network connection has to be bridged, also you must click "Configure adapters" and uncheck the "VirtualBox Host-Only Ethernet Adapter".
| 0 | 1 | 1 | 0 |
2014-07-03T15:25:00.000
| 4 | 1.2 | true | 24,557,707 | 0 | 0 | 1 | 3 |
I have an Echoprint local webserver (uses tokyotyrant, python, solr) set up on a Linux virtual machine.
I can access it through the browser or curl in the virtual machine using http//localhost:8080 and in the non-virtual machine (couldn't find out how to say it better) I use the IP on the virtual machine also with the 8080 port.
However, when I try to access it through my android on the same wifi I get a connection refused error.
|
Difficulty accessing local webserver
| 24,557,803 | 0 | 1 | 184 | 0 |
android,python,solr,webserver,tokyo-tyrant
|
Is the server bound to localhost or 0.0.0.0?
Maybe your host resolves that ip to some kind of a localhost as well, due to bridging.
| 0 | 1 | 1 | 0 |
2014-07-03T15:25:00.000
| 4 | 0 | false | 24,557,707 | 0 | 0 | 1 | 3 |
I have an Echoprint local webserver (uses tokyotyrant, python, solr) set up on a Linux virtual machine.
I can access it through the browser or curl in the virtual machine using http//localhost:8080 and in the non-virtual machine (couldn't find out how to say it better) I use the IP on the virtual machine also with the 8080 port.
However, when I try to access it through my android on the same wifi I get a connection refused error.
|
Projection of a Tastypie REST API into python objects
| 24,677,758 | 0 | 2 | 276 | 0 |
python,mysql,django,rest,sqlalchemy
|
You want to see what queries are generated by django ORM or tastepy?
I think one easy way is to do a wrappper arround the DB class, where you run the DB class method, analise the results and print our save them to a file.
Another way to do this, is to use mysql slow_query_log with 0 seconds to log all the queries that are being made to MYSQL.
You can use a diferent user our schema to parse the results more easy.
Not good to test in production services :)
| 0 | 0 | 0 | 1 |
2014-07-03T19:40:00.000
| 2 | 0 | false | 24,562,068 | 0 | 0 | 1 | 1 |
I want to test web applications that were developed using Django framework and Tastypie.
My plan was to test the REST API calls of the web apps against the queries they perform on the MySql DB. In order to do so I've investigated a little bit about DB access framework, and have encountered SQLalchemy framework, and the reflection attitude.
My thought were to try and access the Web Apps REST API in the same attitude and test the results from both sources.
Can you please suggest a different approach for examining this problem? Is there framework that will help for this task?
|
Django Models Abstract Base Class - can they be extended across apps?
| 24,563,099 | 1 | 1 | 123 | 0 |
python,django,abstract-class
|
Since an abstract base class is not a registered model, it makes absolutely no difference where it lives. It can be in any Python file that can be imported by the models.py files in each app.
| 0 | 0 | 0 | 0 |
2014-07-03T20:40:00.000
| 1 | 1.2 | true | 24,562,961 | 0 | 0 | 1 | 1 |
Sorry for the silly question, I can't seem to find a definitive answer.
In almost all of the models in all of the apps in my Django project, there are two common fields - last_updated and date_created. I want to cut down on code by putting them into an abstract base class, of which all of my models extend.
Is there some way to use a single Abstract Base Class across all of my apps - and if so, is there a natural place for that class to live?
Thanks.
|
BeautifulSoup Object Will Not Pickle, Causes Interpreter to Silently Crash
| 24,563,375 | 1 | 9 | 3,438 | 0 |
python,beautifulsoup,pickle
|
In fact, as suggested by dekomote, you have only to take advantadge that you can allways convert a soup to an unicode string and then back again the unicode string to a soup.
So IMHO you should not try to pass soup object through the multiprocessing package, but simply the strings representing the soups.
| 0 | 0 | 0 | 0 |
2014-07-03T20:53:00.000
| 3 | 0.066568 | false | 24,563,148 | 1 | 0 | 1 | 1 |
I have a soup from BeautifulSoup that I cannot pickle. When I try to pickle the object the python interpreter silently crashes (such that it cannot be handled as an exception). I have to be able to pickle the object in order to return the object using the multiprocessing package (which pickles objects to pass them between processes). How can I troubleshoot/work around the problem? Unfortunately, I cannot post the html for the page (it is not publicly available), and I have been unable to find a reproducible example of the problem. I have tried to isolate the problem by looping over the soup and pickling individual components, the smallest thing that produces the error is <class 'BeautifulSoup.NavigableString'>. When I print the object it prints out u'\n'.
|
Is Beautiful Soup available for Python 3.4.1?
| 27,249,435 | 0 | 12 | 11,995 | 0 |
python,beautifulsoup
|
I'm new to this as well.
I agree - it's not always clear from forum answers where to type the various suggestions when you're new to the subject.
Start by opening a command prompt. You can do this by typing CMD into the searchbox after pressing the start button.
At the command prompt, type "python -m pip install beautifulsoup4"
At this point, the module should be downloaded and installed.
To check that it's installed correctly, you can open the python command line program - (the one that gives you ">>>" prompts) and type "from bs4 import BeautifulSoup"
Note that everything is case sensitive, so be careful when you type.
If no errors are reported, the module is correctly installed on your machine and you can proceed to your next hurdle. :)
Good luck.
| 0 | 0 | 0 | 0 |
2014-07-06T01:50:00.000
| 4 | 0 | false | 24,592,036 | 0 | 0 | 1 | 3 |
I want to try and make a program that downloads images from the internet, and I have found a guide that uses Beautiful soup. I have heard of Beautiful Soup before, so I figured that I would try it out. My only issue is that I can't seem to find a version for Python 3. I went to their website, but I was unable to find a version that worked with Python 3.
Whenever I would run the setup.py file, I would get an error that was too quick to read, but it looked like it was saying syntax error.
So I looked at the code and realized that there weren't any parenthesis in front or after strings that were supposed to be printed.
I have tried numerous different webpages and different searches, but was unable to find an answer.
I'm also sorry if this is not a question related to programming, if it is not, please leave a comment on this question and I will delete the question ASAP.
|
Is Beautiful Soup available for Python 3.4.1?
| 37,222,073 | 0 | 12 | 11,995 | 0 |
python,beautifulsoup
|
Try using "python -m pip install beautifulsoup4"
This line is working perfectly fine for me on Python 3.4
| 0 | 0 | 0 | 0 |
2014-07-06T01:50:00.000
| 4 | 0 | false | 24,592,036 | 0 | 0 | 1 | 3 |
I want to try and make a program that downloads images from the internet, and I have found a guide that uses Beautiful soup. I have heard of Beautiful Soup before, so I figured that I would try it out. My only issue is that I can't seem to find a version for Python 3. I went to their website, but I was unable to find a version that worked with Python 3.
Whenever I would run the setup.py file, I would get an error that was too quick to read, but it looked like it was saying syntax error.
So I looked at the code and realized that there weren't any parenthesis in front or after strings that were supposed to be printed.
I have tried numerous different webpages and different searches, but was unable to find an answer.
I'm also sorry if this is not a question related to programming, if it is not, please leave a comment on this question and I will delete the question ASAP.
|
Is Beautiful Soup available for Python 3.4.1?
| 37,579,583 | 0 | 12 | 11,995 | 0 |
python,beautifulsoup
|
Below work for me.
Source of content is quora.com.
Make sure you download the recent beautifulsoup version.
For Windows how to install beautifulsoup4 for python2 or python3.
Place the file you downloaded in any file directory on your computer.
First locate where your Python file directory is below am using C:\Python27
To open open command prompt type cmd into the run file.
in command prompt do this.
type cd Python27
then type
pip install beautifulsoup4.
You may have to use the full path:
C:\Python27\Scripts\pip install beauifulsoup4
or even
C:\Python27\Scripts\pip.exe install beautifulsoup4
for Python3
in command prompt do this.
type cd Python34
then type
pip install beautifulsoup4
You may have to use the full path:
C:\Python34\Scripts\pip install beauifulsoup4
or even
C:\Python34\Scripts\pip.exe install beautifulsoup4
| 0 | 0 | 0 | 0 |
2014-07-06T01:50:00.000
| 4 | 0 | false | 24,592,036 | 0 | 0 | 1 | 3 |
I want to try and make a program that downloads images from the internet, and I have found a guide that uses Beautiful soup. I have heard of Beautiful Soup before, so I figured that I would try it out. My only issue is that I can't seem to find a version for Python 3. I went to their website, but I was unable to find a version that worked with Python 3.
Whenever I would run the setup.py file, I would get an error that was too quick to read, but it looked like it was saying syntax error.
So I looked at the code and realized that there weren't any parenthesis in front or after strings that were supposed to be printed.
I have tried numerous different webpages and different searches, but was unable to find an answer.
I'm also sorry if this is not a question related to programming, if it is not, please leave a comment on this question and I will delete the question ASAP.
|
Is it possible to add a letter or some other character in front of an incrementing field?
| 24,602,097 | 0 | 0 | 113 | 0 |
python,mysql,django,django-models
|
It is not possible with an auto-incrementing field, exclusively. You could set up another column inside each table with a single letter identifying the table, have an auto-incrementing column, and then make the key the combination of the two. You can also set this up using a trigger.
However, this doesn't fully make sense because the letter really isn't needed within a single table.
I suspect that you are trying to solve a different problem, which is to have multiple "types" of an entity in different tables (say a table of contacts, with one for email, one for mail, one for telephone contact). If so, another approach is to have a master table of everything with an auto-incrementing id, and then to use this id in the subtables, defined with a 1-1 relationship.
| 0 | 0 | 0 | 0 |
2014-07-07T01:43:00.000
| 2 | 0 | false | 24,602,022 | 0 | 0 | 1 | 1 |
What I would like to do is have my primary key field (or another field as long as it accepts auto incrementing) auto increment with a letter in front of it. For example:
I would like to be able to make pk equal A1,A2,A3 in one table, and if i choose, B1, B2,B3 in another table. Is this possible with django? mysql? The field doesn't have to be the primary key field as long as it auto increments. Please let me know.
|
Execute Python Script from Django
| 24,620,400 | 0 | 0 | 292 | 0 |
python,django,subprocess,popen,django-celery
|
I suggest using Celery.
subprocess, multiprocessing, and threading all are powerful tools, but are in general hard to get working. They're more useful if you already have a working system, are running at the limit of the hardware, and don't mind spending a good deal of effort to get lower latency or parallel processing or higher throughput.
| 0 | 1 | 0 | 0 |
2014-07-07T21:31:00.000
| 1 | 1.2 | true | 24,620,225 | 0 | 0 | 1 | 1 |
I am trying to execute a python script from a webpage through a Django view. Other questions related to a known script from within the Django project directory. I need to be able to execute a script anywhere on the system given the file path. Eventually, multiple scripts will be run in parallel using Celery or a similar method. Should I be using some permutation of popen or sub-processing?
|
Django - Multiple apps on one webpage?
| 24,644,610 | 11 | 15 | 11,743 | 0 |
python,django
|
A django app doesn't really map to a page, rather, it maps to a function. Apps would be for things like a "polls" app or a "news" app. Each app should have one main model with maybe a couple supporting ones. Like a news app could have a model for articles, with supporting models like authors and media.
If you wanted to display multiple, you would need an integration app. One way to do this is to have a "project" app next to your polls and news apps. The project app is for your specific website- it is the logic that is specific to this application. It would have your main urls.py, your base templat(s), things like that. If you needed information from multiple apps in one page, you have to have a view that returns info from multiple apps. Say, for example, that you have a view that returns the info for a news article, and one that returns info for a poll. You could have a view in your project app that calls those two view functions and sticks the returned data into a different template that has spots for both of them.
In this specific example, you could also have your polls app set up so that its return info could be embedded- and then embed the info into a news article. In this case you wouldn't really have to link the apps together at all as part of your development, it could be done as needed on the content creation end.
| 0 | 0 | 0 | 0 |
2014-07-08T02:16:00.000
| 5 | 1 | false | 24,622,714 | 0 | 0 | 1 | 1 |
I've looked all over the net and found no answer.
I'm new to Django. I've done the official tutorial and read many more but unfortunately all of them focus on creating only one application. Since it's not common to have a page as a single app, I would like to ask some Django guru to explain how I can have multiple apps on a webpage. Say I go to mysite.com and I see a poll app displaying a poll, gallery app displaying some pics, news app displaying latest news etc, all accessed via one url. I know I do the displaying in template but obviously need to have access to data. Do I create the view to return multiple views? Any advice, links and examples much appreciated.
|
Django include models.py from project to multiple apps
| 24,628,844 | 0 | 2 | 2,218 | 0 |
python,django,django-models,import
|
You are not meant to put models directly on a project level in Django. Every model have to be associated with a particular app. On the other hand you can import models between apps.
If you feel a need for a project level models it just means you haven't partitioned your functionality into apps properly. There shouldn't be any reason to have "project level models" (or "project level views" for that matter). You just need to split the functionality into separate apps.
Let's say you are designing an intranet website for a school. You would have one app that deals with students' accounts, and another app generating timetables, and yet another one for an internal message board, etc.. Every app defines its own models (there are no "project level models"), but apps can import each others models (so message board posts can have a ForeignKey field pointing at student from the "students" app).
| 0 | 0 | 0 | 0 |
2014-07-08T09:10:00.000
| 3 | 0 | false | 24,627,919 | 0 | 0 | 1 | 1 |
I would like to know if there is a way to include/import the models.py from the project directory to multiple apps without copying the model in each app. Thank you!
|
Gunicorn max_requests for Production
| 24,656,069 | 0 | 8 | 3,830 | 0 |
python,gunicorn
|
Yes and no. Depends. Restarting workers eats resources. But the price is not too high. On the other hand if you have memory leaks then it will allow you to save memory. Thus effectively increasing performance.
| 0 | 0 | 0 | 0 |
2014-07-09T13:58:00.000
| 2 | 0 | false | 24,655,713 | 0 | 0 | 1 | 2 |
Is there any effect on performance if I use gunicorn max_requests setting for production server?
|
Gunicorn max_requests for Production
| 26,990,224 | 0 | 8 | 3,830 | 0 |
python,gunicorn
|
I've just found that this setting is the cause of a response time issue I have having. Baseline response time of one of my sites, measured locally, was about 20ms. This goes up to about 300ms on a worker restart, so yes, there is a performance impact.
As a result of this, I've upped my setting from a super-safe 10 to 100.
| 0 | 0 | 0 | 0 |
2014-07-09T13:58:00.000
| 2 | 0 | false | 24,655,713 | 0 | 0 | 1 | 2 |
Is there any effect on performance if I use gunicorn max_requests setting for production server?
|
Using PhoneGap + Google App Engine to Upload and Save Images
| 24,657,475 | 0 | 1 | 620 | 1 |
python,google-app-engine,cordova,google-cloud-storage
|
Yes, that is a fine use for GAE and GCS. You do not need an <input type=file>, per se. You can just set up POST parameters in your call to your GAE url. Make sure you send a hidden key as well, and work from SSL-secured urls, to prevent spammers from posting to your app.
| 0 | 1 | 0 | 0 |
2014-07-09T14:05:00.000
| 2 | 0 | false | 24,655,877 | 0 | 0 | 1 | 1 |
Goal: Take/attach pictures in a PhoneGap application and send a public URL for each picture to a Google Cloud SQL database.
Question 1: Is there a way to create a Google Cloud Storage object from a base64 encoded image (in Python), then upload that object to a bucket and return a public link?
I'm looking to use PhoneGap to send images to a Python Google App Engine application, then have that application send the images to a Google Cloud Storage bucket I have set up, then return a public link back to the PhoneGap app. These images can either be taken directly from the app, or attached from existing photo's on the user's device.
I use PhoneGap's FileTransfer plugin to upload the images to GAE, which are sent as base64 encoded images (this isn't something I can control).
Based on what I've found in Google Docs, I can upload the images to Blobstore; however, it requires <input type='file'> elements in a form. I don't have 'file' input elements; I just take the image URI returned from PhoneGap's camera object and display a thumbnail of the picture that was taken (or attached).
Question 2: Is it possible to have an <input type='file'> element and control it's value? As in, is it possible to set it's value based on whether the user chooses a file, or takes a picture?
Thanks in advance!
|
Set environment variables in GAE control panel
| 35,254,560 | 4 | 2 | 2,796 | 0 |
python,google-app-engine
|
You can store your keys in datastore. Later when you need them in the code, you can fetch them from datastore and cache them by memcache.
| 0 | 1 | 0 | 0 |
2014-07-10T10:06:00.000
| 3 | 0.26052 | false | 24,673,772 | 0 | 0 | 1 | 1 |
I deploy my project to GAE over Github. There is some foreign API-key which I don't want to save in repository and make them public. Is it possible to set an environment variable for a project in GAE control panel so I can catch it in my application?
|
Python Export Program to PDF using Latex format
| 24,684,691 | 1 | 0 | 2,206 | 0 |
python,pdf,export,latex,pdflatex
|
generate a Latex file.tex with a Python script
f= open("file.tex", 'w')
f.write('\documentclass[12pt]{article}\n')
f.write('\usepackage{multicol}\n')
f.write('\n\begin{document}\n\n')
...
f.write('\end{document}')
f.close()
run pdflatex on the LaTex file from the Python script as a subprocess
subprocess.call('latex file.tex')
As an alternative to 1. you can generate a LaTex template and just substitute the variable stuff using Python regular expressions and string substitutions.
| 0 | 0 | 0 | 1 |
2014-07-10T19:00:00.000
| 3 | 0.066568 | false | 24,684,316 | 0 | 0 | 1 | 1 |
I have a GUI program in Python which calculates graphs of certain functions. These functions are mathematical like say, cos(theta) etc. At present I save the graphs of these functions and compile them to PDF in Latex and write down the equation manually in Latex.
But now I wish to simplify this process by creating a template in Latex that arranges, The Function Name, Graph, Equation and Table and complies them to a single PDF format with just a click.
Can this be done? And how do I do it?
Thank you.
|
Django Rest Framework--deny access to list but not to retrieve
| 27,932,256 | 0 | 1 | 302 | 0 |
python,django,rest,permissions,django-rest-framework
|
One of the arguments to has_permission is view, which has an attribute .action, which is one of the five "LCRUD" actions ("list"/"create"/"retrieve"/"update"/"destroy"). So I think you could use that to check, in has_permission, whether the action being performed is a list or a retrieve, and deny or allow it accordingly.
| 0 | 0 | 0 | 0 |
2014-07-10T19:32:00.000
| 1 | 0 | false | 24,684,821 | 0 | 0 | 1 | 1 |
I'm using Django Rest Framework and I'm having some trouble with permissions. I know how to use has_permission and has_object_permission, but I have a number of cases where someone needs to be able to access retrieve but not list--e.g., a user has access to their own profile, but not to the full list of them. The problem is, has_permission is always called before has_object_permission, so has_object_permission can only be more restrictive, not less.
So far, the only way I've been able to do this is to have more permissive permissions and then overwrite list() directly in the ViewSet and include the permission check in the logic, but I'd be able to actually store all of this logic in a Permissions class rather than in each individual viewset.
Is there any way to do this? Right now I feel like I'm goign to have to write a ViewSet metaclass to automatically apply permissions as I want to each viewset method, which isn't really something I want to do.
|
How can I identify requests made via AJAX in Python's Flask?
| 56,367,083 | 1 | 15 | 5,005 | 0 |
python,ajax,angularjs,flask
|
There isn't any way to be certain whether a request is made by ajax.
What I found that worked for me, was to simply include a get parameter for xhr requests and simply omit the parameter on non-xhr requests.
For example:
XHR Request: example.com/search?q=Boots&api=1
Other Requests: example.com/search?q=Boots
| 0 | 0 | 1 | 0 |
2014-07-10T23:06:00.000
| 3 | 0.066568 | false | 24,687,736 | 0 | 0 | 1 | 1 |
I'd like to detect if the browser made a request via AJAX (AngularJS) so that I can return a JSON array, or if I have to render the template. How can I do this?
|
Django: storing/querying a dictionary-like data set?
| 24,690,665 | 0 | 0 | 992 | 1 |
python,mysql,django,mongodb,database
|
In a Django project you've got 4 alternatives for this kind of problem, in no particular order:
using PostgreSQL, you can use the hstore field type, that's basically a pickled python dictionary. It's not very helpful in terms of querying it, but does its job saving your data.
using Django-NoRel with mongodb you get the ListField field type that does the same thing and can be queried just like anything in mongo. (option 2)
using Django-eav to create an entity attribute value store with your data. Elegant solution but painfully slow queries. (option 1)
storing your data as a json string in a long enough TextField and creating your own functions to serializing and deserializing the data, without thinking on being able to make a query over it.
In my own experience, if you by any chance need to query over the data, your option two is by far the best choice. EAV in Django, without composite keys, is painful.
| 0 | 0 | 0 | 0 |
2014-07-11T00:29:00.000
| 2 | 0 | false | 24,688,388 | 0 | 0 | 1 | 1 |
I apologize if this has been asked already, or if this is answered somewhere else.
Anyways, I'm working on a project that, in short, stores image metadata and then allows the user to search said metadata (which resembles a long list of key-value pairs). This wouldn't be too big of an issue if the metadata was standardized. However, the problem is that for any given image in the database, there is any number of key/values in its metadata. Also there is no standard list of what keys there are.
Basically, I need to find a way to store a dictionary for each model, but with arbitrary key/value pairs. And I need to be able to query them. And the organization I'm working for is planning on uploading thousands of images to this program, so it has to query reasonably fast.
I have one model in my database, an image model, with a filefield.
So, I'm in between two options, and I could really use some help from people with more experience on choosing the best one (or any other solutions that would work better)
Using a traditional relational database like MySql, and creating a separate model with a foreignkey to the image model, a key field, and a value field. Then, when I need to query the data, I'll ask for every instance of this separate table that relates to an image, and then query those rows for the key/value combination I need.
Using something like MongoDB, with django-toolbox and its DictField to store the metadata. Then, when I need to query, I'll access the dict and search it for the key/value combination I need.
While I feel like 1 would be much better in terms of query time, each image may have up to 40 key/values of metadata, and that makes me worry about that separate "dictionary" table growing far too large if there's thousands of images.
Any advice would be much appreciated. Thanks!
|
Add a column to heroku postgres database
| 24,698,874 | 0 | 1 | 1,178 | 1 |
python,django,postgresql,heroku
|
I presume that you have created a migration to add mainsite_message.spam to the schema. Have you made sure that this migration is in your git repository?
If you type git status you should see untracked files. If the migration is untracked you need to git add path_to_migration and then push it to Heroku before you can run it there.
| 0 | 0 | 0 | 0 |
2014-07-11T12:11:00.000
| 3 | 0 | false | 24,697,420 | 0 | 0 | 1 | 2 |
So, locally I've changed my models a few times and used South to get everything working. I have a postgres database to power my live site, and one model keeps triggering a column mainsite_message.spam does not exist error. But when I run heroku run python manage.py migrate mainsite from the terminal, I get Nothing to migrate. All my migrations have been pushed.
|
Add a column to heroku postgres database
| 24,697,852 | 0 | 1 | 1,178 | 1 |
python,django,postgresql,heroku
|
Did you run schemamigration before? If yes, go to your database and take a look at your table "south_migrationhistory" there you can see what happened.
If you already did the steps above you should try to open your migration file and take a look as well, there you can find if the creation column is specified or not!
| 0 | 0 | 0 | 0 |
2014-07-11T12:11:00.000
| 3 | 0 | false | 24,697,420 | 0 | 0 | 1 | 2 |
So, locally I've changed my models a few times and used South to get everything working. I have a postgres database to power my live site, and one model keeps triggering a column mainsite_message.spam does not exist error. But when I run heroku run python manage.py migrate mainsite from the terminal, I get Nothing to migrate. All my migrations have been pushed.
|
How to throttle S3 & Glacier upload/download speeds with boto?
| 41,159,662 | 1 | 0 | 1,618 | 0 |
python,boto
|
The simplest would be to use traffic shaping tools under linux, like tc. These tools let you control bandwidth and even simulate network packet loss or even long distance communication issues. Easy to write a python script to control the port behavior via a shell.
| 0 | 0 | 1 | 0 |
2014-07-11T16:53:00.000
| 3 | 0.066568 | false | 24,702,818 | 0 | 0 | 1 | 1 |
I'm using boto to upload and download files to S3 & Glacier.
How can I ratelimit/throttle the uploading and downloading speeds?
|
Is there a way to specify a default base-template for all templates in django?
| 24,710,778 | 1 | 1 | 273 | 0 |
python,django,django-templates
|
Unless you want to write your own template loader function that looks to your settings for the default and monkey-patch it in, then "no, there isn't a way to do that" is accurate.
At least it's only one line per file.
Plus, being a long-standing Django convention, other devs will immediately be able to see which base template is used (in more complex projects you may find you use different base templates depending on, say, the type of user).
Finally, as the Zen of Python goes, explicit is better than implicit. :-)
| 0 | 0 | 0 | 0 |
2014-07-12T04:08:00.000
| 3 | 1.2 | true | 24,709,551 | 0 | 0 | 1 | 2 |
I'm 2 hours into Django and am wondering if there is a way to specify a default base template that will automatically be loaded for all templates so that you don't have to repeat yourself and specify {% extends "foo.html" %} at the top of every page template.
For example, at the project or app level some metadata(settings) could specify a default template that was used unless either the call to render or the template itself specified that you shouldn't include the template.
i. e. render(... other args..., layout=null) or {% noextends "foo.html" %}
This effectively turns the opt-in style into an opt-out, which in my experience is preferred. Given that it's specified in something like settings it's not "magic" and breaking with the spirit of Django.
I've looked over the documentation and this doesn't seem to be available by default. I suppose I could do something like override the built-in render routine to try and concatenate the {% extends "foo.html" %} call on to every template, but I am hoping the internet can just tell me there is already a solution that I'm missing.
|
Is there a way to specify a default base-template for all templates in django?
| 24,711,278 | 1 | 1 | 273 | 0 |
python,django,django-templates
|
Don't forget, it's a guiding principle in Python - and therefore also in Django - that explicit is better than implicit. So whereas Rails, for example, emphasises convention over configuration and has all sorts of things happen automatically, this is very much alien to the Python way of doing things.
So no, there is no way to get Django to make templates inherit from a base automatically. And while you probably could get that working by creating a custom template loader, it's not a very good idea as it would confuse everyone else looking at your project.
| 0 | 0 | 0 | 0 |
2014-07-12T04:08:00.000
| 3 | 0.066568 | false | 24,709,551 | 0 | 0 | 1 | 2 |
I'm 2 hours into Django and am wondering if there is a way to specify a default base template that will automatically be loaded for all templates so that you don't have to repeat yourself and specify {% extends "foo.html" %} at the top of every page template.
For example, at the project or app level some metadata(settings) could specify a default template that was used unless either the call to render or the template itself specified that you shouldn't include the template.
i. e. render(... other args..., layout=null) or {% noextends "foo.html" %}
This effectively turns the opt-in style into an opt-out, which in my experience is preferred. Given that it's specified in something like settings it's not "magic" and breaking with the spirit of Django.
I've looked over the documentation and this doesn't seem to be available by default. I suppose I could do something like override the built-in render routine to try and concatenate the {% extends "foo.html" %} call on to every template, but I am hoping the internet can just tell me there is already a solution that I'm missing.
|
Using Django Users for all logged in users, and registering them
| 24,718,066 | 0 | 0 | 48 | 0 |
python,django,django-users,python-3.4
|
I was just talking to an advanced developer friend of mine about this. He said using djangos users is frowned upon and to build it out separately. I don't know much more on this but it's something I will be doing in the future.
| 0 | 0 | 0 | 0 |
2014-07-12T21:04:00.000
| 2 | 0 | false | 24,717,307 | 0 | 0 | 1 | 1 |
I have a site that - other than the signup process - will be only used by logged in users. It's my first Django site, and I'm wondering whether I can use the Django user model (slightly extended) to work with all my users, or should it only be used for administrative users such as myself?
Apologies if this is a stupid question. Additionally, and either way, what's the best way to manage user registrations? It'd be awesome if this were built into Django, but it's not, and I read django-registration is relatively abandoned. Any recommendations welcome.
|
How do I test that Django upgrades don't break the current database?
| 24,718,048 | 0 | 0 | 50 | 0 |
python,django,upgrade
|
You can always crate a dump of your database if you are afraid of losing data.
| 0 | 0 | 0 | 0 |
2014-07-12T22:39:00.000
| 2 | 0 | false | 24,717,941 | 0 | 0 | 1 | 2 |
What is the best way of writing a unit test in Django that tests the validity of current database information when Django is upgraded?
My unit tests create new information in the databases when they are run, but this isn't helpful for safely upgrading.
|
How do I test that Django upgrades don't break the current database?
| 24,731,271 | 0 | 0 | 50 | 0 |
python,django,upgrade
|
What do you think could happen when you upgrade Django? Django updated your files not your database without permission from you. So you could upgrade your Django and run all your tests (local) to see if nothing is broken.
| 0 | 0 | 0 | 0 |
2014-07-12T22:39:00.000
| 2 | 0 | false | 24,717,941 | 0 | 0 | 1 | 2 |
What is the best way of writing a unit test in Django that tests the validity of current database information when Django is upgraded?
My unit tests create new information in the databases when they are run, but this isn't helpful for safely upgrading.
|
pygtk TextView and WebKit.WebView synchronized scrolling
| 24,722,441 | 0 | 0 | 221 | 0 |
python,webkit,gtk,pygtk
|
why do you want sync those scrollbars? You can achieve this by using the same Gtk.Adjustment (number of pages sets to 0).
I haven't use much of webkit but it essentialy a widget. so maybe a workaround would be disconnect a signal "value-changed" from Gtk.Adjustment until "load-status" signal from WebKitView reached Webkit.LoadStatus.FINISHED (if that's the correct syntax).
If that doesn't work, maybe you use WebKitView.move_cursor () (if i remember the function properly) based on Gtk.Adjustment on your text view (we use 2 adjustments this time)
| 1 | 0 | 0 | 0 |
2014-07-12T23:15:00.000
| 1 | 0 | false | 24,718,142 | 0 | 0 | 1 | 1 |
I've got a text view and a web view, each inside a scrolled window of their own and I'm trying to achieve synchronized scrolling between the two but I can't seem to get it to work.
The web view is basically taking the text from the text view and rendering it as marked up HTML via webview.load_html_string(). I think the problem could be the delay in loading the HTML as every time the web view is refreshed it is scrolled back to the very start.
Right now I call a function every time the content of the text view is changed and then modify the vadjustment.value of the scrolled window containing the web view.
But this doesn't work. Is it because of the delay? I can't think of any way to solve this issue.
|
Django: Put a Form into a Form (recursive ...)
| 25,321,619 | 0 | 2 | 564 | 0 |
python,django,forms,recursion,django-forms
|
In first glance, your idea seems to be complex. And the immediate question is - "Why do need such feature?". 99% - of tasks can be solved with built-in Django "bricks", another 1% - "Please hardcode". Also I may assume that the problem behind such an idea is complex too, and will be hard understandable by end user.
| 0 | 0 | 0 | 0 |
2014-07-13T11:16:00.000
| 4 | 0 | false | 24,722,087 | 0 | 0 | 1 | 2 |
I like Django forms library, but it would be even better if a form could contain forms.
My dream looks like this:
I have a form which behaves like normal form: for example a class called SuperForm
SuperForm can contain several normal forms, or even (recursive) SuperForms
You can bind it to data (to make it bound), call is_valid() ...
Is this possible with django or an external app?
Update
I see many people did not understand what I want. My fault, I did not give a use case.
Use case: A page should allow the user to update his email and his telephone number. The email is from django.contrib.auth and the phone number is from our custom model.
Both inputs should be in a single <form> tag. Since ModelForm is easy to use, I don't want to create a form myself by hand.
I want a container which contains the ModelForm of django.contrib.auth.models.User and the ModelForm of our custom model.
I don't want to loop over both forms (in other use cases there could be much more forms) myself, and check whether they are valid or not.
If I call is_valid() or save() on the container the matching method of the forms gets called.
|
Django: Put a Form into a Form (recursive ...)
| 25,411,066 | -1 | 2 | 564 | 0 |
python,django,forms,recursion,django-forms
|
I think you are thinking about forms in a different way than what you should.
Forms are simply there for input. How they are processed is up to you.
Sure you can run is_valid on the form, and that would check against the modelform that you have assigned. The awesome thing is you can check multiple model forms on the same form. The data that is needed for the model form will be processed the extra data would be ignored. If the is_valid fails you still pass the data back like you normally would to be corrected.
| 0 | 0 | 0 | 0 |
2014-07-13T11:16:00.000
| 4 | -0.049958 | false | 24,722,087 | 0 | 0 | 1 | 2 |
I like Django forms library, but it would be even better if a form could contain forms.
My dream looks like this:
I have a form which behaves like normal form: for example a class called SuperForm
SuperForm can contain several normal forms, or even (recursive) SuperForms
You can bind it to data (to make it bound), call is_valid() ...
Is this possible with django or an external app?
Update
I see many people did not understand what I want. My fault, I did not give a use case.
Use case: A page should allow the user to update his email and his telephone number. The email is from django.contrib.auth and the phone number is from our custom model.
Both inputs should be in a single <form> tag. Since ModelForm is easy to use, I don't want to create a form myself by hand.
I want a container which contains the ModelForm of django.contrib.auth.models.User and the ModelForm of our custom model.
I don't want to loop over both forms (in other use cases there could be much more forms) myself, and check whether they are valid or not.
If I call is_valid() or save() on the container the matching method of the forms gets called.
|
could not save preference file google-apps-engine
| 24,765,014 | 0 | 1 | 53 | 0 |
python,google-app-engine
|
I think I have found the answer to my own question.
I have a small app I have written to backup my stuff to Google Drive, this app would appear to have an error in it that does not stop it from running but does cause it to make a file called
C:\Usera\myname\Google
Therefore GAE can not create a directory called C:\Usera\myname/Google nor a file called C:\Usera\myname/Google\google_appengine_launcher.ini
I deleted the file Google, made a directory called Google and ran the GAE, saved pereferences and all working
| 0 | 1 | 0 | 0 |
2014-07-14T04:13:00.000
| 1 | 0 | false | 24,729,427 | 0 | 0 | 1 | 1 |
Just installed Google Apps Engine and am getting "could not save" errors.
Specifically if I go in to preferences I get
Could not save into preference file
C:\Usera\myname/Google\google_appengine_launcher.ini:No such file or directory.
So some how I have a weird path, would like to know where and how to change this. I have search but found nothing, I have done a repair reinstall of GAE
Can find nothing in the registry for google_appengine_launcher.ini
I first saw the error when I created my first Application
Called hellowd
Parent Directory: C:\Users\myname\workspace
Runtime 2.7 (PATH has this path)
Port 8080
Admin port 8080
click create
Error:
Could not save into project file
C:\Users\myname/Google\google_appengine_launcher.ini:No such file or directory.
Thanks
|
Django: Finish processing one request from a user before proceeding to the next
| 24,742,679 | 0 | 0 | 259 | 0 |
python,django,rabbitmq,celery
|
I don't know why I didn't think of this sooner, I added in a unique_together clause which will prevent another like_object from being created.
| 0 | 0 | 0 | 0 |
2014-07-14T16:54:00.000
| 2 | 0 | false | 24,741,712 | 0 | 0 | 1 | 1 |
I'm currently looking for a solution that will prevent a user from making multiple requests at the same time. I would like the first request to finish before the I process the second request from the user. For example, lets say user adam liked and un-liked suzy's photo. Both unliking and liking of the photo happens in the same view.
Currently the problem that I've been having is that I'm processing both requests at the same time. In the case of the like view, when a user likes something, I create a like_object. When the user decides to unlike something, I check for the existence of the like_object in the database and then delete it. HOWEVER! If the first request hasn't finished yet, the check for the like_object in the second request will come back saying there is no like object and it will create a second like_object.
Once all of this is finished processing, I will end up having 2 like_objects for the same photo from the same user. This is bad.
To give you more information, I use Gunicorn as my HTTP server. I run 3 regular workers, which is why each request is processed at the same time.
So what do you think I could do? I mean, I was thinking for using Celery and RabbitMQ for this. Each request will be submitted into a queue and be processed asynchronously. That's one option. But I feel like that might be overkill in a situation like this. I'm looking for something that can be done directly within Django. Hmm, let me know of the possible solutions.
Thanks
|
Do selenium tests in django applications increase coverage?
| 24,768,403 | 2 | 0 | 826 | 0 |
python,django,selenium,integration-testing,code-coverage
|
Well, they increase coverage if they execute code which is not executed by your other tests. However, that won't show up in your reports unless you figure out a way to capture which lines are executed during selenium testing, and add that into the data about coverage.
| 0 | 0 | 1 | 0 |
2014-07-15T19:41:00.000
| 2 | 0.197375 | false | 24,766,819 | 0 | 0 | 1 | 1 |
So, do they? That is the question. I'm not seeing any increase in my coverage reports with my integration tests done with selenium.
|
How would I implement a change approval process for a Django model?
| 24,767,411 | 0 | 0 | 2,143 | 0 |
python,django
|
I would create another table (tablename_approval) with columns something like
approved | boolean
approved_by | foreign key to user
timestamp | timestamp
to track the state of each individual row.
You might want to consider an enum rather than boolean to track the difference between items which have not yet been approved versus those that were checked and intentionally not approved.
| 0 | 0 | 0 | 0 |
2014-07-15T20:13:00.000
| 2 | 0 | false | 24,767,321 | 0 | 0 | 1 | 1 |
I have a model for which changes need to be approved by a user with a certain flag before they are seen by everybody. Making two different identical models is not an option, because the model has a many-to-many field referencing itself, which needs to be linked to both approved and non-approved entries.
I'm using Django 1.7. django-moderation looks like the best option, but it doesn't support manytomany relations. I've also tried django-gatekeeper which didn't work for me either.
Is there a library which supports many-to-many relationships?
If not, how would I go about doing this myself?
|
Uploading code to server and run automatically
| 24,769,619 | 1 | 1 | 262 | 0 |
python,cloud
|
Here are two approaches to this problem, both of which require shell access to the cloud server.
Write the program to handle the scheduling itself. For example, sleep and wake up every few miliseconds to perform the necessary checks. You would then transfer this file to the server using a tool like scp, login, and start it in the background using something like python myscript.py &.
Write the program to do a single run only, and use the scheduling tool cron to start it up every minute of the day.
| 0 | 0 | 0 | 1 |
2014-07-15T23:02:00.000
| 2 | 0.099668 | false | 24,769,574 | 0 | 0 | 1 | 2 |
I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically.
I'm working on a project that would require some code to be running 24/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time each user wants to receive a daily newsletter (for some subjective reason) - the code would at the right time of day send the newsletter to the correct person. But of course, all of this is running out on a Cloud server.
Any help would be appreciated - even correcting my entire formulation of the problem! If you know how to do this in any other language - please reply with your solutions!
Thanks!
|
Uploading code to server and run automatically
| 24,983,741 | 1 | 1 | 262 | 0 |
python,cloud
|
Took a few days but I finally got a way to work this out. The most practical way to get this working is to use a VPS that runs the script. The confusing part of my code was that each user would activate the script at a different time for themselves. To do this, say at midnight, the VPS runs the python script (using scheduled tasking or something similar) and runs the script. the script would then pull times from a database and process the code at those times outlined.
Thanks for your time anyways!
| 0 | 0 | 0 | 1 |
2014-07-15T23:02:00.000
| 2 | 0.099668 | false | 24,769,574 | 0 | 0 | 1 | 2 |
I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically.
I'm working on a project that would require some code to be running 24/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time each user wants to receive a daily newsletter (for some subjective reason) - the code would at the right time of day send the newsletter to the correct person. But of course, all of this is running out on a Cloud server.
Any help would be appreciated - even correcting my entire formulation of the problem! If you know how to do this in any other language - please reply with your solutions!
Thanks!
|
AWS ElasticBeanstalk "no files found to execute"
| 24,920,993 | 0 | 0 | 74 | 0 |
python,amazon-web-services,flask,amazon-elastic-beanstalk
|
An internal 500 error can be caused by many reasons. The "No files found to execute" issue seems interesting...Could you link to your log file? Or, more specifically, just show the /var/log/httpd/error_log section of your log file. This is usually very helpful to diagnosing things that go wrong after a successful deployment. Sorry I can't give a definitive answer yet - 500 is very generic!
| 0 | 0 | 0 | 0 |
2014-07-16T03:29:00.000
| 1 | 0 | false | 24,771,722 | 0 | 0 | 1 | 1 |
I am still new to this, so please pardon the inexperience.
I am currently developing a website with a coder using python and flask, and it needs to be placed into elastic beanstalk.
The website was developed offline, and we are trying to upload it to EB.
We have followed the instructions on the AWS support, and have been able to get the "Hello World!" sample site working. However, upon reading the logs, it shows that, at the bottom, "No files found to execute"
When we upload our website, it shows the same error in the logs, but instead of showing the website, it would show Internal 500 error.
Any advice is appreciated!
|
django registration page with country , state field after submission
| 24,777,165 | 0 | 1 | 178 | 0 |
python,django,forms
|
I have tried your case in admin of Django. There is a request object in Django which I suppose you know what it is. You can get user selection by request.user.user_permissions.select_related(). Hope it will help you.
| 0 | 0 | 0 | 0 |
2014-07-16T07:18:00.000
| 2 | 0 | false | 24,774,512 | 0 | 0 | 1 | 1 |
I have created a django form using django-registration package.
In that I have two selection fields , first is country, second is state depending on the country. If I get any errors, when I submit the form it returns form with user filled data.
But I am facing problems with selection field of country and state.
Please give me idea to solve this
|
How to run a python function on every Admin page load in Django
| 24,782,492 | 0 | 2 | 1,889 | 0 |
python,django,python-3.x,django-admin
|
I would deal it with a simple way. Find a function the admin must execute such as save_model(). Then put your own function in it.
| 0 | 0 | 0 | 0 |
2014-07-16T13:40:00.000
| 3 | 0 | false | 24,782,368 | 0 | 0 | 1 | 1 |
I would like a python function to be run any time a page from the admin interface is loaded. This does not need to run on every page load(ie non-admin related pages). This function requires the request object or the user id.
I know I could create a new view and call it from javascript from the page, but this seems like a horrible way of doing it. Is there a way to somehow attach a function to admin page loads server side without adding any additional dependencies?
Update: the function is used to hook into a kind of logging system that keeps track of first/last interaction of each user each day that needs to be updated whenever the user uses the admin interface. It would seem that a middleware app would allow me to do what I want to do, thank you guys!
|
How do I find where a django template variable comes from in the python
| 24,796,873 | 1 | 0 | 668 | 0 |
python,django,django-templates,django-views
|
Look at the URL of the page. Then go to urls.py and look at which view is linked to the URL. Then open views.py and search for the view which the URL linked to.
In that view, the variable 'x' should be there. If it's not, then check the template context processors and middlewares as karthikr suggested.
| 0 | 0 | 0 | 0 |
2014-07-16T17:44:00.000
| 1 | 1.2 | true | 24,787,347 | 0 | 0 | 1 | 1 |
Is there a good general way of finding the line of python code responsible for passing in variables to django templates? When newly picking up a large code base, and I see {{ x.y }} in the template, and nothing obviously related (by how things are named) to x in the {% load ... %}, what do I do? Where can I find this variable in the python so that I can change it or related code?
My current solutions tend to be tedious and overwhelming. It's a lot of searching, but I would like to be able to just know where to look.
|
Google App Engine send batch email
| 24,814,266 | 1 | 0 | 88 | 0 |
python,google-app-engine,email
|
You can set up a CRON job to run every few minutes and process your email queue. It will require an endpoint where you can send a POST request, but you can use a secret token (like just any random guid) to verify the request is legitimate before you send the email.
| 0 | 1 | 0 | 0 |
2014-07-17T14:45:00.000
| 1 | 1.2 | true | 24,806,675 | 0 | 0 | 1 | 1 |
I was wondering how I would go about emailing user emails stored in a python datastore.
Should I create a sort of maintenance page where I can log in as an administrator and then send an email or is there a way for me to execute a python script without needing a handler pointing to a separate webpage so I don't have to worry about the page being discovered and exploited.
|
Streaming audio from webserver
| 24,811,718 | 0 | 0 | 452 | 0 |
python,ios,audio,streaming
|
What happens when the playback is restarted? Print the HTTP URLs on the server. Does the player start from index=0, go to index=4000, then back to index=0 again?
| 0 | 1 | 0 | 0 |
2014-07-17T18:27:00.000
| 1 | 0 | false | 24,810,929 | 0 | 0 | 1 | 1 |
I'm creating a simple app that can play audio files (currently only mp3 files) located on a webserver.
Currently, I'm using Python's SimpleHTTPServer server side, and the AVAudioPlayer for iOS.
It sort of works, since the file is streamed over HTTP instead of just being downloaded from the webserver. But I often experience that the playback of a file is suddenly restarted.
I'm considering using another method of streaming, eg. RTMP, but on the other hand I want to keep things simple. I'm wondering if another HTTP server might do the trick? Any other experiences/suggestions?
|
beautifulsoup in python3.4 cannot use in pycharm
| 24,818,385 | 1 | 2 | 2,453 | 0 |
python,python-3.x,ubuntu
|
pip install beautifulsoup4 does not work?
Did you try to create a new virtualenv in pycharm and simple add library?
| 0 | 0 | 0 | 0 |
2014-07-18T06:07:00.000
| 2 | 0.099668 | false | 24,818,249 | 1 | 0 | 1 | 2 |
I am using ubuntu14.0LTS and pycharm IDE how to download and install beautifulsoup and add beautifulsoup library into pycharm.
I tried using pip install it's not working.
|
beautifulsoup in python3.4 cannot use in pycharm
| 29,523,112 | -1 | 2 | 2,453 | 0 |
python,python-3.x,ubuntu
|
THis is how I found it,
First I click on file in the top menu.
then I click on settings, now look for project interpreter this where you can add beautifulsoup by clicking on the green cross on the right site of the screen.
After installing it. Call it by using : from bs4 import beautifulsoup
| 0 | 0 | 0 | 0 |
2014-07-18T06:07:00.000
| 2 | -0.099668 | false | 24,818,249 | 1 | 0 | 1 | 2 |
I am using ubuntu14.0LTS and pycharm IDE how to download and install beautifulsoup and add beautifulsoup library into pycharm.
I tried using pip install it's not working.
|
What's the appropriate way to use Flask with zeromq in production?
| 24,890,173 | 2 | 6 | 3,408 | 0 |
python,flask,zeromq
|
Is the ZMQ socket in your app connect()-ing, or is it bind()-ing? If your app is considered the client and it's connecting, then multiple instances should be able to connect without issue. If it's considered the server and it's binding, then yes, you'll have problems... but in your case, it seems like you should consider your Flask app to be more transient, and thus the client, and the other end to be more reliable, and thus the server.
But it's hard to really give any concrete advice without code, there's only so much I can intuit from the little information you've given.
| 0 | 0 | 0 | 0 |
2014-07-18T21:08:00.000
| 3 | 0.132549 | false | 24,833,833 | 0 | 0 | 1 | 2 |
I have a Flask app that accepts HTTP requests. When certain HTTP requests come in, I want to trigger a message on a zeromq stream. I'd like to keep the zeromq stream open all the time. I'm wondering what the appropriate way to do this is. Since it is recommended to use gunicorn with Flask in production, doesn't that mean that there will be multiple instances of the Flask app, and if I put the zeromq connection in the same place as the Flask app, only one of those will be able to connect, and the others will fail.
|
What's the appropriate way to use Flask with zeromq in production?
| 24,834,017 | 0 | 6 | 3,408 | 0 |
python,flask,zeromq
|
ZeroMQ shall not reuse context across different threads. The same applies to sockets.
If you manage to keep the socket used exclusively by one thread in worker, you might reuse the
socket.
Anyway, I would start with creating new context and socket with every request and see, if there is
any need to go into complexities of sharing a ZeroMQ connection. Set up ZeroMQ is often rather fast.
| 0 | 0 | 0 | 0 |
2014-07-18T21:08:00.000
| 3 | 0 | false | 24,833,833 | 0 | 0 | 1 | 2 |
I have a Flask app that accepts HTTP requests. When certain HTTP requests come in, I want to trigger a message on a zeromq stream. I'd like to keep the zeromq stream open all the time. I'm wondering what the appropriate way to do this is. Since it is recommended to use gunicorn with Flask in production, doesn't that mean that there will be multiple instances of the Flask app, and if I put the zeromq connection in the same place as the Flask app, only one of those will be able to connect, and the others will fail.
|
How can I force splinter to use a default browser?
| 30,110,730 | 0 | 0 | 128 | 0 |
android,python,iframe,selenium,splinter
|
You can provide it as the argument when you instantiate the splinter browser object.
| 0 | 0 | 1 | 0 |
2014-07-20T00:45:00.000
| 1 | 0 | false | 24,846,309 | 0 | 0 | 1 | 1 |
I've searched thoroughly and still can't find the answer to this question. I finally figured out how to prefill a form in an iframe using splinter, but it only works in firefox on my computer, while not working in another browser, let alone a mobile device. I've tried importing webdriver from selenium, etc. Still, nothing.
So far, the webbrowser works both on the pc and my android device to easily pull up a website; unfortunately, I can't get it to prefill forms in iframes.
Can anybody help???
Thank you!!!
|
How to return HTTPMovedPermanently (301 status) instead HTTPFound (302) in pyramid notfound_view_config
| 24,882,407 | 1 | 2 | 390 | 0 |
python,pyramid,http-status
|
My solution with deprecated class:
class append_slash_notfound_factory(AppendSlashNotFoundViewFactory):
def __call__(self, context, request):
result = super(append_slash_notfound_factory, self).__call__(context, request)
if isinstance(result, HTTPFound):
return HTTPMovedPermanently(result.location)
return result
| 0 | 0 | 0 | 0 |
2014-07-21T12:47:00.000
| 2 | 0.099668 | false | 24,865,495 | 0 | 0 | 1 | 1 |
Using notfound_view_config in pyramid with parameter append_slash=True, i get 302 http status when redirecting, but i want set custom http status - 301.
@notfound_view_config(append_slash=True, renderer="not_found.mako")
def notfound(request):
return {}
|
Python SimpleHttpServer howto
| 42,041,564 | 1 | 0 | 2,367 | 0 |
javascript,jquery,python,html,simplehttpserver
|
I hope starting python server in the correct folder path of index.html file should solve the issue.
P.S I have faced the same issue and realised that I have started the python server in the parent folder of index.html file which didn't have the script.js file
| 0 | 0 | 0 | 0 |
2014-07-21T17:56:00.000
| 1 | 0.197375 | false | 24,871,598 | 0 | 0 | 1 | 1 |
I have: I created index.html - the simplest html page & launch my simple http server with python -m SimpleHttpServer 8000.
I want: make index.html use javascript which depends on JQuery.
Problem: Seems SimpleHttpServer doesn't load JS files. I mean if I write <script src="myScript.js"/> inside index.html - myScript.js won't be loaded by browser.
Question: Why browser doesn't download JS files?
P.S. I use OSX Mavericks 10.9.4
|
Python Flask webserver stop responding
| 42,686,598 | 0 | 12 | 9,757 | 0 |
python,flask
|
In my case, I need to change worker_class from 'sync' to 'gevent', since I do some asynchronous tasks. Then no more hangs.
| 0 | 0 | 0 | 0 |
2014-07-22T10:28:00.000
| 3 | 0 | false | 24,884,901 | 0 | 0 | 1 | 2 |
I am running a flask web server, it works fine during testing, but now freezes at least once per day. All I need to do is to restart it and it will work again. Is there a good way to monitor it and maybe I should just kill/restart it every time it fails. Do people actually kill their web server periodically to avoid this kind thing from happening?
|
Python Flask webserver stop responding
| 26,342,720 | 3 | 12 | 9,757 | 0 |
python,flask
|
While the default web server might not be the best for production, it is probably not the root cause of the crashes. I use it in a production environment on an internal network and it is very stable. Before blaming the web server check to make sure your code can handle requests that that may collide with each other. In my case I had lots of stability issues before I instituted locking on data base tables so that certain requests would be blocked until previous requests were done with updates. Flask can't make sure your code is thread safe. And changing the web server won't help if it is not.
| 0 | 0 | 0 | 0 |
2014-07-22T10:28:00.000
| 3 | 0.197375 | false | 24,884,901 | 0 | 0 | 1 | 2 |
I am running a flask web server, it works fine during testing, but now freezes at least once per day. All I need to do is to restart it and it will work again. Is there a good way to monitor it and maybe I should just kill/restart it every time it fails. Do people actually kill their web server periodically to avoid this kind thing from happening?
|
make a Client-Server application
| 24,893,137 | 1 | 0 | 136 | 0 |
python,url,client-server,client,webclient
|
The "action" part of a form is an url, and If you don't specify the scheme://host:port part of the URL, the client will resolve it has the current page one. IOW: just put the path part of your script's URL and you'll be fine. FWIW hardcoding the scheme://host:port of your URLs is an antipattern, as you just found out.
| 0 | 0 | 1 | 0 |
2014-07-22T14:54:00.000
| 2 | 0.099668 | false | 24,890,739 | 0 | 0 | 1 | 2 |
I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?
I mean, for example I have an html form and a button "ok" :
If the server and the client are in the same computer, in action = " " we put localhost/file.py , but if the server and the client are not in the same computer how to do this ? Because the client can't to have localhost in his webbrower (url).
|
make a Client-Server application
| 24,907,187 | 0 | 0 | 136 | 0 |
python,url,client-server,client,webclient
|
Your script is supposed to be run as a CGI script by a web-server, which sets environment variables like REMOTE_ADDR, REQUEST_METHOD ...
You are running the script by yourself, and this environment variable are not available.
That's why you get the KeyError.
| 0 | 0 | 1 | 0 |
2014-07-22T14:54:00.000
| 2 | 1.2 | true | 24,890,739 | 0 | 0 | 1 | 2 |
I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?
I mean, for example I have an html form and a button "ok" :
If the server and the client are in the same computer, in action = " " we put localhost/file.py , but if the server and the client are not in the same computer how to do this ? Because the client can't to have localhost in his webbrower (url).
|
django models and OOP design
| 24,898,191 | 0 | 0 | 1,085 | 0 |
python,django,oop,django-models
|
You should put the methods of the Quest class on the model itself and get rid of the Quest class.
| 0 | 0 | 0 | 0 |
2014-07-22T21:25:00.000
| 1 | 1.2 | true | 24,898,132 | 0 | 0 | 1 | 1 |
I wrote a quest system for an online game. My quests are serialized into json objects for a JavaScript client that fetches those quests then from a REST backend (I use django RestFramework)
Now I'm wondering on which class or django model I should put the "behaviour" that belongs to the data.
I stored the data that belongs to a quest in several separate models:
A model QuestHistory: with models.Fields like Boolean completed, and Datetime started where I put the information belonging to a specific user (it also as a field user).
Then I have a model QuestTemplate : The part that is always the same, fields like quest_title and quest_description
I also have a model Rewards and model Task and TaskHistory that are linked to a quest with a foreign Key field.
To combine this information back to quest I created a pure python class Quest(object): and defined methods on this class like check_quest_completion. This class is the then later serialized. The Problem with this approach is that It becomes quite verbose, for example when I instantiate this class or when I define the Serializer.
Is there a python or django "shortcut" to put all fields of a django model into another class (my Quest class here), something similar to the dict.update method maybe?
Or should I try to put the methods on the models instead and get rid of the Quest class?
I have some other places in my game that look very similar to the quest system for example the inventory system so I'm hoping for a more elegant solution.
|
How to use the Django ORM for creating an interface like MySQL admin that connects to multiple databases
| 24,917,828 | 0 | 0 | 110 | 1 |
django,mysql-python,django-orm,cx-oracle
|
Django uses connection pooling (i.e. few requests share the same DB connection). Of course, you can write a middleware to close and reinitialize connection on every request, but I can't guarantee you will not create race conditions, and, as you said, there is no point to do so.
If you want to make automatic multi-database CRUD, you'd better use some other framework (maybe, Flask or Bottle), because Django is optimized in much aspects for content sites with pre-set data scheme.
Also, it's not quite simple application, and maybe it's not a good way to learn some new technology at all. Try starting with something simpler, maybe.
| 0 | 0 | 0 | 0 |
2014-07-23T13:38:00.000
| 1 | 1.2 | true | 24,912,020 | 0 | 0 | 1 | 1 |
So I'm fairly new to Django development and I started using the cx_Oracle and MySQLdb libraries to connect to Oracle and MySQL databases. The idea is to build an interface that will connect to multiple databases and support CRUD ops. The user logs in with the db credentials for the respective databases. I tried not using the Django ORM (I know you may ask then what is the point)but then it is still all a learning endeavor for me. Without the Django ORM (or any ORM for that matter),I was having trouble persisting db connections across multiple requests(Tried using sessions).I need some direction as to what is the best way to design this.
|
Best way to find the location of a config file based from launching directory?
| 24,915,117 | 3 | 0 | 241 | 0 |
python,configuration
|
If you want to get the path to file that has your code relative to from where it was launched, then it is stored in the __file__ of the module, which can be used if you:
dont want your module(s) to be installed with a setup.py/distutils
scheme.
and want your code + configs contained in one location.
So a codeDir = os.path.dirname(os.path.abspath(__file__)) should always work.
If you want to make an installer, I would say it is customary to place the code in one place and things like configs somewhere else. And that would depend on your OS. On linux, one common place is in /home/user/.local/share/yourmodule or just directly under /home/user/.yourmodule. Windows have similar place for app-data.
For both, os.environ['HOME'] / os.getenv('HOME') is a good starting point, and then you should probably detect the OS and place your stuff in the expected location with a nice foldername.
I can't swear that these are best practices, but they seem rather hack-free at least.
| 0 | 0 | 0 | 1 |
2014-07-23T15:20:00.000
| 1 | 1.2 | true | 24,914,489 | 1 | 0 | 1 | 1 |
I'm developing a module right now that requires a configuration file.
The configuration file is optional and can be supplied when the module is launched, or (ideally) loaded from a defaults.json file located in the same directory as the application. The defaults.json file's purpose is also used to fill in missing keys with setdefault.
The problem comes from where the module is launched...
...\Application = python -m application.web.ApplicationServer
...\Application\application = python -m web.ApplicationServer
...\Application\application\web = python ApplicationServer.py
....read as, "If if I'm in the folder, I type this to launch the server."
How can I determine where the program was launched from (possibly using os.getcwd()) to determine what file path to pass to json.load(open(<path>), 'r+b')) such that it will always succeed?
Thanks.
Note: I strongly prefer to get a best practices answer, as I can "hack" a solution together already -- I just don't think my way is the best way. Thanks!
|
Best practice to upgrade a Plone 3 theming product to Plone 4
| 25,017,085 | 0 | 0 | 44 | 0 |
python,themes,plone,product,theming
|
If you want the traditional editing interface, old-style theme packages are helpful. If you have HTML resources ready from the designer, and want them quickly deployed, Diazo seems a fit. Anyway, Sunburst is the Plone 4 default theme package, you should check it out thoroughly and take advantage from the stock Plone packages whenever appropriate to minimize your efforts.
Aside the theming, my experience on Plone 3 to 4 migration, it takes more time moving Archetypes to Dexterity, especially if your add-ons are based on Archetypes. Of course, your mileage may vary.
| 0 | 0 | 0 | 0 |
2014-07-23T17:49:00.000
| 1 | 0 | false | 24,917,458 | 0 | 0 | 1 | 1 |
I have several sites in Plone 3.3.5 with its own theming product for each site, designed by an outside contractor long ago. Would it be best that I try to upgrade these theming products to Plone 4 compatible or should I use the new Diazo tool built into Plone 4 to create these different themes for each site?
Thanks in advance for your help.
|
Having error queues in celery
| 24,946,459 | 0 | 4 | 1,656 | 0 |
python,celery,reliability
|
I had a similar problem and i solved it may be not in a most efficient way but however my solution is as follows:
I have created a django model to keep all my celery task-ids and that is capable of checking the task state.
Then i have created another celery task that is running in an infinite cycle and checks all tasks that are 'RUNNING' on their actual state and if the state is 'FAILED' it just reruns it. Im not actually changing the queue for the task which i rerun but i think you can implement some custom logic to decide where to put every task you rerun this way.
| 0 | 1 | 0 | 0 |
2014-07-24T14:35:00.000
| 2 | 0 | false | 24,936,671 | 0 | 0 | 1 | 1 |
Is there any way in celery by which if a task execution fails I can automatically put it into another queue.
For example it the task is running in a queue x, on exception enqueue it to another queue named error_x
Edit:
Currently I am using celery==3.0.13 along with django 1.4, Rabbitmq as broker.
Some times the task fails. Is there a way in celery to add messages to an error queue and process it later.
The problem when celery task fails is that I don't have access to the message queue name. So I can't use self.retry retry to put it to a different error queue.
|
Reasons why Django was slow
| 24,937,984 | 3 | 2 | 431 | 0 |
python,database,django,performance
|
It all depends on the query that you're running. If you're running a SELECT COUNT(*) FROM foo on a table that has ten rows, it's going to be very fast; but if your query involves a dozen joins, sub-selects, filters on un-indexed rows--or if the target table simply has a lot of rows--the query can take an arbitrary amount of time. In all likelihood, the bottleneck is not Django (although its ORM has some quirks), but rather the database and your query. Just because no rows meet the criteria doesn't mean that the database didn't need to deal with the other rows in the table.
| 0 | 0 | 0 | 0 |
2014-07-24T15:25:00.000
| 1 | 1.2 | true | 24,937,897 | 0 | 0 | 1 | 1 |
This is simply a question of curiosity. I have a script that loads a specific queryset without evaluating it, and then I print the count(). I understand that count has to go through so depending on the size it could potentially take some time, but it took over a minute to return 0 as the count of an empty queryset Why is that taking so long? is it Django or my server?
notes:
the queryset was all one type.
|
How can a Spotfire data table be sent to a web service as csv and then replace the data table with the service response?
| 28,900,283 | 1 | 1 | 1,721 | 0 |
web-services,ironpython,spotfire
|
I have addressed the similar problem but I was using different approach than the proposed IronPython script behind a button.
In my case I created a standalone C#/ASP.NET web application and I have embedded the Spotfire Web Player into the application.
I used the Spotfire JavaScript API to pick up the data marked by user within the Spotfire Web embedded part and then send it via JavaScript call to webservice on the application. The webservice did some processing and sent the data to other destination.
So my scenario was a bitt different but for yours you would also consider using the approach to embedd Spotfire Web into some app that you have full control over rather than using the IronPython script.
| 0 | 0 | 0 | 0 |
2014-07-24T18:04:00.000
| 2 | 0.099668 | false | 24,940,938 | 0 | 0 | 1 | 1 |
I need to send my Spotfire data table to a web service as csv and then replace the data table with the service response. I assume that this can be done with IronPython behind a button. Any ideas how?
|
Check box in Django admin run a Python function on save without a BooleanField
| 24,944,279 | 0 | 0 | 300 | 0 |
python,django,django-models,django-forms,django-admin
|
You can add any arbitrary fields to a form: they need to be form fields (eg forms.BooleanField) but as long as they don't also exist on the model they won't be saved.
You can then take any action you like in the form's clean() method, or in the modeladmin's save_form method.
| 0 | 0 | 0 | 0 |
2014-07-24T21:03:00.000
| 1 | 0 | false | 24,943,916 | 0 | 0 | 1 | 1 |
Is there a way to have a check box appear in Django admin, but instead of associating it with a BooleanField, having it run a function if it is / is not checked upon save? I don't need to store a Boolean in the database, but may need to store something depending on other fields, and whether the check box was checked.
In particular, I would like to store a ForeignKey if the check box was just checked, empty it (set ForeignKey to null) if the check box was just unchecked, and do nothing it the check box state stayed the same. I don't want to display what this ForeignKey is to the user, just set it or delete it behind the scenes.
|
Django - Load template with jQuery into variable
| 24,945,629 | 1 | 1 | 145 | 0 |
javascript,jquery,python,django
|
If I understand correctly, you are trying to hide jquery code.
You can't hide jquery code from the user, because django processes python code before it serves up the template, there's no way to protect jquery code with python. Really the best thing you can do is to minimize and obfuscate the code, but that only makes it difficult for human reading.
| 0 | 0 | 0 | 0 |
2014-07-24T21:18:00.000
| 1 | 1.2 | true | 24,944,148 | 0 | 0 | 1 | 1 |
I'm working with a client that has a view that, after a user logs in, this view loads a template, that dynamically draws a canvas with jQuery, and generates an image copy of the canvas.
They want to protect the jQuery code, hiding the process in the python code.
I tried using PyExecJS, but it doesn't support jQuery, since there is no DOM.
I've also tried urllib2, mechanize and Selenium, but none worked.
Is there an alternative or have I missed something?
Update/Resolution: In case someone stumbles onto this question: I ended up using Selenium for Python to load the JS function, fed it the necessary data and extracted the image from it. It has a bit of an overhead, but since the main goal was to keep the JS code obfuscated, it worked.
|
Django Database Module
| 24,997,975 | 1 | 0 | 56 | 1 |
database,django,mysql-python,django-database
|
For working inside virtualenv you need to install
pip install MySQL-python==1.2.5
| 0 | 0 | 0 | 0 |
2014-07-24T22:10:00.000
| 2 | 0.099668 | false | 24,944,869 | 0 | 0 | 1 | 2 |
I am developing a system that will need to connect from a remote mysql database on the fly to do a specific task. To accomplish this, I am thinking to use Mysql-db module in python. Since the remote database is not part of the system itself I do not prefer to add it on the system core database settings (DATABASES settings.py). Is there a much better way to accomplish this aside from using Mysql-db module? Is there a built in django module that I can use?
|
Django Database Module
| 24,997,774 | 0 | 0 | 56 | 1 |
database,django,mysql-python,django-database
|
MySQLdb is the best way to do this.
| 0 | 0 | 0 | 0 |
2014-07-24T22:10:00.000
| 2 | 1.2 | true | 24,944,869 | 0 | 0 | 1 | 2 |
I am developing a system that will need to connect from a remote mysql database on the fly to do a specific task. To accomplish this, I am thinking to use Mysql-db module in python. Since the remote database is not part of the system itself I do not prefer to add it on the system core database settings (DATABASES settings.py). Is there a much better way to accomplish this aside from using Mysql-db module? Is there a built in django module that I can use?
|
How do I remove/add the python interpreter from eclipse?
| 24,973,729 | 0 | 1 | 1,345 | 0 |
python,django,eclipse,interpreter
|
On the menubar go to Window -> Preferences -> Pydev -> Interpreters -> Python
Remove the interpreter and click on Quick Auto Config.
That should do the trick. Make sure django is installed first.
| 0 | 0 | 0 | 0 |
2014-07-26T17:19:00.000
| 1 | 0 | false | 24,973,568 | 1 | 0 | 1 | 1 |
I'm an eclipse noob.
After adding PyDev to eclipse, I try to create a "PyDev Django Project", but and I get the "Django not found" error.
I heard that you have to remove the python interpreter from eclipse, then add it again. But I don't know how to do that.
Can someone show me how to remove/add the python interpreter in eclipse?
It is greatly appreciated.
Brent.
|
Sign in with Twitter: how to verify the current user is stil logged in
| 25,003,619 | 0 | 0 | 36 | 0 |
python,google-app-engine,twitter,webapp2
|
Are you talking about being logged in to Twitter.com or your app? If you have received oAuth access tokens by authenticating an app, then logging out of twitter.com won't 'log you out' of any apps, the tokens will remain valid until the user revokes the access.
| 0 | 0 | 0 | 1 |
2014-07-27T10:39:00.000
| 1 | 0 | false | 24,980,103 | 0 | 0 | 1 | 1 |
I have managed to use oauth authentication and add a Sign in with Twitter functionality to a Google App Engine web app.
How should I verify, during the site navigation, if the user is still logged in Twitter?
|
get input file name and file extention using flask
| 24,982,070 | 20 | 6 | 6,570 | 0 |
python,flask,filenames
|
Found the answer. request.files['upload'].filename gives the file name and extension in flask
| 0 | 0 | 0 | 0 |
2014-07-27T12:56:00.000
| 2 | 1.2 | true | 24,981,184 | 0 | 0 | 1 | 1 |
lets say that I have <input name="upload" type="file"> and I am uploading picture.jpg. The question is how can I get the file name+extention? By other words the correct script for request.files.filename or request.upload.filename
|
Calling Django server api from android phone
| 24,988,398 | 0 | 0 | 3,171 | 0 |
android,python,django,api
|
If I understand your question correctly, you have a Django installation on your laptop and you are able to hit a specific page/service locally using "localhost:8000/polls/link/2/" and it works fine. Now you want to access it from your mobile. Correct?
Replace the "localhost" with IP address of your laptop. For example, "10.0.0.1:8000/polls/link/2/"
You will find your IP address in System Preferences -> Network
| 0 | 0 | 0 | 0 |
2014-07-28T01:49:00.000
| 6 | 0 | false | 24,987,488 | 0 | 0 | 1 | 2 |
I am developing an android app. For local testing I have created a django server on my laptop. My problem is I am not able to call django apis from app code. For example, if I want to call any django server api from desktop I write "localhost:8000/polls/link/2/". Now how to replace this "localhost part of url" if calling same api from mobile. And also my desktop is connected to internet by the same mobile hotspot. So basically both desktop and phone are on same network.
My ifconfig command on desktop shows
And my desktop is Mac and mobile is Samsung core duo
|
Calling Django server api from android phone
| 47,381,501 | 0 | 0 | 3,171 | 0 |
android,python,django,api
|
Firstly run the django server by typing python manage.py runserver 0.0.0.0:8000. Then check the ip of your private network i.e wlan ip using ifconfig command then simply replace your localhost text with that ip while calling API.
But above all make sure that your phone and lappy should be in same network.
| 0 | 0 | 0 | 0 |
2014-07-28T01:49:00.000
| 6 | 0 | false | 24,987,488 | 0 | 0 | 1 | 2 |
I am developing an android app. For local testing I have created a django server on my laptop. My problem is I am not able to call django apis from app code. For example, if I want to call any django server api from desktop I write "localhost:8000/polls/link/2/". Now how to replace this "localhost part of url" if calling same api from mobile. And also my desktop is connected to internet by the same mobile hotspot. So basically both desktop and phone are on same network.
My ifconfig command on desktop shows
And my desktop is Mac and mobile is Samsung core duo
|
Call python FUNCTION from javascript
| 24,993,506 | 2 | 0 | 4,050 | 0 |
javascript,python,angularjs,client-server
|
It doesn't have much to do with Python, really. Your javascript code is executed on the client's brower, and all it can do is issuing HTTP requests (synchronous or asynchronous). At this point which webserver / technology / language is used to handle the HTTP request is totally irrelevant. So, from the client javascript code POV, you are not "calling a Python function", you are sending an HTTP request and handling the HTTP response.
If your web host doesn't let you run django (or any wsgi-compliant script) then you'll probably have to either use plain CGI (warning: very primitive techno) or migrate to PHP (no comment). Or find another hosting that doesn't live in the past ;)
| 0 | 0 | 0 | 0 |
2014-07-28T10:16:00.000
| 2 | 1.2 | true | 24,993,048 | 0 | 0 | 1 | 1 |
this question have been asked numerous times, I know and I'm sorry if by ignorance I didn't get the answers.
I have a hosting plan which doesn't allow me to install django, which was really nice to call an rest api easily with the routing settings.
What I want is to be able to call a python function from javascript code doing a get/post (I'm using AngularJs, but it would be the same making an ajax get/post.)
Let's say I have a js controller 'Employee' and a view 'CreateEmployee'.
From my javascript view, I can call my CreateEmployee() on the js controller, now my question is, how can I call a specific function (let's say) def CreateEmployee(params...) on my .py file?
All I found is making a get/post on my .py file, but didn't find how to invoke a specific function.
I probably don't get the python and client/server communication paradigm, I've been coding on asp.net WebForms for a long time, and since I can't use frameworks like Django I'm stuck.
Thanks
|
Couchbase: Add View to existing Design Document
| 24,997,007 | 0 | 1 | 563 | 0 |
java,python,command-line,couchbase,couchbase-view
|
So it appears after watching how their Web UI console works, that they're essentially reusing the "create a design document," i.e. the PUT command, to overwrite the existing design document. I have no idea how this would work on a production machine while it is running or the implications of such actions. The documentation, for a commercial product, in this regards is lacking.
| 0 | 0 | 0 | 0 |
2014-07-28T13:23:00.000
| 2 | 1.2 | true | 24,996,265 | 0 | 0 | 1 | 1 |
I can query the views of a design document. I can create a brand new design document. I can delete a design document. I can add a view to a design document I'm in the process of creating but...
How do you add a view to an already existing design document without going through their web UI? Is it even possible or do you always have to create a brand new design doc just to modify it.
For reference, I've looked at the "couchbase-cli" tool, the Python SDK, the Java SDK and even the REST API itself. Nowhere have I found a means of adding a view to a design document and persist that view in Couchbase without having to create a design document. Did I miss something from the documentation?
|
Django cutting off uploaded file
| 25,031,586 | 0 | 3 | 86 | 0 |
python,ajax,django
|
Turns out it was a "feature" of the client-side AJAX package we were using (flow.js) and we just had to increase chunkSize.
| 0 | 0 | 0 | 0 |
2014-07-28T19:45:00.000
| 1 | 1.2 | true | 25,003,108 | 0 | 0 | 1 | 1 |
I'm making a Django app in which a user can upload a file (an image) using AJAX.
While developing locally, I saw that PIL, which I used to process the image after upload, had a bug. After investigating I found out it's because PIL is getting the file data cut off. It's only getting the first 1MB of the file, which is why it's failing. (The file is around 3MB.)
Why could this be, and how can I solve it? My immediate suspicion is that runserver, which I use locally, caps AJAX uploads for some reason. But I can't be sure. And if it does, I don't know how to make it stop.
Can anyone help?
|
handling different required package versions
| 25,006,589 | -1 | 1 | 49 | 0 |
python
|
You have a couple of options these are the only ones I can think of:
fork (sorry but this may be the easiest/ quickest),
wait for a new version for the older package, or
change it to not use zipped eggs (I don't really understand this though).
[EDIT] could you potentially trick one into thinking that it is using its version. I don't know the specifics, but from my understanding you could use a virtual machine.
There could be others that I don't know (it actually probable) but that is all I could think of hopefully you find a solution though!
| 0 | 0 | 0 | 0 |
2014-07-29T00:37:00.000
| 1 | -0.197375 | false | 25,006,539 | 0 | 0 | 1 | 1 |
I (thankfully) never ran into this before, and (sadly) just did.
My app now imports 2 packages, which each import the requests library. The two authors have pegged the version of requests to different versions. One wants 2.1.0 , the other wants 2.3.0.
Automated tests appear to pass on both. My app appears to function perfectly on both.
My app won't start, however, because of the requirements. From what I can understand on my development environment, it's because of the version number being pegged in a requirements.txt file. [ In dev we have PasteDeploy + Waitress, an exception is raised in PasteDeploy; in production we have uwsgi ]
The only ways I can think of handling this, is to:
fork the projects
change the system to not use zipped eggs, and run a patch.
both are going to be a hassle to maintain, and add a lot of complexity to the build/deploy process.
does anyone have other suggestions?
|
How to get data from inspect element of a webpage using Python
| 25,027,442 | 0 | 6 | 34,323 | 0 |
python,html,extract
|
BeautifulSoup could be used to parse the html document, and extract anything you want. It's not designed for downloading. You could find the elements you want by it's class and id.
| 0 | 0 | 1 | 0 |
2014-07-30T01:11:00.000
| 4 | 0 | false | 25,027,339 | 0 | 0 | 1 | 1 |
I'd like to get the data from inspect element using Python. I'm able to download the source code using BeautifulSoup but now I need the text from inspect element of a webpage. I'd truly appreciate if you could advise me how to do it.
Edit:
By inspect element I mean, in google chrome, right click gives us an option called inspect element which has code related to each element of that particular page. I'd like to extract that code/ just its text strings.
|
How do I prevent the raw WSGI python file from being read?
| 25,056,888 | 0 | 1 | 77 | 0 |
python,apache,.htaccess,wsgi
|
You should not stick the WSGI file in the DocumentRoot directory in the first place. You have created the situation yourself. It doesn't need to be in that directory for WSGIScriptAlias to work.
| 0 | 1 | 0 | 1 |
2014-07-30T16:33:00.000
| 2 | 0 | false | 25,042,205 | 0 | 0 | 1 | 2 |
I am using mod_wsgi with apache to serve the python application. I have a directive in the VirtualHost entry as follows WSGIScriptAlias /app /home/ubuntu/www/app.wsgi. I also have DocumentRoot /home/ubuntu/www/. Therefore, if the user attempts to read /app.wsgi it gets the raw file. If I try to block access to it via .htaccess, the application becomes unusable. How do I fix this? Is there a way to do so without moving the file out of the DocumentRoot?
|
How do I prevent the raw WSGI python file from being read?
| 25,045,724 | 0 | 1 | 77 | 0 |
python,apache,.htaccess,wsgi
|
This is far from the best option, but it does seem to work: I added WSGIScriptAlias /app.wsgi /home/ubuntu/www/app.wsgi to the VirtualHost as well so that it will run the app on that uri instead of returning the raw file.
| 0 | 1 | 0 | 1 |
2014-07-30T16:33:00.000
| 2 | 0 | false | 25,042,205 | 0 | 0 | 1 | 2 |
I am using mod_wsgi with apache to serve the python application. I have a directive in the VirtualHost entry as follows WSGIScriptAlias /app /home/ubuntu/www/app.wsgi. I also have DocumentRoot /home/ubuntu/www/. Therefore, if the user attempts to read /app.wsgi it gets the raw file. If I try to block access to it via .htaccess, the application becomes unusable. How do I fix this? Is there a way to do so without moving the file out of the DocumentRoot?
|
Lightweight Python Web Browser
| 31,276,859 | -1 | 0 | 1,135 | 0 |
python,multithreading,web,browser,python-webbrowser
|
i have written winks-up in vala.
It's small and fast and compile well on raspbian.
All the code was optimize to reduce memory occupation.
isn't perfect but was better like nothing
| 1 | 0 | 0 | 1 |
2014-07-30T20:04:00.000
| 3 | -0.066568 | false | 25,045,924 | 0 | 0 | 1 | 2 |
Got a bit of weird request here, however it's one which I can't really figure out the answer to.
I'm writing a python application that displays web pages and locally stored images.
What I need is a way of displaying a web page using python that is really lightweight and quite fast. The reason for this is that it is running on a Raspberry Pi.
Of course I have many options, I can run it through web browser installed on the Raspbian distribution and run it as a separate process in python, I can download an Arch-Linux compatible browser and run it as a separate process in python and finally I can write my own native python file using Gtk or PyQt.
All of these approaches have their downsides as well as serious overheads. The web browser must also be full screen when I have a web page to display, and minimised when I'm displaying an image.
The main issue I have had with Gtk and PyQt is the way they have to be executed on the main thread - which is impossible as it doesn't align with my multithreaded architecture. The downside to using the web browsers that are pre-installed on raspbian, is that from python you lack control and it's slow. And finally, the issue with using an Arch-Linux browser is that it ends up being messy and hard to control.
What I would Ideally need is a web browser that loads a web page almost instantaneously, or a multithreaded web browser that can handle multiple instances. This way I can buffer one web page in the background whilst another browser is being displayed.
Do you guys have any advice to point me in the right direction? I would've thought that there would be a neat multithreaded python based solution by now, and I would think that's either because no one needs to do what I'm doing (less likely) - or I'm missing something big (more likely)!
Any advice would be appreciated.
James.
|
Lightweight Python Web Browser
| 25,051,761 | 0 | 0 | 1,135 | 0 |
python,multithreading,web,browser,python-webbrowser
|
I'd use PyQT to display the page but if the way PyQT use threads does not fit within you application, you may just write a minimalist (I'm speaking of ~10 lines of code here) web browser using PyQT, and fork it from your main application ?
| 1 | 0 | 0 | 1 |
2014-07-30T20:04:00.000
| 3 | 0 | false | 25,045,924 | 0 | 0 | 1 | 2 |
Got a bit of weird request here, however it's one which I can't really figure out the answer to.
I'm writing a python application that displays web pages and locally stored images.
What I need is a way of displaying a web page using python that is really lightweight and quite fast. The reason for this is that it is running on a Raspberry Pi.
Of course I have many options, I can run it through web browser installed on the Raspbian distribution and run it as a separate process in python, I can download an Arch-Linux compatible browser and run it as a separate process in python and finally I can write my own native python file using Gtk or PyQt.
All of these approaches have their downsides as well as serious overheads. The web browser must also be full screen when I have a web page to display, and minimised when I'm displaying an image.
The main issue I have had with Gtk and PyQt is the way they have to be executed on the main thread - which is impossible as it doesn't align with my multithreaded architecture. The downside to using the web browsers that are pre-installed on raspbian, is that from python you lack control and it's slow. And finally, the issue with using an Arch-Linux browser is that it ends up being messy and hard to control.
What I would Ideally need is a web browser that loads a web page almost instantaneously, or a multithreaded web browser that can handle multiple instances. This way I can buffer one web page in the background whilst another browser is being displayed.
Do you guys have any advice to point me in the right direction? I would've thought that there would be a neat multithreaded python based solution by now, and I would think that's either because no one needs to do what I'm doing (less likely) - or I'm missing something big (more likely)!
Any advice would be appreciated.
James.
|
How to change settings in a middleware?
| 25,054,828 | 0 | 0 | 394 | 0 |
python,django,apache
|
No, there is no way to do this, and that's a very good thing as it is a bad idea. There is no reason to use the same Apache process for different sites: instead you should have different virtual hosts for each of your sites, and let Apache manage them.
| 0 | 0 | 0 | 0 |
2014-07-31T08:37:00.000
| 1 | 1.2 | true | 25,054,347 | 0 | 0 | 1 | 1 |
I'd like to change the environment variable DJANGO_SETTINGS_MODULE (along with a few others) and then have ALL relevant modules like django.conf, django.db etc reloaded to reflect the information from the new settings module. The new settings module will have different database. I will be doing this in a middleware.
I was able to achieve this by reloading a few modules along with django.conf and django.db. All new SQL statements were fired against the new DB.
But this appears to be so hackish.
The main reason for me wanting to do this is to have the same apache child process serve requests for different django applications (different settings and not different apps) without having to recreate a new apache child process which reloads the whole thing.
Is there a clean way of achieving what I want to do?
Thanks,
UPDATE (19-Sept-2014): I have accepted Daniel Roseman's answer as that seems to be the reality in the context of the question asked. The Router approach suggested by him was something that I explored but couldn't use because django's transaction classes don't use the router. The router I presume exists for a different reason. The application code base I'm working on, which is pretty large, has tons of transaction.commit_manually for the default or a specific db alias. I was trying to get this to support multiple client databases without changing the application code.
However, I did manage to solve the main problem which was to support multiple client DBs and other settings. I don't try to change the settings on the fly nor do I use the router. I instead have a single settings.py with all client DB information. I monkey patched the connection handler to return a different database connection for 'default' alias (or other specific alias used by the code) based on certain env variables set in the middleware. So far this has worked fine. I will post an update if I run into any issues or if someone else can point out a potential issue with the approach.
|
Pass a request to a DJANGO REST api using Angular and then return those results in a DJANGO view
| 25,067,631 | 1 | 1 | 109 | 0 |
javascript,python,django,angularjs,rest
|
It depends on the architecture of your application.
If you are building your client as a single page web application using Angular & your business logic is served using the Django REST API in JSON/XML format. Then rendering of the view should be the responsibility of the client side code.
As per me whatever you are doing looks perfectly okay. I don't see any redundancy of the templates in this architecture.
| 0 | 0 | 0 | 0 |
2014-07-31T17:03:00.000
| 1 | 1.2 | true | 25,064,876 | 0 | 0 | 1 | 1 |
Ok, so basically what is happening is I have a search input on my index page. The user types something in the search input, and that is sent to the Django REST api which returns the data in JSON format. I can loop through that results array using Angular ng-repeat. But my question is: is there a way to send that request to another django view and have django return the values using a for loop and a template that I already created?
( I am trying to avoid recreating the template specifically for Angular because that would be repetitive)
Any suggestions, or help on this comes much appreciated. Thank you in advance for taking the time to help me.
All the best.
|
Error: No section: 'default' in Robot Framework using DatabaseLibrary
| 32,266,513 | 2 | 1 | 4,534 | 1 |
python-2.7,robotframework
|
You should check the content of dbConfigFile. You don't specify one so the default one is ./resources/db.cfg.
The error says when python try to parse that file it cannot find a section named default. In documentation it says:
note: specifying dbapiModuleName, dbName dbUsername or dbPassword directly will override the properties of the same key in dbConfigFile
so even if you specify all properties it reads config file.
| 0 | 0 | 0 | 0 |
2014-08-01T04:44:00.000
| 1 | 0.379949 | false | 25,072,996 | 0 | 0 | 1 | 1 |
I am using Robot Framework with Database Library to test database queries on localhost. I am running it by XAMPP.
This is my test case:
*** Settings ***
Library DatabaseLibrary
*** Variables ***
@{DB} robotframework root \ localhost 3306
*** Test Cases ***
Select from database
[Tags] This
Connect To Database MySQLdb @{DB}[0] @{DB}[1] @{DB}[2] @{DB}[3] @{DB}[4]
@{results}= Query Select * From tbName
Log Many @{results}
I have installed MySQLDb for Python 2.7, however, when I run it using pybot, it keeps returning error:
Select from database | FAIL |
NoSectionError: No section: 'default'
Please help me to solve this problem. Thanks.
|
How to preserve UTF8 string from app to webserver in Python
| 25,074,740 | 2 | 1 | 191 | 0 |
python,utf-8
|
HTTP headers are strictly 7-bit US ASCII. The RFC allows you to accept ISO8859-1as a compatibility hack, but don't send any byte beyond 127.
There is no standard or best way to send any other data type beside ASCII in the headers. It is your application's responsibility to encode arbitrary sequences of bytes (and your UTF string is an arbitrary sequence of bytes) such that the encoding is 7-bit safe.
Use whatever is most convenient for both client and server in their implementation language(s). Base64 encoding, \hh byte escapes, \uhhhh unicofe character escapes, %hh as per URL encoding, =HH as in MIME, or &#... entities. All of these methods exist and are being used in the wild.
| 0 | 0 | 0 | 0 |
2014-08-01T06:30:00.000
| 4 | 0.099668 | false | 25,074,173 | 0 | 0 | 1 | 2 |
I have an app that submit a request to a Python webserver. The app has a UTF8 string with the following contents:
la langue franþaise.ppt
This is put into a HTTP header, and somehow converted as such:
la langue fran\xfeaise.ppt
Then Python on the web-server tried to do something with the string that maybe expects it to be UTF8, and I get this error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 14: invalid start byte
I would basically like to preserve this UTF8 from the app to the web-server, such that the variable would contain the following if I printed it:
la langue franþaise.ppt
What's the best way to preserve a UTF8 string from a web client and server (assuming both written in Python)?
|
How to preserve UTF8 string from app to webserver in Python
| 25,074,360 | 2 | 1 | 191 | 0 |
python,utf-8
|
\xfe is ISO-8859-1 encoding for þ.
While utf8 in content is widely supported, HTTP headers should be ASCII. The HTTP spec allows ISO-8859-1, but it's not recommended or reliable in tooling. Other encodings are not allowed without special escaping.
If possible, escape your special chars in a way that allows them to be transferred as ASCII. Base64 as suggested by fileoffset is one option, another would be the quote function from urllib.parse (or urrlib on python2)
| 0 | 0 | 0 | 0 |
2014-08-01T06:30:00.000
| 4 | 1.2 | true | 25,074,173 | 0 | 0 | 1 | 2 |
I have an app that submit a request to a Python webserver. The app has a UTF8 string with the following contents:
la langue franþaise.ppt
This is put into a HTTP header, and somehow converted as such:
la langue fran\xfeaise.ppt
Then Python on the web-server tried to do something with the string that maybe expects it to be UTF8, and I get this error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 14: invalid start byte
I would basically like to preserve this UTF8 from the app to the web-server, such that the variable would contain the following if I printed it:
la langue franþaise.ppt
What's the best way to preserve a UTF8 string from a web client and server (assuming both written in Python)?
|
Import Error - Pydev Eclipse
| 25,087,270 | 1 | 1 | 249 | 0 |
python,eclipse,pydev,importerror
|
For that to work you need to have init.py under 'project_dir', 'dira' and 'dirb' and then you need to set as a source folder the directory which is the parent of the 'project_dir' (and not the project_dir itself) -- and no other directories should be set as source folders.
I.e.: the source folder is the directory added to the PYTHONPATH (so, for importing 'project_dir', its parent must be in the PYTHONPATH).
Note: You may have to remove the project from Eclipse/PyDev and recreate it a level before for this to work depending on how you created it the first time.
| 0 | 0 | 0 | 1 |
2014-08-01T10:46:00.000
| 1 | 0.197375 | false | 25,078,549 | 0 | 0 | 1 | 1 |
I have co'd existing code from an SVN repo that uses full imports - by which I mean:
-->projectdir
-------->dira
-------------->a1.py
-------------->a2.py
-------->dirb
-------------->b1.py
Suppose a1.py imports a method from a2.py:
Normally I would simply write:
from a2 import xyz
Here they have written it as:
from project_dir.dira.a2 import xyz
How do I make eclipse recogonize these imports?
Basically I want to be able to Ctrl+click and Open Declaration. I need to browse through this massive project and I simply cannot do so until this works.
PS:
I have tried adding the projectdir to the PYTHONPATH
I have tried adding each and every sub-directory to PYTHONPATH
I have an init in every folder -_-
|
Django memory leak: possible causes?
| 68,154,893 | 0 | 21 | 15,649 | 0 |
python,django,memory-leaks,uwsgi
|
Django doesn't have known memory leak issues.
I had a similar memory issue. I found that there is a slow SQL causing a high DB CPU percentage. The memory issue is fixed after I fixed the slow SQL.
| 0 | 0 | 0 | 0 |
2014-08-02T00:47:00.000
| 2 | 0 | false | 25,090,573 | 0 | 0 | 1 | 1 |
I've a Django application that every so often is getting into memory leak.
I am not using large data that could overload the memory, in fact the application 'eats' memory incrementally (in a week the memory goes from ~ 70 MB to 4GB), that is why I suspect the garbage collector is missing something, I am not sure though. Also, it seems as this increment is not dependant of the number of requests.
Obvious things like DEBUG=True, leaving open files, etc... no apply here.
I'm using uWSGI 2.0.3 (+ nginx) and Django 1.4.5
I could set up wsgi so that restart the server when the memory exceeds certain limit, but I wouldn't like to do that since that is not a solution really.
Are there any well know situations where the garbage collector "doesn't do its work properly"? Could it provide some code examples?
Is there any configuration of uWSGI + Django that could cause this?
|
Classify different versions of the same webpage
| 25,090,652 | 0 | 0 | 34 | 0 |
python,html,ads,adsense
|
If the HTML is definitely the same every time, the variations are probably being done on the client side using javascript.
The answer depends on what you mean by "classify." If you just want to know, on any given load of the page, where the widgets are, you will probably have to use something like Selenium that actually opens the page in a browser and runs javascript, rather than just fetching the HTML source. Then you will need to use Selenium to eval some javascript that detects the widget locations. There is a selenium module for python that is fairly straightforward to use. Consider hooking it up to PhantomJS so you don't have to have a browser window up.
| 0 | 0 | 1 | 0 |
2014-08-02T00:57:00.000
| 1 | 1.2 | true | 25,090,619 | 0 | 0 | 1 | 1 |
There is a webpage which when loaded uses a random placement of forms / controls / google ads. However, the set is closed--from my tests there are at least three possible variations, with two very common and the third very rare.
I would like to be able to classify this webpage according to each variation. I tried analyzing the html source of each variation, but the html of all the variations is exactly the same, according to both Python string equals and the Python difflib. There doesn't seem to be any information specifying where to put the google ads or the controls.
For an example, consider a picture with two boxes, a red one (call it box A) and a blue one (call it box B). The boxes themselves never change position, but what takes their position does.
Now consider two possible variations, one of which is chosen everytime the webpage is loaded / opened.
Variation 1: Suppose 50% of the time, the google ad is positioned at box A (the red one) and the website control is thus placed at box B (the blue one).
Variation 2: Suppose also 50% of the time, the google ad is positioned at box B (the blue one) and the website control is thus placed at box A (the red one).
So if I load the webpage, how can I classify it based on its variation?
|
Google App Engine, Datastore and Task Queues, Performance Bottlenecks?
| 25,110,135 | 1 | 2 | 158 | 0 |
python,json,google-app-engine,rest,google-cloud-datastore
|
This is a really good question, one that I've been asked in interviews, seen pop up in a lot of different situations as well. Your system essentially consists of two things:
Savings (or writing) models to the data store
Reading from the data store.
From my experience of this problem, when you view these two things differently you're able to come up with solid solutions to both. I typically use a cache, such as memcachd, in order to keep data easily accessible for reading. At the same time, for writing, I try to have a main db and a few slave instances as well. All the writes will go to the slave instances (thereby not locking up the main db for reads that sync to the cache), and the writes to the slave db's can be distributed in a round robin approach there by ensuring that your insert statements are not skewed by any of the model's attributes having a high occurance.
| 0 | 1 | 0 | 0 |
2014-08-03T22:30:00.000
| 2 | 0.099668 | false | 25,109,746 | 0 | 0 | 1 | 1 |
We're designing a system that will take thousands of rows at a time and send them via JSON to a REST API built on Google App Engine. Typically 3-300KB of data but let's say in extreme cases a few MB.
The REST API app will then adapt this data to models on the server and save them to the Datastore. Are we likely to (eventually if not immediately) encounter any performance bottlenecks here with Google App Engine, whether it's working with that many models or saving so many rows of data at a time to the datastore?
The client does a GET to get thousands of records, then a PUT with thousands of records. Is there any reason for this to take more than a few seconds, and necessitate the need for a Task queues API?
|
Adding PyDev eclipse pulgin manually
| 25,133,261 | 0 | 0 | 347 | 0 |
java,python,eclipse,plugins
|
I solved this problem:
There was no issue with either eclipse or with PyDev. It was about the Java version I had. PyDev works with JDK 7, but I had JDK 6. Due to this even after I copied the PyDev to droppins, nothing was shown up in Preferences. Once I used JDK 7, its working.
Thanks,
| 0 | 1 | 0 | 0 |
2014-08-04T12:04:00.000
| 2 | 0 | false | 25,118,283 | 0 | 0 | 1 | 1 |
I am on an assignment to work with Jython. I tried to install PyDev plugin to my eclipse ( Kepler service release 2 on Linux 64 bit machine )manually (dev machine doesnot have internet connection). But when I do manually by downloading .zip file and adding it as following:
Help-> Install new software ->Add -> Archieve:
but I am getting an error.
No repository found at file:/home/lhananth/eclipse/dropins/PyDev%203.6.0.zip!.
No repository found at file:/home/lhananth/eclipse/dropins/PyDev%203.6.0.zip!.
I tried to manually add the unziped folders to dropin folder of eclipse but its not working as well- Python is not appearing as a selection in the Eclipse, Window, Preferences.
Can some body help me out ? (I tried all the replies for similar posts available in stack overflow)
|
Django REST Framework: Generics or ModelViewSets?
| 25,138,732 | 4 | 12 | 14,838 | 0 |
python,django,rest,django-rest-framework
|
Why there is generics if ModelViewSet gives same abilities and more?
Let me first rephrase the question a little more explicitly for you...
"Why are there Generic Views, when there are also Generic ViewSets"
Which really just comes down to a question of why REST framework supports both views and viewsets. Answer - ViewSets are useful for prototyping or for cases when your API URLs neatly map to a fixed convention throughout (eg CRUD style APIs). Views are useful for being explicit, or for cases when your URLs do not neatly map to a fixed convention throughout.
| 0 | 0 | 0 | 0 |
2014-08-04T19:19:00.000
| 3 | 0.26052 | false | 25,125,959 | 0 | 0 | 1 | 1 |
I use generics and plain urls for my REST API, but now I stuck with problem: I want custom actions, simple views to make some things with my models, like "run", "publish", etc.
ViewSet gives action decorator to create custom actions, but only in ViewSets, also, there is stepial routers, which gives us ability to simplify everything using railsish convention-over-configuration.
But I find that ModelViewSet gives us same abilities, as generics: full CRUD, serializers, filters, cusstom pre/post and queryset, so, it leads to question:
Why there is generics if ModelViewSet gives same abilities and more? What a difference?
|
best practice for tracking new/seen items
| 25,140,245 | 0 | 0 | 60 | 0 |
python,google-app-engine,google-cloud-datastore,app-engine-ndb
|
There's probably a few ways to go about this, and using Google Cloud SQL would probably make your life easier for this. What you could do though is add a BooleanProperty to your entity types for example, named 'New', that would be set to 'True' by default. You would need to create an algorithm that would check through the datastore to return you any entity who's 'New' BooleanProperty is set to True, and then set it to False once it's returned.
| 0 | 0 | 0 | 0 |
2014-08-05T12:38:00.000
| 1 | 0 | false | 25,139,041 | 1 | 0 | 1 | 1 |
So I'm making productivity app for myself and ppl around me. There will be a lots of different stuff related to different type groups or individual persons for different types of reasons.
Is there some best practice approach, algorythm or guidelines to do this properly that I should know before I screw everything up?
If it matters, I'm using GAE, Python, NDB.
CLARIFICATION EDIT:
someone contributed to household's savings account
Someone posted a picture to album of the party that I attended
somone from household added someting to shopping list
i received a direct message
someone uploaded a documentg to project workspace etc
I need to keep track of which items are new and which have been seen.
|
start only one flask instance using apache + wsgi
| 25,143,417 | 1 | 1 | 1,457 | 1 |
python,apache,flask,wsgi
|
The WSGIApplicationGroup directive may be what you're looking for as long as you have the wsgi app running in daemon mode (otherwise I believe apache's default behavior is to use prefork which spins up a process to handle each individual request):
The WSGIApplicationGroup directive can be used to specify which application group a WSGI application or set of WSGI applications belongs to. All WSGI applications within the same application group will execute within the context of the same Python sub interpreter of the process handling the request.
You have to provide an argument to the directive that specifies a name for the application group. There's a few expanding variables: %{GLOBAL}, %{SERVER}, %{RESOURCE} and %{ENV:variable}; or you can specify your own explicit name. %{GLOBAL} is special in that it expands to the empty string, which has the following behavior:
The application group name will be set to the empty string.
Any WSGI applications in the global application group will always be executed within the context of the first interpreter created by Python when it is initialised. Forcing a WSGI application to run within the first interpreter can be necessary when a third party C extension module for Python has used the simplified threading API for manipulation of the Python GIL and thus will not run correctly within any additional sub interpreters created by Python.
I would recommend specifying something other than %{GLOBAL}.
For every process you have mod_wsgi spawn, everything will be executed in the same environment. Then you can simply control the number of database connections based on the number of processes you want mod_wsgi to spawn.
| 0 | 0 | 0 | 0 |
2014-08-05T15:49:00.000
| 1 | 1.2 | true | 25,143,105 | 0 | 0 | 1 | 1 |
I'm using wsgi apache and flask to run my application. I'm use from yourapplication import app as application to start my application. That works so far fine. The problem is, with every request a new instance of my application is created. That leads to the unfortunate situation that my flask application creates a new database connection but only closes it after about 15 min. Since my server allows only 16 open DB connections the server starts to block requests very soon. BTW: This is not happening when I run flask without apache/wsgi since it opens only one connection and serves all requests as I want.
What I want: I want to run only one flask instance which then servers all requests.
|
Django manage.py runserver fails to respond
| 25,291,353 | 2 | 2 | 2,089 | 0 |
python,django,python-2.7
|
Okay, so to reiterate my last post.
There was a call to a Django service that was failing on application startup. No error was thrown, instead it was absorbed by Sentry. Those who were already using the VM on their local machines had worked around the issue.
The issue was identified by importing ipdb and calling its set_trace() function. From the console, I stepped through the application, testing likely variables and return values until it refused to continue. This narrowed it down to the misbehaving service and its unthrown error.
The code has been updated with proper try/catch blocks and the error is now handled gracefully.
So to summarise: Not a malfunctioning VM, but a problem with code.
| 0 | 1 | 0 | 0 |
2014-08-05T16:14:00.000
| 1 | 1.2 | true | 25,143,621 | 0 | 0 | 1 | 1 |
I'm running a vagrant box on Mac OS X. The VM is running Ubuntu 12.04, with Python 2.7 and Django 1.4.5. When I start up manage.py, I call it like this:
./manage.py runserver 0.0.0.0:8000
And if I visit http://127.0.0.1:8000 from within the VM, the text browsers I've tried report that the HTTP request has been sent and then wait for a response until the request times out. No response ever comes.
I can telnet to the port like this:
telnet 127.0.0.1 8000
And enter random gibberish, which manage.py reports as the following:
127.0.0.1 - - [05/Aug/2014 17:06:26] code 400, message Bad request syntax ('asdfasdfadsfasd')
127.0.0.1 - - [05/Aug/2014 17:06:26] "asdfasdfadsfasd" 400 -
So manage.py is listening on that port. But a standard HTTP request generates no response from manage.py, either in the console or in the browser.
I've tried using different ports which hasn't had any effect. Does anyone have any ideas?
UPDATE
Some additional curl output.
Executing 'curl -v http://127.0.0.1:8000' returns
'* About to connect() to 127.0.0.1 port 8000 (#0)
* Trying 127.0.0.1... connected
GET / HTTP/1.1
User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: 127.0.0.1:8000
Accept: /
'
Executing 'curl -v http://somefakedomain' results in
'* getaddrinfo(3) failed for somefakedomain:80
* Couldn't resolve host 'somefakedomain'
* Closing connection #0
curl: (6) Couldn't resolve host somefakedomain'
|
Saving login screen username and password for Kivy app
| 25,147,496 | 0 | 3 | 5,234 | 0 |
android,python,ios,parse-platform,kivy
|
The answer is essentially that you must simply save the data somewhere. The details will depend on your requirements, and aren't specific to kivy - you can look up normal android or python practices.
I'm not sure exactly what android guarantees about permissions, but storing stuff in your app directory (on the main partition, not 'external' storage) should be inaccessible to other apps, though anything with root can view them. You can use normal python tools if you want to encrypt the data, and manage your own kivy gui for getting a decryption key/password from the user.
| 1 | 0 | 0 | 0 |
2014-08-05T20:02:00.000
| 3 | 0 | false | 25,147,323 | 0 | 0 | 1 | 1 |
I am working on a Kivy app for iOS and Android and need help with keeping the user persistently logged in, even after the app is closed or killed. I am using Parse to store user credentials.
I've already added an on_pause method to the App class, but this only keeps the user logged in if the app is closed but not killed. Is there a best practice for securely allowing persistent user login with Kivy, even after an app is killed?
Edit: I prefer a single Kivy solution that works for both an Android app and an iOS app, without the need to edit/add iOS or Android specific code.
|
Using Mako Template in Javascript
| 25,156,421 | 1 | 2 | 1,595 | 0 |
javascript,jquery,python,html,mako
|
Ajax is the "right" way to do this.
In order to insert the values into your separate Javascript file dynamically, it can no longer be served as a static file. Beyond that, it adds an extra layer of problems with security and maintainability as you have to deal with string escaping, possible script injection, and having Mako syntax in your Javascript. Not to mention losing the ability to host your .js files on a CDN or server configured for static files.
| 0 | 0 | 0 | 0 |
2014-08-06T09:00:00.000
| 1 | 0.197375 | false | 25,156,170 | 0 | 0 | 1 | 1 |
I have a dashboard I am working on, using Python cherrypy framework and Mako template language.
I had an html file for each of dashboard pages.
There, I used Mako to pass some data to html and inline Javascript.
For example, to display the names of some processes when I only had the list of ids, I passed a Python dict that maps ids to their corresponding names, and then used the dict in ${} tags.
However, as I am now moving these Javascript codes into a separate file with .js extension, I found out simply putting the same Mako code blocks in the Javascript code does not work.
Is there any way I could use Mako template language in an external .js file that is imported in an html file?
Is it considered a bad practice and should I pass all these data using XMLHTTPRequests when I am passing them to Javascript?
|
Can I add a checkbox in to Model Forms in Django even if there is no Field in DB for it
| 25,174,963 | 0 | 0 | 868 | 0 |
django,python-2.7,django-models,django-forms
|
Define a Custom ModelForm by specifying model in Meta and declare the required additional field there. After that set form attribute of your Admin class with the name of YourForm.
| 0 | 0 | 0 | 0 |
2014-08-07T05:28:00.000
| 2 | 0 | false | 25,174,797 | 0 | 0 | 1 | 1 |
I have a model form and I need to add a checkbox to it. This checkbox is not mapped to any database field. Is this possible ? How !
|
Is twistedweb with django recommeneded
| 25,198,042 | 2 | 3 | 244 | 0 |
python,django,twisted,event-driven,twisted.web
|
Nope, unless you heavily modify django db adapters and some core component you will not get any advantage. There are some tool for simplyfing the job, but you will be on the bleeding edge trying to adapt something built with the blocking paradigm since the beginning, to something completely different.
On the other side, performance should not be worst, as 99.9% of the time your app itself is the bottleneck, not your WSGI infrastructure.
Regarding async django, lot of people had luck with gevent, but you need to carefully analyze your app to be sure all of the components are gevent-friendly (and this could not be an easy task, expecially for db adapters).
Remember, even if your app is 99.9999999% non-blocking, you are still blocking.
| 0 | 1 | 0 | 0 |
2014-08-07T07:37:00.000
| 2 | 0.197375 | false | 25,176,734 | 0 | 0 | 1 | 1 |
I have a Django application which I need to deploy in a WSGI container. I can either chose an event driven app server like TwistedWeb or a process driven server like uWSGI. I completely understand the difference between an event driven and a process driven server and I know Django framework is blocking in nature.
I came across TwistedWeb which lets us run a WSGI application in a simple fashion.
My questions are as follows:
1) Would I gain anything by running Twisted instead of uWSGI as Django is blocking in nature. Is TwistedWeb different from the standard twisted library ? I know people run Twisted with Django when they need support for async as well, for ex chat along with normal functionality and they still want to have just one app. I have no such use case and for me its just a website.
2) Would the performance be worse on TwistedWeb as its just a single process and my request would block as Django is synchronous in nature ? Or TwistedWeb runs something like uWSGI which launches multiple processes before hand and distributes requests in a roundrobin fashion among those ? If yes then is TwistedWeb any better than uWSGI ?
3) Is there any other protocol other than WSGI which can integrate Twisted with Django and still give me async behavior (trying my luck here :) )
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.