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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Backup in one and restore in another Google App Engine application by using Cloud Storage? | 34,706,288 | 4 | 8 | 961 | 1 | python,google-app-engine | Yes!! What you are trying to do is not possible. The reason is that there are absolute references in the backup files to the original backup location (bucket). So moving the files to another GCS location will not work.
Instead you have to leave the backup files in the original GCS bucket and give your new project read access to that folder. That is done in the "Edit bucket permissions" option. eg. add:
Project - owners-12345678 - Reader
Now you are able to import from that bucket in your new project in "Import Bucket Information". | 0 | 1 | 0 | 0 | 2014-12-16T22:17:00.000 | 2 | 0.379949 | false | 27,514,985 | 0 | 0 | 1 | 2 | My goal was to duplicate my Google App Engine application. I created new application, and upload all needed code from source application(python). Then I uploaded previously created backup files from the Cloud Storage of the source application (first I downloaded those files to PC and than uploaded files to GCS bucket of the target app)
After that I tried to restore data from those files, by using "Import Backup Information" button.
Backup information file is founded and I can add it to the list of available backups. But when I try to do restore I receive error: "There was a problem kicking off the jobs. The error was: Backup not readable"
Also I tried to upload those files back to original application and I was able to restore from them, by using the same procedure, so the files are not corrupted.
I know there are another methods of copying data between applications, but I wanted to use this method. If for example, my Google account is being hacked and I can not access my original application data, but I have all backup data on my hard drive. Then I can simply create new app and copy all data to the new app...
Has anyone before encountered with the similar problem, and maybe found some solution?
Thanks! |
Backup in one and restore in another Google App Engine application by using Cloud Storage? | 29,852,870 | 1 | 8 | 961 | 1 | python,google-app-engine | Given the message, my guess is that the target application has no read access to the bucket where the backup is stores. Add the application to the permitted users to that bucket before creating the backup so that the backup objects will inherit the permission. | 0 | 1 | 0 | 0 | 2014-12-16T22:17:00.000 | 2 | 0.099668 | false | 27,514,985 | 0 | 0 | 1 | 2 | My goal was to duplicate my Google App Engine application. I created new application, and upload all needed code from source application(python). Then I uploaded previously created backup files from the Cloud Storage of the source application (first I downloaded those files to PC and than uploaded files to GCS bucket of the target app)
After that I tried to restore data from those files, by using "Import Backup Information" button.
Backup information file is founded and I can add it to the list of available backups. But when I try to do restore I receive error: "There was a problem kicking off the jobs. The error was: Backup not readable"
Also I tried to upload those files back to original application and I was able to restore from them, by using the same procedure, so the files are not corrupted.
I know there are another methods of copying data between applications, but I wanted to use this method. If for example, my Google account is being hacked and I can not access my original application data, but I have all backup data on my hard drive. Then I can simply create new app and copy all data to the new app...
Has anyone before encountered with the similar problem, and maybe found some solution?
Thanks! |
Cherrypy session timeout on browser closed? | 27,565,293 | 0 | 0 | 474 | 0 | python,cherrypy | Set tools.sessions.persistent to False | 0 | 0 | 1 | 0 | 2014-12-17T01:59:00.000 | 2 | 0 | false | 27,517,192 | 0 | 0 | 1 | 1 | In cherrypy is there a configuration option so that sessions do not have a "timeout", or if they do, expire immediately when the browser is closed? Right now tools.sessions.on is true and tools.sessions.timeout is 60 minutes. |
How to embed Bokeh server in Django application | 27,520,156 | 10 | 13 | 5,749 | 0 | python,django,bokeh | No need to reinvent.
bokeh-server is a webserver and can listen on arbitrary port.
you can have your django webserver listen on some other arbitrary port.
... and integrate the two:
have redirects from django to bokeh-server, or
webserver in front, e.g. nginx which does reverse-proxy. | 0 | 0 | 0 | 0 | 2014-12-17T07:02:00.000 | 1 | 1 | false | 27,519,960 | 0 | 0 | 1 | 1 | From what I read the dynamic and big data rendering capabilities of Bokeh are accessible by use of the bokeh-server.
In Bokeh documentation there is a brief mention of embedding the bokeh-server in a Flask application using the blueprint api. This option retains all of the Bokeh's dynamic and big data rendering capabilities.
I would like to do the same for a django1.7 application.
Has this been done?
If so are there any examples? |
Completion of App Engine Index Writes (Python) | 27,540,122 | 1 | 1 | 45 | 0 | python,google-app-engine,google-cloud-datastore | No, it is done asynchronously and you are not able to control this process. Hooks available only for by key gets, not for index queries. Try to build your datastore with parent-child relationships, so you can do ancestor queries, they are always consistent. | 0 | 1 | 0 | 0 | 2014-12-17T10:13:00.000 | 1 | 1.2 | true | 27,523,124 | 0 | 0 | 1 | 1 | Is there a way to know / detect if an object (after being put to the datastore) has been written to an index i.e. object would be visible in a relevant query? Maybe something like a hook method?
Thanks! |
Multiple Time Zones in Google Appengine Cron Job | 27,530,878 | 3 | 0 | 571 | 0 | python,google-app-engine,cron | You can schedule a cron job to run every hour, because every hour there is 9 am somewhere. | 0 | 1 | 0 | 0 | 2014-12-17T15:19:00.000 | 1 | 0.53705 | false | 27,528,859 | 0 | 0 | 1 | 1 | I want to schedule a task for 9:00 AM in every country. (basically 9:00 AM in every time zone). How can I schedule that in google appengine?
Will it take multiple timezones for time zone parameter?
Thanks in advance |
Associate Existing Image File with Django Model | 27,534,164 | 1 | 0 | 360 | 0 | python,django,django-models,django-templates,django-admin | Well you have to save it somewhere in order to map the user and the image....
So I can think of 2 solutions -
Have a field that stores the path. Then you can access it via the template, something like this - <img src="{{author.photo_path}}">
If you're saying the path might change, you can have a user ID for each user, and store his photo with that ID. Then you can simply do <img src="/path/{{author.id}}_picture.gif">
Using the second solution, you can also have the path as a variable in your code, and then pass it to the template, and access the picture like this -
<img src="/{{path}}/{{author.id}}_picture.gif">, which doesn't force you to have a hardcoded path, and once the path changes you only change it once, not in all your model instances/template files | 0 | 0 | 0 | 0 | 2014-12-17T20:16:00.000 | 1 | 1.2 | true | 27,534,078 | 0 | 0 | 1 | 1 | I'm creating a basic blog in Django. One of my classes is for the authors. Each contains Name, Position, Biography, etc., and I'm attempting to associate existing images with each author to be used as avatars, essentially.
FileField and ImageField aren't what I want to use as I already have images stored statically elsewhere- I just want to specify each image's path manually in the Django admin as a URL (CharField/TextField, whatever) and have that image served when I call {{ author.photo }} in a template, for example. I also don't necessarily want to source the image path from the class model, as the structure and paths of the existing images may change. Any ideas? |
Terminal/django/komodo edit | 27,559,411 | 1 | 0 | 323 | 0 | python,django,terminal,komodoedit | Let's start from the beginning:
You are in your project folder eg /home/me/myproject
You create a new virtualenv, eg virtualenv /home/me/virtualenvs/myprojectenv
You activate the new virtualenv:
source /home/me/virtualenvs/myprojectenv/bin/activate
...this means that python and pip commands now point to the versions installed in your virtualenv
You install your project dependencies pip install django
You can ./manage.py runserver successfully
Now, the virtualenv has only been activated in your current terminal session. If you cd outside your project directory the virtualenv is still active. But if you open a new terminal window (or turn off the computer and come back later) the virtualenv is not activated.
If the virtualenv is not activated then the python and pip commands point to the system-installed copies (if they exist) and Django has not been installed there.
All you need to do when you open a new terminal is step 3. above:
source /home/me/virtualenvs/myprojectenv/bin/activate
Possibly the tutorial you followed got you to install virtualenvwrapper which is an additional convenience layer around the virtualenv commands above. In that case the steps would look like this:
You are in your project folder eg /home/me/myproject
You create a new virtualenv, eg mkvirtualenv myprojectenv
...virtualenv has already been activated for you now!
You install your project dependencies pip install django
You can ./manage.py runserver successfully
and whenever you start a new shell session you need to:
workon myprojectenv
in order to re-activate the virtualenv | 0 | 0 | 0 | 0 | 2014-12-19T03:32:00.000 | 1 | 1.2 | true | 27,559,330 | 1 | 0 | 1 | 1 | I sincerely apologize for the noobish dribble thats about to come out here:
Okay so I am following along with a youtube tutorial using terminal/django/komodo edit to make a simple website. This is my first time really using terminal, I am having issues. I have read up on the terminal and searched this site for my question but to no avail. Im hoping someone will take the time to answer this for me as it is most infuriating. This is my first time working with virtual env's as well.
So my question is, How do I uhmm, I suppose "save" my virtual env settings?
So I have set up a new virualenv. Downloaded django and started up my server so I can see things such as the admin page, log in page, from the internet page. Things go as they should along with the tutorial until it comes time to eventually turn off my computer.
When I reload the virtualenv I cannot run the server, it gives me: Import error, no module named django.core.management.
I use pip freeze and it shows that django is no longer installed.
If trying to reinstall django it gives a long block of error messages.
All the work done within the virtualenv file is still visible for the komodo edit pages however, but it seems the terminal does not want to work properly. My only option thus far has been to completely remake a virualenv, re-set it all up with the proper imports, files, django and restart the project.
so my questions are:
how do I save my terminal and/or virtualenv settings?
What do I need to do before logging off to ensure I will be able to continue with my project?
Lets say I am going to continue with my project, How do I start up the project again via terminal? Is that where I am going wrong? I've assumed up until now that I must go into terminal, start the server again and then from komodo edit continue with my project, but inside the terminal everything goes wrong.
Im not even explicitly saying I cannot continue with my project, I am more saying the terminal is not recognizing I had django installed within my virtualenv, and it is not letting me start the server again.
I have tried doing the research on my own, I am not one to sit back and wait for an answer but being completely new, this is baffling. I am sorry for the noob questions, feel free to link another answered question or website that has the answer.
Thank you all!! |
Python MySQLdb with SELinux | 27,734,160 | 0 | 8 | 1,090 | 1 | python,django,mysql-python,selinux | Couple of permission issues that I notice:
Make sure your credentials for mySQLdb have access to the database.
If you are using IP and Port to connect to the database, try using localhost.
Make sure the user (chmod permissions) have access to the folder where mySQL stores stuff. Sometimes when storing media and things it need permission to the actual folder.
Lastly, I would try to reset Apache server (not the entire machine). | 0 | 0 | 0 | 0 | 2014-12-20T21:29:00.000 | 4 | 0 | false | 27,584,508 | 0 | 0 | 1 | 1 | I'm using the mySQLdb module within my django application which is linked to Apache via WSGI.
However I'm getting permission issues (shown below). This is down to SElinux and if I set it to passive everything is ok.
ImproperlyConfigured: Error loading MySQLdb module:
/opt/django/virtenv/django15/lib/python2.7/site-packages/_mysql.so:
failed to map segment from shared object: Permission denied
What is the best way to update SELinux to include this without having to turn off the whole the thing. The error is shown below:
ImproperlyConfigured: Error loading MySQLdb module:
/opt/django/virtenv/django1/lib/python2.7/site-packages/_mysql.so:
cfailed to map segment from shared object: Permission denied |
Django on CentOS/Bluehost: Attempt to Write a Readonly Database, which Chmod besides 777 to use? | 27,594,818 | 1 | 2 | 310 | 1 | python,django,sqlite | The user accessing the database (www-data?) needs to have write privileges to the folder the data resides in as well as the file itself. I would probably change the group ownership (chgrp) of the folder to www-data and add a group sticky bit to the folder as well (chmod g+s dbfolder). The last one makes sure that any new files created belongs to the group owner.
If you're on bluehost you should also have access to MySql (which is a much better choice for web-facing db). | 0 | 0 | 0 | 0 | 2014-12-21T23:04:00.000 | 1 | 1.2 | true | 27,594,703 | 0 | 0 | 1 | 1 | I am trying to get writing privileges to my sqlite3.db file in my django project hosted on bluehost, but I cannot get any other chmod command to work besides the dangerous/risky chmod 777. When I chmod 777 the db file and the directory, everything works perfectly.
However, in order to be more prudent, I’ve tried chmodding 775 the directory of the sqlite file and chmod 664 the actual db file itself. No luck. I still get OperationalError: Attempt to Write to a Read Only Database whenever I access a feature that requires writing to the db.
I appreciate any assistance. |
scrapy: does it make sense to disable filtering on a formrequest? | 27,602,635 | 1 | 1 | 134 | 0 | python,scrapy | If the request has the dont_filter attribute set, the offsite middleware will allow the request even if its domain is not listed in allowed domains. | 0 | 0 | 1 | 0 | 2014-12-22T10:24:00.000 | 1 | 1.2 | true | 27,600,761 | 0 | 0 | 1 | 1 | So I've been wondering regarding a spider, if maybe some of my requests might be getting filtered because they are to the url endpoint but with different body arguments (form data). Does the dont_filter=True make sense with FormRequest object? |
When should I use the Flask.config vs. use flask.session? | 27,608,409 | 6 | 1 | 170 | 0 | python,flask | Anything that is static, app-wide, doesn't change much, and has important information for all users, should use config. (e.g. secret keys, options to modify the app from project to project, emails, generic messages)
Session should only be used to store relevant user data as the data is modified through each page. (e.g. user login data, user preferences, user inputs from previous pages)
If you have to save something from Page 1 to Page 5 in your website for that particular user, then use session. Sessions should mainly be used based on the individual user. | 0 | 0 | 0 | 0 | 2014-12-22T18:27:00.000 | 2 | 1.2 | true | 27,608,372 | 0 | 0 | 1 | 2 | Is there a rule for when to use Flask.config vs. flask.session to store variables? |
When should I use the Flask.config vs. use flask.session? | 27,608,411 | 4 | 1 | 170 | 0 | python,flask | Yes, most definitely.
The config is for global, project-level variables: the location of files, keys for any APIs you might be using, your database access settings, things like that.
The session is for variables related to the current user's session on the site: their previous choices on a multi-page form, preferences, login details, etc.
You definitely don't want to get these mixed up. | 0 | 0 | 0 | 0 | 2014-12-22T18:27:00.000 | 2 | 0.379949 | false | 27,608,372 | 0 | 0 | 1 | 2 | Is there a rule for when to use Flask.config vs. flask.session to store variables? |
Best way to add Django migrations to a django project | 27,615,457 | 0 | 0 | 635 | 0 | python,django,django-migrations | I have done the migration from 1.6 to 1.7 on an existing project. It was fairly painless.
I renamed my old South migrations folders and let the django 1.7 migrations create a new one. (i.e. $mv appname/migrations appname/migrations.south) That will make it easier to go back to South for any reason and will keep from having a jumbled mess of both in your migrations folders. | 0 | 0 | 0 | 0 | 2014-12-23T05:21:00.000 | 2 | 0 | false | 27,614,494 | 0 | 0 | 1 | 1 | I have a Django application initially created for version 1.6 and I've just finished the upgrade for the last version. All the models has managed = False and prior none of them was managed by south and now I want to start using Django migrations for 1.7 version.
Which would be the best and seamless way to do it? I'm afraid that just changing managed = True in all models and run manage.py makemigrations will make a mess in both migrations files and database.
Thanks
EDIT
As was suggested I ran manage.py makemigrations. It created the script 0001_initial with some model definitions but not for all the objects in models package. It creates 11 tables but I have 19 tables. All models has managed = True and I don't have any database router. |
Notifying user's browser of change without websockets | 27,616,278 | 0 | 1 | 55 | 1 | python,web,pyramid | You need a table with current editor, record_id and timeout. The first editor asks per POST-request to edit a record and you put a new line in this table, with a reasonable timeout, say 5 min. The first editor gets an "ok" in return. For the second editor you find a match for the record_id in the table, look at the timeout, and if it's not timed out, (s)he gets an "error" in return to the post request. In an second POST-request, an editor send it's changes. You look in the table, if (s)he's the editor and send "changed" or "rejected" accordingly. | 0 | 0 | 0 | 0 | 2014-12-23T07:44:00.000 | 2 | 0 | false | 27,616,098 | 0 | 0 | 1 | 1 | I'm developing intranet web app that is based on Pyramid with SQLAlchemy.
It eventually may (will) happen that 2 users will edit the same record. How can I handle the requirement to notify the user who started editing later that particular record is being edited by the first user? |
how to tell browser screen size in python | 27,627,672 | 0 | 0 | 209 | 0 | python,browser,size | I am not sure about what you are trying to do, but I have pretty good reasons to believe that this is something you want to handle in your css/js side of the application.
I am not familiar with app-engine, but the browser does not send it's viewport size with requests (unless you put it yourself in request data).
So if you are using ajax request - put the data about viewport in the data send to backend. If not - use css or js to handle your frontend. | 0 | 0 | 0 | 0 | 2014-12-23T20:34:00.000 | 1 | 0 | false | 27,627,619 | 0 | 0 | 1 | 1 | I am using WebApp2 with python (and app-engine). Is there a way to tell the screen size of the browser in python? I am trying to figure if the browser size is less than 768. |
Get host and port for Heroku app | 27,666,089 | 2 | 3 | 1,682 | 0 | python,heroku,host,crossbar | For the host use 0.0.0.0. For the port number it's slightly more complicated...
When it creates a web dynamo Heroku sets a PORT environment variable with the dynamo's port. To set this in crossbar you need to create a script that reads that variable and writes it into your config wherever the port is requested. Then you make sure that the script returns 0 on exit and put the following in your Procfile:
web: ./your_config_helper_script && crossbar start
That runs your script first (which should get your config file ready) before running crossbar | 0 | 0 | 0 | 0 | 2014-12-23T21:22:00.000 | 1 | 1.2 | true | 27,628,174 | 0 | 0 | 1 | 1 | I'm trying to get a Crossbar.io app running on Heroku. Crossbar.io requires you to put the app's host in a config file that's used to launch the app. I've tried the following:
my-app-name.herokuapp.com: No dice. I imagine Heroku does some fancy redirection internally that prevents this from working.
$HOSTNAME: running a script that outputs the HOSTNAME and using the result in the config file doesn't work either. The HOSTNAME is a GUID that contains no useful information.
IP: I tried getting the external IP of the app, but no luck. The IP changes each time I start the app.
Is there an established way to do this on Heroku?
Also the config requires a port and Heroku seems to assign these dynamically. Any way to access the port as well (ideally before the app runs) |
Bulk download of web images | 27,647,682 | 1 | 0 | 83 | 0 | javascript,python,amazon-s3 | I'd suggest spinning up one or more EC2 instances and running your thumbnail job there. You'll eliminate almost all lot of the bandwidth costs (free from ec2 instances in the right region to s3), and certainly the transfer speed will be faster within the AWS network.
For 600K files to process, you may want to consider loading each of those 'jobs' into an SQS queue, and then have multiple EC2 instances polling the queue for 'work to do' - this will allow you to spin up as many ec2 instances as you want to run in parallel and distribute the work.
However, the work to setup the queue may or may not be worth it depending on how often you need to do this, and how quickly it needs to finish - i.e. if this is a one time thing, and you can wait a week for it to finish, a single instance plugging away may suffice. | 0 | 0 | 1 | 0 | 2014-12-24T08:09:00.000 | 1 | 1.2 | true | 27,633,641 | 0 | 0 | 1 | 1 | I have about 600k images url (in a list) and I would like to achieve the following :
Download all of them
generate a thumbnail of specific dimensions
upload them to Amazon s3
I have estimated my images average to about 1mb which would be about 600gb of data transfer for downloads. I don't believe my laptop and my Internet connection can take it.
Which way should I go? I'd like preferably to have a solution that minimizes the cost.
I was thinking of a Python script or a JavaScript job, run in parrallel if possible to minimize the time needed
Thanks! |
Can uWSGI return a response before the POST data is uploaded? | 27,646,090 | 0 | 0 | 244 | 0 | python,nginx,uwsgi | The limit here is nginx. It cannot avoid (unless when in websockets mode) buffering the input. You may have more luck with apache or the uWSGI http router (albeit i suppose they are not a viable choice) | 0 | 0 | 1 | 1 | 2014-12-25T07:32:00.000 | 1 | 0 | false | 27,645,172 | 0 | 0 | 1 | 1 | I have an api with publishers + subscribers and I want to stop a publisher from uploading a lot of data if there are no subscribers. In an effort to avoid another RTT I want to parse the HTTP header, see if there are any subscribers and if not return an HTTP error before the publisher finishes sending all of the data.
Is this possible? If so, how do I achieve it. I do not have post-buffering enabled in uwsgi and the data is being uploaded with a transfer encoding of chunked. Therefore, since uWSGi is giving me a content-length header, it must have buffered the whole thing somewhere previously. How do I get it to stop?
P.S. uWSGi is being sent the data via nginx. Is there some configuration that I need to set there too perhaps? |
If a website gives a 302 HTTP response code, can I get the original link's raw HTML still? | 27,651,589 | 1 | 0 | 66 | 0 | python,http,python-requests | Basically you don't. If the web server is returning a 302 unless it decides to include the old html(which would be very odd ) you are basically out of luck.
Now if you hit it with a web browser and it doesn't redirect you, then perhaps it is doing something like user agent sniffing and redirecting based on that. So in that case you would need your code to claim to be that ua. | 0 | 0 | 1 | 0 | 2014-12-25T23:26:00.000 | 2 | 0.099668 | false | 27,651,530 | 0 | 0 | 1 | 1 | I'm trying, in Python, using the requests library, to get the HTML for a website that automatically redirects to another one. How do I avoid this and get the HTML for the original site, if possible? I know it exists and has HTML for it because I have accessed it via the Chrome view-source function. Any help appreciated. |
How to manage migrations in django 1.7 among developers? | 27,654,493 | 1 | 4 | 56 | 0 | python,django | so there are developers A and B.
if it is very important you both have notification enabled in git so that you know what your friend has pushed.
lets imagine, A and B are working at the same time on same django app, possibly on the same models.py.
if A pushes changes on models.py, B needs to apply these changes in his local version before he pushes. if B pushes his changes, A needs to apply them first before he pushes. in this way, both local versions will have the same migration history. this is how I do with my friends..
any improvement to what i say is highly appreciated | 0 | 0 | 0 | 0 | 2014-12-26T07:54:00.000 | 1 | 0.197375 | false | 27,654,405 | 0 | 0 | 1 | 1 | We are 2 developers working on a django application. As we are in the initial stages of the app our models are changing rapidly and so are django migration files. So if one of us pushes the migrations to git and when the other one pulls them and tries to apply them, django is not able to find a common migration point as he also would have made some model changes. Please suggest a clean way to resolve this issue. |
Is it okay to spawn a thread from django post save signal? | 27,676,874 | 1 | 5 | 826 | 0 | python,json,django,multithreading,django-models | I don't know where you would have read that signals are executed in threads, because it is not at all true. Django does not do anything with threads, and neither should you: if you want to execute something out of process, use a task queue system like Celery. | 0 | 0 | 0 | 0 | 2014-12-28T13:27:00.000 | 2 | 0.099668 | false | 27,676,834 | 1 | 0 | 1 | 1 | I have post_save signal on one of my models which calls json.dumps on a large python dictionary. I want to call this json.dumps in a separate thread so it may not slow down the save call on my model. I was wondering if it is okay to spawn a new thread from inside a post_save signal? I have read that post_save signals are themselves thread so would it be okay to spawn another Python thread from it?
EDIT: I cannot use a celery task for some reason. |
Django, move variables | 27,695,615 | 2 | 1 | 46 | 0 | python,django,middleware | I'm not sure why you say that session variables are not the best solution. On the contrary, they are absolutely the right solution for doing this.
In the first view, you can simply do request.session['first_data'] = my_data, and in the second, my_data = request.session.pop('first_data'). | 0 | 0 | 0 | 0 | 2014-12-29T20:29:00.000 | 2 | 1.2 | true | 27,695,564 | 0 | 0 | 1 | 1 | I have a standard django application. In a view (let's name it First) I call an HttpResponseRedirect (to the view called Second) however there is some data I'd like to transfer to the Second view. What options do I have to achieve this?
One would be to set a GET parameter, however this is not a nice solution.
I also could set a session variable, but this is also not the best solution.
Do I have any other possibility? For example could I use some context processor or something similar?
My question might contain not all the information, but I hope someone can give me a good tip. |
Import absolute import only once in Django project | 27,710,578 | 2 | 2 | 904 | 0 | python,django,python-2.7 | The problem with frequent use of absolute_import is usually caused by the ambiguity within a package. If you are developing several subpackages and need to constantly use absolute_import to use a top-level package, just rename the problem subpackage. It is anyway a good idea. | 0 | 0 | 0 | 0 | 2014-12-30T18:09:00.000 | 2 | 0.197375 | false | 27,710,366 | 0 | 0 | 1 | 1 | I like to use absolute_import function in Python 2.7. Because in Python 2.7 there is no absolute_import
So I have to import it like this.
from __future__ import absolute_import
In my Django project I have a lot of files, like models.py, views.py and so on. And on top of each file I have to put
from __future__ import absolute_import
to be able to use this function.
Question is following:
If there is possibility to import absolute_import only once in project and use it everywhere ? |
Using Robot framework with Google Chrome browser | 27,816,296 | 0 | 0 | 580 | 0 | python-2.7,selenium-webdriver,robotframework | Have you tried running the test with 'pybot -L TRACE' ? | 0 | 0 | 1 | 1 | 2014-12-31T06:21:00.000 | 1 | 0 | false | 27,717,059 | 0 | 0 | 1 | 1 | I am running test scripts in Robot framework using Google Chrome browser.
But when I run scripts consecutively two times, no message log gets generated in message log section in Run tab. This problem is being encountered only while using Chrome.
Can anyone help me on this as why it is occurring. |
How to override a signal in the sites framework django framework | 27,780,840 | 0 | 0 | 92 | 0 | python,django,django-signals | You should be able to do this by importing only the signals you need to use. You could have a separate set of signal files for each of your sites, importing them relatively to your wsgi.py or manage.py files, which should allow you to override or extend your entire base signal library.
If all of your sites are running from one wsgi.py or manage.py file, you will probably have to test which files to import instead of relying on importing them relative to your cwd. | 0 | 0 | 0 | 0 | 2014-12-31T07:41:00.000 | 1 | 0 | false | 27,717,893 | 0 | 0 | 1 | 1 | I have a model that is firing a post_save signal in the django framework set to run more than one site. What I need to do is to be able to override that signal with a signal that will be defined in the specific site that needs this signal and use the one in the main app as a base.
Or maybe in short I want to be able to write these signals or any other code that is specific to each site in its own place but inheriting from the common code. |
How to cancel Django cache in fastcgi | 27,725,014 | 2 | 0 | 47 | 0 | python,django,apache | Thats the nature of using it in that format/setup. On development, running as 'manage.py runserver' it auto reloads on file changes.
production/proxy setups like you have, you need to reload/restart the service to have changes take effect. | 0 | 0 | 0 | 0 | 2014-12-31T17:57:00.000 | 1 | 1.2 | true | 27,724,624 | 0 | 0 | 1 | 1 | I am testing a web application on both shared host and Apache localhost, using Django and fastcgi. When I edited my code and refreshing the page, many times the new code does not take effect. I think this is a cache issue, but I don't know how from the application.
For example: adding new url pattern to mysite/urls.py it does not take effect till I restart the Apache server on the localhost or waiting some time on the shared host.
I did not find any entries in mysite/settings.py that may allow any solution for that issue. I use Django 1.7 and Python 3.4.2. |
Django: How to query terms with punctuation (ie: !.;’) insensitivity? | 27,730,225 | 2 | 0 | 195 | 0 | python,django,facebook,facebook-graph-api | You'll need to store two versions of the username: one for querying against, and one for display. | 0 | 0 | 0 | 0 | 2015-01-01T11:03:00.000 | 3 | 0.132549 | false | 27,730,191 | 0 | 0 | 1 | 2 | I am creating an application that needs to find facebook usernames that I’ve stored in the database, but facebook usernames are both case insensitive and insensitive to periods. For example, the username Johnsmith.55 is the same as johnsmith55 or even j…O.hn.sMiTh.5.5. when sending facebook API requests.
Obviously, I am using the _iexact query command to remedy the case insensitivity, but what can I use to remedy the insensitivity to periods? I know a cop out method is simply to save all usernames to the database after stripping them of periods and also stripping the username that’s being searched of its periods and then querying, but I want to save and display people’s username’s the way that they really appear in their facebook URL (which includes periods) even though facebook API requests technically are insensitive to periods.
Any ideas for a simple method of doing this? Thanks in advance for any help |
Django: How to query terms with punctuation (ie: !.;’) insensitivity? | 27,730,740 | 1 | 0 | 195 | 0 | python,django,facebook,facebook-graph-api | You can also implement your own querying loguc with custom lookups in Django 1.7 or later. | 0 | 0 | 0 | 0 | 2015-01-01T11:03:00.000 | 3 | 0.066568 | false | 27,730,191 | 0 | 0 | 1 | 2 | I am creating an application that needs to find facebook usernames that I’ve stored in the database, but facebook usernames are both case insensitive and insensitive to periods. For example, the username Johnsmith.55 is the same as johnsmith55 or even j…O.hn.sMiTh.5.5. when sending facebook API requests.
Obviously, I am using the _iexact query command to remedy the case insensitivity, but what can I use to remedy the insensitivity to periods? I know a cop out method is simply to save all usernames to the database after stripping them of periods and also stripping the username that’s being searched of its periods and then querying, but I want to save and display people’s username’s the way that they really appear in their facebook URL (which includes periods) even though facebook API requests technically are insensitive to periods.
Any ideas for a simple method of doing this? Thanks in advance for any help |
Scrapy ImportError: No module named project.settings when using subprocess.Popen | 27,731,947 | 0 | 4 | 1,463 | 0 | python,scrapy,popen | I suggest let python focus on the scrape task and use something else for process control. If it were me, I'd write a small bash script to run your program.
Test that the launcher script works by running it with env -i yourscript.sh because that will make sure it runs without any inherited environment settings.
Once the bash script works correctly, including setting up virtualenv etc, you could have python run that bash script, not python. You've sidestepped any strange environment issues at that point and got yourself a pretty solid launcher script.
Even better, given you have the bash script at that point, use a "proper" process controller (daemontools, supervisor...) spin up the process, restart on crash, etc. | 0 | 0 | 0 | 0 | 2015-01-01T14:32:00.000 | 2 | 0 | false | 27,731,670 | 0 | 0 | 1 | 1 | I have scrapy crawler scraping thru sites. On some occasions scrapy kills itself due to RAM issues. I rewrote the spider such that it can be split and run for a site.
After the initial run, I use subprocess.Popen to submit the scrapy crawler again with new start item.
But I am getting error
ImportError: No module named shop.settingsTraceback (most recent call last):
File "/home/kumar/envs/ishop/bin/scrapy", line 4, in <module> execute()
File "/home/kumar/envs/ishop/lib/python2.7/site-packages/scrapy/cmdline.py", line 109, in execute settings = get_project_settings()
File "/home/kumar/envs/ishop/lib/python2.7/site-packages/scrapy/utils/project.py", line 60, in get_project_settings settings.setmodule(settings_module_path, priority='project')
File "/home/kumar/envs/ishop/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 109, in setmodule module = import_module(module)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name)ImportError: No module named shop.settings
The subprocess cmd is
newp = Popen(comm, stderr=filename, stdout=filename, cwd=fp, shell=True)
comm -
source /home/kumar/envs/ishop/bin/activate && cd /home/kumar/projects/usg/shop/spiders/../.. && /home/kumar/envs/ishop/bin/scrapy crawl -a category=laptop -a site=newsite -a start=2 -a numpages=10 -a split=1 'allsitespider'
cwd - /home/kumar/projects/usg
I checked sys.path and it is correct ['/home/kumar/envs/ishop/bin', '/home/kumar/envs/ishop/lib64/python27.zip', '/home/kumar/envs/ishop/lib64/python2.7', '/home/kumar/envs/ishop/lib64/python2.7/plat-linux2', '/home/kumar/envs/ishop/lib64/python2.7/lib-tk', '/home/kumar/envs/ishop/lib64/python2.7/lib-old', '/home/kumar/envs/ishop/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7', '/usr/lib/python2.7', '/home/kumar/envs/ishop/lib/python2.7/site-packages']
But looks like the import statement is using "/usr/lib64/python2.7/importlib/__init__.py" instead of my virtual env.
Where am I wrong? Help please? |
Installing python packages in virtual environment | 27,732,951 | 1 | 0 | 1,051 | 0 | python,pip,virtualenv | Either change the permissions of the virtual enviroment directory or recreate it without using sudo. | 0 | 0 | 0 | 0 | 2015-01-01T17:19:00.000 | 4 | 0.049958 | false | 27,732,911 | 1 | 0 | 1 | 3 | I'm trying to install django in a virtual environment. I'm in a virtual environment, but when i type pip install django I get a permission denied error. If I try to run sudo pip install django, however, I get sudo: pip: command not found. Not entierly sure where to go from here. |
Installing python packages in virtual environment | 27,732,983 | 0 | 0 | 1,051 | 0 | python,pip,virtualenv | This is a permissions issue and caused by how the virtual environment has been set up. The safest thing to do now is to remove the virtual environment and make sure to recreate it with the user's permissions (no sudo). And as a side note, the command not found error is due to pip not being set up for root. | 0 | 0 | 0 | 0 | 2015-01-01T17:19:00.000 | 4 | 0 | false | 27,732,911 | 1 | 0 | 1 | 3 | I'm trying to install django in a virtual environment. I'm in a virtual environment, but when i type pip install django I get a permission denied error. If I try to run sudo pip install django, however, I get sudo: pip: command not found. Not entierly sure where to go from here. |
Installing python packages in virtual environment | 27,733,194 | 2 | 0 | 1,051 | 0 | python,pip,virtualenv | Since you setup your virtual environment with sudo virtualenv /opt/myenv, you now need to run the correct pip instance (i.e. the one inside your newly created virtual environment).
Therefore, your command needs to be sudo /opt/myenv/bin/pip install django | 0 | 0 | 0 | 0 | 2015-01-01T17:19:00.000 | 4 | 0.099668 | false | 27,732,911 | 1 | 0 | 1 | 3 | I'm trying to install django in a virtual environment. I'm in a virtual environment, but when i type pip install django I get a permission denied error. If I try to run sudo pip install django, however, I get sudo: pip: command not found. Not entierly sure where to go from here. |
Django models with external DBs | 27,744,297 | 0 | 1 | 437 | 1 | python,django | I would create the minimal django models on the external databases => those that interact with your code:
Several outcomes to this
If parts of the database you're not interested in change, it won't have an impact on your app.
If the external models your using change, you probably want to be aware of that as quickly as possible (your app is likely to break in that case too).
All the relational databases queries in your code are handled by the same ORM. | 0 | 0 | 0 | 0 | 2015-01-02T12:45:00.000 | 3 | 0 | false | 27,742,457 | 0 | 0 | 1 | 1 | I have a typical Django project with one primary database where I keep all the data I need.
Suppose there is another DB somewhere with some additional information. That DB isn't directly related to my Django project so let's assume I do not even have a control under it.
The problem is that I do ont know if I need to create and maintain a model for this external DB so I could use Django's ORM. Or maybe the best solution is to use raw SQL to fetch data from external DB and then use this ifo to filter data from primary DB using ORM, or directly in views.
The solution with creating a model seems to be quite ok but the fact that DB isn't a part of my project means I am not aware of possible schema changes and looks like it's a bad practice then.
So in the end if I have some external resources like DBs that are not related to but needed for my project should I:
Try to create django models for them
Use raw SQL to get info from external DB and then use it for filtering data from the primary DB with ORM as well as using data directly in views if needed
Use raw SQL both for a primary and an external DB where they intersect in app's logic |
How to convert python time to java date | 27,745,293 | 1 | 0 | 2,695 | 0 | java,python,time | Remove the decimal point and convert it to a float. | 0 | 0 | 0 | 0 | 2015-01-02T16:28:00.000 | 3 | 0.066568 | false | 27,745,253 | 1 | 0 | 1 | 1 | I have a python date formatted like this 1418572798.498 within a string.
In Java the dates are formatted like this 1418572798498.
How to convert this string to Java date?
Is there any third party library to use for the conversion? |
How do I clear a flask session? | 27,764,937 | -42 | 37 | 74,779 | 0 | python-2.7,flask | There is no way to clear session or anything.
One must simply change the app.config["SECRET_KEY"] and the contents in session dictionary will get erased. | 0 | 0 | 0 | 0 | 2015-01-02T19:36:00.000 | 6 | 1.2 | true | 27,747,578 | 0 | 0 | 1 | 1 | While importing flask, we import modules such as session etc.
SecureCookieSession is a kind of dictionary, that can be accessed using session.
Now, I try to clear all the junk variables that I used while trying to build a website.
One of the answers on stackoverflow used a command like session.clear() for clearing the contents of a session. But such a command gives an error that no such command exists.
Can anyone point out for me how to clear the SecureCookieSession and how to clear the session every time I shutdown the server or close the website? |
Best Way to Store Large Amount of Outside API Data... using Ruby or Python | 27,761,882 | 0 | 0 | 149 | 0 | python,mysql,ruby,json,mongodb | I think this all boils down to what the most important needs are for the project. These are some of the questions I would try to answer before selecting the technology:
Will I need to access records individually after inserting into the database?
Will I ever need to aggregate the data when reading it (for reporting, for instance)?
Is it more important to the project goals to have the data written quickly or read quickly?
How large do I anticipate the data will grow and will the database technology I select scale easily, cheaply and reliably to support the data volume?
Will the schema of the data change? Do I need a schemaless database solution like MongoDB?
Where are the trade offs between development time/cost, maintenance time/cost and time/cost for running the program?
Without knowing much about the particulars or your project or its goals I would say it's generally not a good idea to store a single JSON object for the entirety of the data. This would likely make it more difficult to read the data and append to it in the future. You should probably apply some more thought on how to model your data and represent it in the database in a way that will make sense when you actually need to use it later. | 0 | 0 | 0 | 1 | 2015-01-04T02:11:00.000 | 1 | 0 | false | 27,761,684 | 1 | 0 | 1 | 1 | Im trying to design a system that can periodic "download" a large amount of data from an outside api..
This user could have around 600,000 records of data that I need once, then to check back every hour or so to reconcile both datasets.
Im thinking about doing this in python or ruby in background tasks eventually but I'm curious about how to store the data.
Would it possible/good idea to store everything in one record hashed as json vs copying each record individually?
It would be nice to be able to index or search the data without anything failing so I was wondering what would be the best implementation memory wise.
For example if the a user has 500,000 tweet records and I want to store all of them, which would be a better implementation?
one record as JSON => user_1 = {id:1 twt:"blah"},{id:2 twt:"blah"},.....{id:600,000 twt:"blah"}
vs
many records =>
id:1 outside_id=1 twt:"blah"
id:2 outside_id=1 twt:"blah"
id:3 outside_id=1 twt:"blah"
I'm curious how I would find out how memory intensive each method is or what is the best solution.
The records are alot more complex with maybe 40 attributes per record I wanted to store.
Also would MySQL or MongoDB be a better solution for fastest copy/storage? |
UnicodeDecodeError in django 1.6 and allauth | 27,787,697 | 0 | 0 | 135 | 0 | django,python-2.7,django-allauth | Problem solved: the secret key in my configuration file started with an (unicode) opening quote, instead of a regular double quote, probably a result of copying and pasting the original file that had been written with an editor that uses these "smarter" quotes. | 0 | 0 | 0 | 0 | 2015-01-05T01:56:00.000 | 1 | 0 | false | 27,772,452 | 0 | 0 | 1 | 1 | I'm trying to run a django website on my local computer. It works fine on an external server, but I didn't set it up and right now I don't have access to all the specs.
The issue I have is when I try to log in the web site as a user, which has been defined. Running in debug mode I get a detailed error page containing on top the message:
UnicodeDecodeError at /accounts/login/
'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
Looking down I can see that the error occurs in crypto.py, function salted_hmac at the line
key = hashlib.sha1((key_salt + secret).encode('utf-8')).digest()
and displaying the local variables I see
key_salt u'django.contrib.sessionsSessionStore'
secret '\xe2\x80\x9cXXX"'
value '{}'
where XXX is a 50 character string identical to the SECRET_KEY defined in my configuration file. Variable secret is assigned in the function through:
if secret is None:
secret = settings.SECRET_KEY
and I know that secret is None at this point since it is a third parameter in salted_hmac not used by the caller. I strongly suspect that the error occurs because python can not handle the unicode characters at the beginning of the variable secret.
So I have a few questions:
1) Why is setting.SECRET_KEY different from the SECRET_KEY I defined in the configuration file? Is it how it should be? And if it is do I have any control over what it should be?
2) Could something in my environment be responsible for this?
A few notes: As I mentioned it works on a server, running ubuntu 1.6, python 2.7. However I can not right now obtain the info on the versions for the other packages. But even if I could I still want to know why it doesn't work on my installation. I have tested with django 1.6.1, python 2.7 on lubuntu 14.04, opensuse 13.2, with identical results.
Thanks for any help or hint.
a |
How to create link for django filter | 60,852,547 | 0 | 2 | 2,342 | 0 | python,django,python-2.7,django-filter | maybe you try use some js solution.
just get all the current attributes from url by using js ,build dict.
when clicking other attribute button,you can add or replace the attribute in the dict.
use this dict to form your url. | 0 | 0 | 0 | 0 | 2015-01-05T11:37:00.000 | 3 | 0 | false | 27,778,737 | 0 | 0 | 1 | 1 | Scenario:
Products can have multiple attributes defined in the database, I want to be able to filter by those attributes.
Since i have not found a way to use dynamic attributes using django-filter, this is currently achieved by using django filter MethodFilter which parses the attributes passed as query string as:
/products?attribute=size_2&attribute=color_red
url like this is parsed and it works.
The problem is building the url:
I couldn't find a reasonable way to build the url, that would take current search parameters into account and add/replace those parameters.
Django seems to be forcing me to use urlconf but django-filter uses query string parameters.
What i try to achieve is this:
The user is on page /products?attribute=size_10 which display all products with that size.
When he clicks th link "color red" the new url becomes: /products?attribute=size_10&attribute=color_red
Can you point me to the django way of implementing this? |
Google Drive / App Engine for Document Management System | 27,791,624 | 0 | 1 | 1,208 | 0 | google-app-engine,google-drive-api,document-management,google-apps-for-education,google-app-engine-python | Since you'll be building your own software, the answer to "will it do what I want" is always "yes, eventually".
You'll need to make a decision about document formats, which in turn will influence your indexing mechanism. Specifically, you have two primary options:-
convert the files to Google document formats (doc, spreadsheet, etc). You will then be able to use Google's own indexing and search, eg. as you would from drive.gogle.com. The downside is that formatting may be lost during the import/export round trip.
keep the documents in their native format (eg. MS .docx), and perform your own indexing. This will require parsing each document type, which is non-trivial, but I'm sure there are third party libraries to assist. The upside is that the documents you retrieve are the identical documents you imported.
I think I would look at doing both of the above. Thus when you import a file into your DMS you store it twice into Google Drive, converted and unconverted. Use App Engine datastore to keep track of the pairings. This way you can use the Drive search to find the converted document, but the file you serve back to the user is its unconverted twin. | 0 | 1 | 0 | 0 | 2015-01-05T19:53:00.000 | 1 | 1.2 | true | 27,786,842 | 0 | 0 | 1 | 1 | I administer a University's document management system. The system is a 3rd party that integrates with another 3rd party database that acts as our ERP system. The DMS is quite clunky and has a wide array of terrible bugs / lacks features & support. I've been playing around with Google App Engine / Drive SDK in my free time out of curiosity. Since we are a Google Apps for Education customer, we have unlimited drive space and all our users are Google apps users.
Would it be feasible to internally build a web application (potentially powered by Google App Engine) that utilizes the Drive SDK to manage all the university's files (~ 6 TB). From my experimenting it seems to have all the capabilities required. |
Serve static files with Eve | 41,322,114 | 1 | 5 | 1,052 | 0 | python,flask,eve | try set import_name arg for Eve:
app = Eve(import_name=__name__) | 0 | 0 | 0 | 0 | 2015-01-06T12:36:00.000 | 3 | 0.066568 | false | 27,798,842 | 0 | 0 | 1 | 1 | I am running Flask and Eve on localhost at a same time. The Flask app serves static files and makes requests to the Eve app to get some data. I want to run Eve only, without a separate Flask app. How can I serve static files with Eve? |
epub3 : how to add the mimetype at first in archive | 28,436,076 | 0 | 0 | 1,098 | 0 | python,zip,epub,epub3 | The solution I've found:
delete the previous mimetype file
when creating the new archive create an new mimetype file before adding anything else : zipFile.writestr("mimetype", "application/epub+zip")
Why does it work : the mimetype is the same for all epub : "application/epub+zip", no need to use the original file. | 0 | 0 | 1 | 0 | 2015-01-06T13:28:00.000 | 2 | 1.2 | true | 27,799,692 | 0 | 0 | 1 | 1 | I'm working on a script to create epub from html files, but when I check my epub I have the following error : Mimetype entry missing or not the first in archive
The Mimetype is present, but it's not the first file in the epub. Any idea how to put it in first place in any case using Python ? |
Django - signals. Simple examples to start | 61,509,996 | 0 | 33 | 24,175 | 0 | python,django,django-signals | In the signals.post_save.connect(receiver=create_customer, sender=Customer)... sender will always be the model which we are defining... or we can use the User as well in the sender. | 0 | 0 | 0 | 0 | 2015-01-06T17:08:00.000 | 5 | 0 | false | 27,803,633 | 0 | 0 | 1 | 1 | I am new to Django and I'm not able to understand how to work with Django signals. Can anyone please explain "Django signals" with simple examples?
Thanks in advance. |
Python - Flask not storing session | 27,852,529 | 2 | 1 | 794 | 0 | python,session,flask | Note to self: make sure memcached is running. | 0 | 0 | 0 | 0 | 2015-01-06T22:10:00.000 | 2 | 1.2 | true | 27,808,101 | 1 | 0 | 1 | 1 | I have a Python project built using the Flask framework.
The project is established and I have installed and ran it on numerous machines (Ubuntu and OSX) using virtualenv.
I went to set up my project on a new computer with Yosemite installed. It installed all of the requirements with no errors and the site runs locally without errors.
The problem is that the Flask session is always an empty dict (nothing is ever in the session). |
Send button in yahoo mail page is not not visible - Firefox, Freebsd 7.2 | 27,815,406 | 0 | 0 | 673 | 0 | python,firefox,freebsd,yahoo-mail | Check if the button is inside an iframe. If it is then switch to frame and try it again. | 0 | 0 | 1 | 1 | 2015-01-07T07:54:00.000 | 1 | 0 | false | 27,814,764 | 0 | 0 | 1 | 1 | I have a python script that sends a mail from Yahoo including an attachment. This script runs on a Freebsd 7.2 client and uses firefox : Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.0.10) Gecko/2009072813 Firefox/3.0.10. The script fails with the error - Element xpath=//input[@value="Send"] not found. Checked the Page source, the x-Path exists. However, it is not visible in the compose page.
Kindly help me sort out this issue. |
Restricted database user for Django | 27,964,212 | 0 | 2 | 1,088 | 1 | python,django,database,postgresql,security | Yes, this is practiced sometimes, but not commonly. The best way to do it is to grant specific privileges on user, not in django. Making such restrictions means that we should not trust application, because it might change some files / data in db in the way that we do not expect it to do so.
So, to sum up: create another user able to create / modify data and user another one with restrictions to use normally.
It's also quite common in companies to create one user to insert data and another one for employees / scripts to access it. | 0 | 0 | 0 | 0 | 2015-01-07T12:50:00.000 | 3 | 0 | false | 27,819,930 | 0 | 0 | 1 | 2 | I'm running Django with Postgres database. On top of application-level security checks, I'm considering adding database-level restrictions. E.g. the application code should only be able to INSERT into log tables, and not UPDATE or DELETE from them.
I would manually create database user with appropriate grants for this. I would also need a more powerful user for running database migrations.
My question is, do people practice things like this? Any advice, best practices on using restricted database users with Django?
Edit: To clarify, there's no technical problem, I'm just interested to hear other people's experiences and takeaways. One Django-specific thing is, I'll need at least two DB users: for normal operation and for running migrations. Where do I store credentials for the more privileged user? Maybe make manage.py migrate prompt for password?
As for the reasoning, suppose my app has a SQL injection vulnerability. With privileged user, the attacker can do things like drop all tables. With a more limited user there's slightly less damage potential and afterwards there's some evidence in insert-only log tables. |
Restricted database user for Django | 27,972,123 | 1 | 2 | 1,088 | 1 | python,django,database,postgresql,security | For storing the credentials to the privileged user for management commands, when running manage.py you can use the --settings flag, which you would point to another settings file that has the other database credentials.
Example migrate command using the new settings file:
python manage.py migrate --settings=myapp.privileged_settings | 0 | 0 | 0 | 0 | 2015-01-07T12:50:00.000 | 3 | 0.066568 | false | 27,819,930 | 0 | 0 | 1 | 2 | I'm running Django with Postgres database. On top of application-level security checks, I'm considering adding database-level restrictions. E.g. the application code should only be able to INSERT into log tables, and not UPDATE or DELETE from them.
I would manually create database user with appropriate grants for this. I would also need a more powerful user for running database migrations.
My question is, do people practice things like this? Any advice, best practices on using restricted database users with Django?
Edit: To clarify, there's no technical problem, I'm just interested to hear other people's experiences and takeaways. One Django-specific thing is, I'll need at least two DB users: for normal operation and for running migrations. Where do I store credentials for the more privileged user? Maybe make manage.py migrate prompt for password?
As for the reasoning, suppose my app has a SQL injection vulnerability. With privileged user, the attacker can do things like drop all tables. With a more limited user there's slightly less damage potential and afterwards there's some evidence in insert-only log tables. |
python simple server with 3.4.2 | 31,328,765 | 0 | 0 | 192 | 0 | angularjs,python-3.4,simplehttpserver | resolved it by re-installing python on my machine. | 0 | 0 | 0 | 1 | 2015-01-07T16:09:00.000 | 1 | 1.2 | true | 27,823,606 | 0 | 0 | 1 | 1 | I'm not savvy with Python or server programming at all. My AVG blocked Python from running SimpleHTTPServer. I was able to install Python 3.4.2 successfully, but noticed that SimpleHTTPServer has been moved into HTTP server.
How can I set up my machine or Python 3.4.2 so that I can just type python -m SimpleHTTPServer when working on my AngularJS projects locally?
I'm running Windows 7 64.
Thanks, |
What are the application and request contexts? | 27,863,220 | 1 | 0 | 94 | 0 | python,flask | app.app_context loads the application and any extentions you have loaded.
A request context is loaded when you are dealing with a request.
A good example.
If you have a background cron that does some database work, you'll need to make use of app_context to get access to the models.
You'll be a in request context pretty much whenever you're handling a view. | 0 | 0 | 0 | 0 | 2015-01-08T04:32:00.000 | 1 | 1.2 | true | 27,832,993 | 0 | 0 | 1 | 1 | I'm new to Flask but have experience with PHP. I know there are session variables and global variables just as in PHP, but what do the contexts actually mean? I read the documentation but could not understand whet it was saying.
What are the application and request contexts, and what the is app.app_context()? |
How To check for environment vars during django startup | 28,414,823 | 0 | 0 | 170 | 0 | python,django,environment-variables | well, it turned out that the AppConfig is not the right spot for a task like that .. i realized my loading of secrets with a modification of the projects manage.py and im planning to release an app with all of the code in the near furture :) | 0 | 0 | 0 | 0 | 2015-01-08T06:57:00.000 | 1 | 1.2 | true | 27,834,570 | 0 | 0 | 1 | 1 | Id like to have my secret keys loaded via environment vars that shall be check on startup of my Django app. Im using an AppConfig for that purpose, because that code will be executed on startup.
For now i wrote a little helper to get the vars and a list of vars to check. Which is working fine.
The problem:
I also wrote a Django management command to help entering and storing the needed vars and save em to the users .profile, BUT when i have my checks in place the AppConfig will raise errors before i even have the chance to run my configuration command :(
So how do i enable that configuration management command whilst still having that env check run on startup?
For now im going to do a plain python script to not load Django at all (which i dont need for now anyways), but in case i might need to alter the database (and thus need Django for some setup task) how would i be able to sneak past my own startup check in my AppConf?
Where else might i be placing the checks?
I tried the main urls.py, but this will only be loaded once the first url lookup is needs and thus one might start the server and not see any errors and still the app will not work once the first url is entered in the browser. |
How can I get the PORT number when using Nginx + Tornado? | 27,880,443 | 0 | 0 | 96 | 0 | python,nginx,tornado | Each of these ports is a different python process, right? At some point you must be passing in the port number to each process and calling app.listen(port) (or one of the related bind/listen methods). Just save the port number at that time (could just be a global variable if you only have one server per process) | 0 | 1 | 0 | 0 | 2015-01-08T08:06:00.000 | 1 | 1.2 | true | 27,835,528 | 0 | 0 | 1 | 1 | Nginx make PORT 8000:8003 to Tornado server.py
I want to get the PORT number in MainHanlder and print it in the browser when someone visit my site.
And I don't want to make several copies of server.py to server8000.py, server8001.py, ..., I want just one main entrance to solve this problem.
How can I do it? |
Cloning PyQt app in django framework | 27,880,120 | 2 | 1 | 1,730 | 0 | django,python-2.7,pyqt4 | I'm not aware of any libraries to port a PyQT desktop app to a django webapp. Django certainly does nothing to enable this one way or another. I think, you'll find that you have to rewrite it for the web. Django is a great framework and depending on the complexity of your app, it might not be too difficult. If you haven't done much with web development, there is a lot to learn!
If it seemed like common sense to you that you should be able to run a desktop app as a webapp, consider this:
Almost all web communication that you likely encounter is done via HTTP. HTTP is a protocol for passing data between servers and clients (often, browsers). What this means is that any communication that takes place must be resolved into discrete chunks. Consider an example flow:
You go to google in your browser.
Your browser then hits a DNS server (or cache) that resolves the name google.com to some IP address.
Cool, now your browser makes a request to that IP address and says "get me some stuff".
Google decides to send you back a minimal amount of HTML and lots of minified JavaScript in the page.
Your browser realizes that there are some image links in the HTML and so it makes additional requests to google to get each of the images so that it can display them.
Now all the content is loaded on your browser so it starts to execute the JavaScript code, and that code needs some more data from google so it starts sending requests to google too.
This is just a small example of how fundamentally different a web application operates than how a desktop application does. On a desktop app you have the added convenience that any operation doesn't need to be "packaged up" and sent, then have an action taken, etc (unless you're using a messaging architecture, but that's relatively uncommon outside of enterprise apps). | 1 | 0 | 0 | 0 | 2015-01-10T18:52:00.000 | 1 | 1.2 | true | 27,879,952 | 0 | 0 | 1 | 1 | I've designed a desktop app using PyQt GUI toolkit and now I need to embed this app on my Django website. Do I need to clone it using django's own logic or is there a way to get it up on website using some interface. Coz I need this to work on my website same way it works as desktop. Do I need to find out packages in django to remake it over the web or is there way to simplify the task?
Please help. |
Clients uploading to database | 27,885,848 | 1 | 0 | 70 | 1 | python,postgresql,security,csv | The script makes a POST request to your Django web server either with login/pwd or unique string.
The web server validates credentials and inserts data into DB. | 0 | 0 | 0 | 0 | 2015-01-11T09:46:00.000 | 2 | 0.099668 | false | 27,885,733 | 0 | 0 | 1 | 1 | I have a python script set up that captures game data from users while the game is being played. The end goal of this is to get all that data, from every user, into a postgresql database on my web server where it can all be collated and displayed via django
The way I see it, I have 2 options to accomplish this:
While the python script is running, I can directly open a connection to the db and upload to it in real time
During the game session, instead of uploading to the db directly, I can save out a csv file to their computer and have a separate app that will find these log files and upload them to the db at a later point
I like (1) because it means these log files cannot be tampered with by the user as it is going straight to the db - therefore we can prevent forgery and ensure valid data.
I like (2) because the initial python script is something that every user would have on their computer, which means they can open it at will (it must be this way for it to work with the game). In other words, if I went with (1) users would be exposed to the user/pass details for connecting to the db which is not secure. With (2) the app can just be an exe where you cant see the source code and cant see the db login details
My questions:
So in one case I'd be exposing login details, in the other I'd be risking end users tampering with csv files before uploading. Is there a method that could combine the pros of the 2 methods without having to deal with the cons?
At the very least, if I had to choose either of these 2 methods, whats the best way to get around its downfall? So is it possible to prevent exposing db credentials in a publicly available python script? And if I have to save out csv files, is there a way to prevent tampering or checking if it has been tampered with? |
Django i18n pattern | 27,913,910 | 0 | 1 | 436 | 0 | python,django,internationalization,django-i18n | What you are experiencing is that your language selection is not sticking as it should and so to do this there are a few things to check.
My guess is that you have 'en' as your LANGUAGE_CODE in your settings so that will always be your fallback. Quite often the reason that you cannot get your language to stick is that you may not have the correct middleware in your settings MIDDLEWARE_CLASSES.
Try the following checklist to see if you have everything you need:
Add SessionMiddleware and LocaleMiddleware to your middleware stack in your settings, ensure the SessionMiddleware comes before LocaleMiddleware as it relies on the use of sessions and it is responsible for fetching your desired language from a request via the url/session/cookie/request header in that order I believe, then uses your fallback language if all else fails.
Ensure all languages that you want to serve are in your LANGUAGES list in settings
That should hopefully do the trick so hope that helps. | 0 | 0 | 0 | 0 | 2015-01-12T23:29:00.000 | 3 | 0 | false | 27,912,563 | 0 | 0 | 1 | 1 | I'm using internationalization.
So, everyhting works fine, when I access http://localhost:8000/en/ and http://localhost:8000/de/
But when I access http://localhost:8000/ it redirects me to http://localhost:8000/en/ even when the last accessed page was http://localhost:8000/de/
Basically, I want to save language code, based on the page accessed, e.g. if I access http://localhost:8000/de/ then language is german. Next, when I access http://localhost:8000, it should point me to http://localhost:8000/de/, not default http://localhost:8000/en/
How this can be done? |
Backup Odoo db from within odoo | 28,070,202 | 1 | 13 | 4,840 | 1 | python,openerp,odoo | You can use a private browser session to access the Database menu, from the login screen, and perform the the backup form there (you need to know the master password to access that, defined in the server configuration file). | 0 | 0 | 0 | 0 | 2015-01-14T04:11:00.000 | 9 | 0.022219 | false | 27,935,745 | 0 | 0 | 1 | 1 | I need to backup the current db while logged into odoo. I should be able to do it using a button, so that suppose I click on the button, it works the same way as odoo default backup in manage databases, but I should be able to do it from within while logged in.
Is there any way to achieve this? I do know that this is possible from outside odoo using bash but thats not what I want. |
Should I allow users to manage their profile using the admin application? | 27,936,097 | 2 | 0 | 50 | 0 | python,django,django-admin | You can code the "member area" to be much more user-friendly than Django's admin, inevitably very general purpose. You can carefully restrict exactly what a user can change, saving them from mistakes that could be damaging and hard to fix, add more sanity checks too.
All in all, I'd say that, while more work, coding your own "member area" is a far superior option than trying to shoehorn things into the (inevitably!) "one size fits all" Django admin arrangements. | 0 | 0 | 0 | 0 | 2015-01-14T04:43:00.000 | 2 | 1.2 | true | 27,936,012 | 0 | 0 | 1 | 2 | Maybe my question can sound a little bit stupid but it's a real one.
I'm doing an ecommerce website, so as an admin I directly use the one provided by django, to manage my article and user.
But, what's the best for my user? Should I let them use the admin panel to manage their profile? (I saw I can manage who can do what on the admin panel). Or should i create a small member area to let them manage their account? |
Should I allow users to manage their profile using the admin application? | 28,121,019 | 0 | 0 | 50 | 0 | python,django,django-admin | Alternatively, you can make these users as 'superusers' in admin, to manage.
And you can override view in admin to make it more friendly. Good luck! | 0 | 0 | 0 | 0 | 2015-01-14T04:43:00.000 | 2 | 0 | false | 27,936,012 | 0 | 0 | 1 | 2 | Maybe my question can sound a little bit stupid but it's a real one.
I'm doing an ecommerce website, so as an admin I directly use the one provided by django, to manage my article and user.
But, what's the best for my user? Should I let them use the admin panel to manage their profile? (I saw I can manage who can do what on the admin panel). Or should i create a small member area to let them manage their account? |
Is it possible to have an absolute href attribute with no scheme? | 27,955,487 | 2 | 0 | 173 | 0 | python,html,tags,uri,url-scheme | If you don't include the URI scheme (http://, https://, //, etc) then the browser will assume it to be a relative URL.
You should be aware of scheme-relative URLs like //www.google.com for your script. In short your should look for a double forward slash // to figure out whether or not a URL will be treated as relative or not. | 0 | 0 | 1 | 0 | 2015-01-15T01:29:00.000 | 2 | 1.2 | true | 27,955,463 | 0 | 0 | 1 | 1 | I'm trying to find a way to test whether a URL is absolute or relative in Python. In the href attribute of an HTML tag, is the lack of a scheme (e.g. http, ftp, etc.) sufficient to mark a URL as relative, or is it possible to have an absolute URL as a href attribute without explicitly specifying the scheme (e.g. 'www.google.com')? I'm getting the scheme by using urlparse.urlparse('some url').scheme. |
Java/python using processBuilder | 27,969,431 | 0 | 1 | 266 | 0 | java,python,processbuilder,inter-process-communicat | From your scenario, you are looking for inter process communication.
You can achieve this using shared file. Your python script will write the output in text file, and your java program will read the same file. | 0 | 0 | 0 | 0 | 2015-01-15T01:51:00.000 | 1 | 0 | false | 27,955,622 | 0 | 0 | 1 | 1 | Good evening all,
am running a python script inside java using processBuilder.
the python script returns a list and i dont know how to get it java and use it since all i can do for the moment with process builder is print errors or outputs.
is it possible to get the list in java as well.
Many thanks |
django run localhost from another computer connected to another network | 60,644,419 | 0 | 6 | 8,099 | 0 | python,django,localhost | If you're working DEBUG=True mod in your Django project, you shouldn't need anything other than that (I assume you are not using port 80, it requires root access).
You must use 0.0.0.0 as host IP, it is a simple solution. And the command is:
python manage.py runserver 0.0.0.0:8000. That's it. | 0 | 0 | 0 | 0 | 2015-01-15T04:56:00.000 | 3 | 0 | false | 27,957,035 | 0 | 0 | 1 | 1 | I am running my django project in localhost and it works fine..
For test purpose I want to run my localhost from another computer connected in the same network.
I have done python manage.py runserver 'my ip address'
That works fine too.. Is there any way that I can access my localhost from another computer connected to another network?
Like I am connected to A network and running my localhost and my friend is connected to B network. Suppose he wants to access my localhost and see my project running then is it possible to access localhost of a computer from another computer connected to another project? |
In the PayPal REST API, how can I get payer information from a newly executed BillingAgreement? | 27,989,541 | 2 | 1 | 555 | 0 | python,rest,paypal | Got a reply from PayPal support. Apparently you can take the same token you pass to BillingAgreement.execute() and pass it to GetExpressCheckoutDetails in their classic API. I tried it and it works. It means you have to use both APIs (which we weren't planning to do) and store both API auth info, which is annoying. Hopefully they'll fix it someday, but if it's been high-priority for two months I'm not holding my breath. | 0 | 0 | 1 | 0 | 2015-01-15T20:32:00.000 | 1 | 0.379949 | false | 27,972,459 | 0 | 0 | 1 | 1 | Let's say I have a billing agreement, which I just executed on the callback from the PayPal site:
resource = BillingAgreement.execute(token)
The resource returned does not have any payer information (name, email, etc). I can use the ID to load the full BillingAgreement:
billing_agreement = BillingAgreement.find(resource.id)
That returns successfully, but the resulting object also lacks an payer info.
This seems like a critical oversight in the REST API's design. If I just got a user to sign up for a subscription, don't I need to know who they are? How else will I send them a confirmation email, allow them to cancel later, etc?
Thanks for the help! |
Is client side validation nessesary in Django? | 27,976,034 | 2 | 3 | 1,963 | 0 | python,django,validation | Client side validation may improve user experience (less page reloads). It may decrease number of hits to he server (but sometimes this number is increased :). But it is not necessary.
Anyway server side validation is a must. You can't trust data from user input. | 0 | 0 | 0 | 0 | 2015-01-16T01:27:00.000 | 3 | 1.2 | true | 27,975,963 | 0 | 0 | 1 | 2 | I am writing a Django app, and am wondering if any client side validation is necessary. Django handles all validation through forms in python on the backend. If something validates wrong, the user is returned to the screen with all their information still there.
I can't see any reason I need to implement client side validation in Django? Is this true? The only reason I can think of is it would save a few hits to the server, but this seems negligible. |
Is client side validation nessesary in Django? | 27,976,103 | 3 | 3 | 1,963 | 0 | python,django,validation | If you have a web application that faces the public internet client side, validation is pretty much a user expectation. You might be able to ignore this if volume is low and people are motivated to use your website.
For an company intranet site, the additional development cost may weigh against client side validation. However, if you use an available client framework (e.g. jquery or django-parsley) the additional cost for client side validation is actually fairly small and likely worth the effort in intraweb applications.
ADDED
Yes, as others had already stated client-side only validation is very bad as it is the same as no validation -- you can coerce the browser to send whatever you want back to the server.
You can do also do lots of nice things client side that you cannot server side. Sometimes these are closely related to client side validation.
E.g., limiting a comment to 500 characters. With client side code you can display a characters remaining count on screen -- with a little planning this can be integrated with the validation code. | 0 | 0 | 0 | 0 | 2015-01-16T01:27:00.000 | 3 | 0.197375 | false | 27,975,963 | 0 | 0 | 1 | 2 | I am writing a Django app, and am wondering if any client side validation is necessary. Django handles all validation through forms in python on the backend. If something validates wrong, the user is returned to the screen with all their information still there.
I can't see any reason I need to implement client side validation in Django? Is this true? The only reason I can think of is it would save a few hits to the server, but this seems negligible. |
PDFKit with python on Ubuntu | 29,774,518 | 0 | 0 | 487 | 0 | python,ubuntu,pdf-generation,pdfkit | I found the solution. The problem was that I didn't close .colse() the file before the initialisation of the pdfkit | 0 | 0 | 0 | 1 | 2015-01-16T21:52:00.000 | 1 | 0 | false | 27,993,383 | 0 | 0 | 1 | 1 | I have a very strange problem. I have a script written in python which is generating an html report then I convert it using pdfkit to pdf . The script is working just fine on MAC and the pdf is generated normally. When I tried to install the same script on Ubuntu I got the following upnormal behavior:
The html file is fully generated
The pdf file is generated but without the last 2 pages
when I tried to convert the either through wkhtmlto pdf command or through the python (outside the script) I got the right PDF form. Any idea why I'm examining this behavior ? |
Embed Python code on a webpage | 27,994,687 | 0 | 0 | 273 | 0 | python,web | Recommend flask. I've just done something like this. Only need a few lines of python code and a few lines of html code. No more than 30 lines.
Write a html page which has an input and a button. When the page gets an input and the button gets hit, a python script will be invoked. And then result will be rendered to a new page. | 0 | 0 | 0 | 0 | 2015-01-16T23:49:00.000 | 2 | 0 | false | 27,994,576 | 0 | 0 | 1 | 1 | Is there an easy, simple way to embed python code in a webpage; i.e., have an embedded app where viewers input numbers and a python code is run and an output is spit out? I don't really want to learn Django just for one project, but if there's no other way, I might have to. |
Login and registration example in Django with different user table | 27,999,374 | 3 | 1 | 1,284 | 0 | python,django | You can specify different permissions in the auth_user table using the is_superuser and is_staff boolean attributes in the model.
Maintaining the session and permissions is easier if you use the auth_user table | 0 | 0 | 0 | 0 | 2015-01-17T09:57:00.000 | 2 | 0.291313 | false | 27,998,297 | 0 | 0 | 1 | 1 | I am quite new to Django, I need a example code for creating login and registration form and a default page which a user can see only after logged in.
Here important thing is that i want to use different table for users other than the auth_user table for admin. These users can logged in and able to perform some functionality.
Please suggest me if its best way to have different table users for such customers? Or i can use the same auth_user table. |
running django python 3.4 on mod_wsgi with apache2 | 28,044,520 | 0 | 6 | 5,696 | 0 | django,apache,python-3.x,mod-wsgi | Thanks guys,
I actually fixed the issue myself this morning by running the make install of mod_wsgi with .configure pointing to python3.4.
I think you were right Adam. | 0 | 0 | 0 | 1 | 2015-01-19T06:51:00.000 | 3 | 0 | false | 28,019,310 | 0 | 0 | 1 | 3 | Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django.
My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto.
ImportError at / cannot import name _imaging Request
Method: GET Request URL: Django Version: 1.7.3
Exception Type: ImportError Exception Value: cannot import
name _imaging Exception
Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in
, line 63 Python Executable: /usr/bin/python Python
Version: 2.7.6 Python Path: ['/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages', '/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages'] |
running django python 3.4 on mod_wsgi with apache2 | 28,038,045 | 9 | 6 | 5,696 | 0 | django,apache,python-3.x,mod-wsgi | I believe that mod_wsgi is compiled against a specific version of python, so you need a py3.4 version of mod_wsgi. You may be able to get one from your os's package repository or you can build one without too much drama. From memory you'll need gcc and python-dev packages (python3-dev?) to build.
OK, quick google, for ubuntu 14.10: sudo apt-get install libapache2-mod-wsgi-py3 should install a py3 version of mod_wsgi (will probably want to remove the existing py2 version).
Adding a shebang line won't do any good as the python interpreter is already loaded before the wsgi.py script is read. | 0 | 0 | 0 | 1 | 2015-01-19T06:51:00.000 | 3 | 1.2 | true | 28,019,310 | 0 | 0 | 1 | 3 | Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django.
My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto.
ImportError at / cannot import name _imaging Request
Method: GET Request URL: Django Version: 1.7.3
Exception Type: ImportError Exception Value: cannot import
name _imaging Exception
Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in
, line 63 Python Executable: /usr/bin/python Python
Version: 2.7.6 Python Path: ['/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages', '/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages'] |
running django python 3.4 on mod_wsgi with apache2 | 28,032,221 | 0 | 6 | 5,696 | 0 | django,apache,python-3.x,mod-wsgi | From what I see here your application is using py2 interpreter with py3 compiled modules, which is no-go.
One simple possible solution that comes me in mind is to add or change first line of manage.py to #!/usr/bin/python3. This will tell script to be interpreted with py3.
Next on guess list would be misconfiguration in *.wsgi file or apache config, whichever you are using. | 0 | 0 | 0 | 1 | 2015-01-19T06:51:00.000 | 3 | 0 | false | 28,019,310 | 0 | 0 | 1 | 3 | Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django.
My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto.
ImportError at / cannot import name _imaging Request
Method: GET Request URL: Django Version: 1.7.3
Exception Type: ImportError Exception Value: cannot import
name _imaging Exception
Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in
, line 63 Python Executable: /usr/bin/python Python
Version: 2.7.6 Python Path: ['/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages', '/var/www/blabla',
'/usr/local/lib/python3.4/dist-packages'] |
Django Navigation from Template-Login to a self written index.html | 28,024,750 | 0 | 0 | 85 | 0 | python,django,login,navigation | 1: create your own view that the login button take the person to when clicked and load your index.html template. you do not have to use the built in login.
2: logo? you can use any logo/format you want. Django doesn't come with a template that creates the look of the site (beside the admin one); so you need to create it. | 0 | 0 | 0 | 0 | 2015-01-19T12:26:00.000 | 2 | 0 | false | 28,024,651 | 0 | 0 | 1 | 2 | Im using the Django template login and want to navigate from the login to my own written index.html file.
so if a user push the "login" button the result page is my index file.
My second question is how to use logos in django python and what structure i need in my project.
best regards |
Django Navigation from Template-Login to a self written index.html | 28,028,387 | 0 | 0 | 85 | 0 | python,django,login,navigation | create custom log-in and registration in your project, and write the custom back-end if you have more user ,if request is came from user to log-in then redirect to index,html, | 0 | 0 | 0 | 0 | 2015-01-19T12:26:00.000 | 2 | 0 | false | 28,024,651 | 0 | 0 | 1 | 2 | Im using the Django template login and want to navigate from the login to my own written index.html file.
so if a user push the "login" button the result page is my index file.
My second question is how to use logos in django python and what structure i need in my project.
best regards |
Should I be adding the Django migration files in the .gitignore file? | 68,283,683 | 1 | 187 | 78,791 | 0 | python,django,git | You should think of migrations as a version control system for your database schema. makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.
The migration files for each app live in a “migrations” directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your development machine and then running the same migrations on your colleagues’ machines, your staging machines, and eventually your production machines.
golden rule : Make once on dev and migrate on all | 0 | 0 | 0 | 0 | 2015-01-19T23:10:00.000 | 10 | 0.019997 | false | 28,035,119 | 0 | 0 | 1 | 5 | Should I be adding the Django migration files in the .gitignore file?
I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.
If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file? |
Should I be adding the Django migration files in the .gitignore file? | 56,424,456 | 3 | 187 | 78,791 | 0 | python,django,git | Gitignore the migrations, if You have separate DBs for Development, Staging and Production environment. For dev. purposes You can use local sqlite DB and play with migrations locally.
I would recommend You to create four additional branches:
Master - Clean fresh code without migrations. Nobody is connected to this branch. Used for code reviews only
Development - daily development. Push/pull accepted. Each developer is working on sqlite DB
Cloud_DEV_env - remote cloud/server DEV environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Dev database
Cloud_STAG_env - remote cloud/server STAG environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Stag database
Cloud_PROD_env - remote cloud/server DEV environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Prod database
Notes:
2, 3, 4 - migrations can be kept in repos but there should be strict rules of pull requests merging, so we decided to find a person, responsible for deployments, so the only guy who has all the migration files - our deploy-er. He keeps the remote DB migrations each time we have any changes in Models. | 0 | 0 | 0 | 0 | 2015-01-19T23:10:00.000 | 10 | 0.059928 | false | 28,035,119 | 0 | 0 | 1 | 5 | Should I be adding the Django migration files in the .gitignore file?
I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.
If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file? |
Should I be adding the Django migration files in the .gitignore file? | 52,187,013 | 1 | 187 | 78,791 | 0 | python,django,git | Having a bunch of migration files in git is messy. There is only one file in migration folder that you should not ignore. That file is init.py file, If you ignore it, python will no longer look for submodules inside the directory, so any attempts to import the modules will fail. So the question should be how to ignore all migration files but init.py?
The solution is:
Add '0*.py' to .gitignore files and it does the job perfectly.
Hope this helps someone. | 0 | 0 | 0 | 0 | 2015-01-19T23:10:00.000 | 10 | 0.019997 | false | 28,035,119 | 0 | 0 | 1 | 5 | Should I be adding the Django migration files in the .gitignore file?
I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.
If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file? |
Should I be adding the Django migration files in the .gitignore file? | 37,484,659 | 4 | 187 | 78,791 | 0 | python,django,git | I can't imagine why you would be getting conflicts, unless you're editing the migrations somehow? That usually ends badly - if someone misses some intermediate commits then they won't be upgrading from the correct version, and their copy of the database will be corrupted.
The process that I follow is pretty simple - whenever you change the models for an app, you also commit a migration, and then that migration doesn't change - if you need something different in the model, then you change the model and commit a new migration alongside your changes.
In greenfield projects, you can often delete the migrations and start over from scratch with a 0001_ migration when you release, but if you have production code, then you can't (though you can squash migrations down into one). | 0 | 0 | 0 | 0 | 2015-01-19T23:10:00.000 | 10 | 0.07983 | false | 28,035,119 | 0 | 0 | 1 | 5 | Should I be adding the Django migration files in the .gitignore file?
I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.
If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file? |
Should I be adding the Django migration files in the .gitignore file? | 45,315,509 | 5 | 187 | 78,791 | 0 | python,django,git | The solution usually used, is that, before anything is merged into master, the developer must pull any remote changes. If there's a conflict in migration versions, he should rename his local migration (the remote one has been run by other devs, and, potentially, in production), to N+1.
During development it might be okay to just not-commit migrations (don't add an ignore though, just don't add them). But once you've gone into production, you'll need them in order to keep the schema in sync with model changes.
You then need to edit the file, and change the dependencies to the latest remote version.
This works for Django migrations, as well as other similar apps (sqlalchemy+alembic, RoR, etc). | 0 | 0 | 0 | 0 | 2015-01-19T23:10:00.000 | 10 | 0.099668 | false | 28,035,119 | 0 | 0 | 1 | 5 | Should I be adding the Django migration files in the .gitignore file?
I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore.
If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file? |
Python Client side tool( should work in browser) to extract values from a pfx file and sign it | 28,065,519 | 1 | 1 | 146 | 0 | python,python-2.7,openssl,pycrypto,brython | So, first things first: it is not usueal to have the same code to run on server side and client side.
Second thing: be aware that no authentication (or "signing") done on client side can be regarded as safe. At most, the client side can take care of closely coupling the signing with the UI to give the user dynamic feedback - but since whatever requests the client side send to the server can very easily be impersonated by an script, authentication must be performed server side for each request - for example, a variable saying the current user has authenticated correctly can just be sent as "True", regardless of usernames and passwords actually known.
Third thing: despite all this, since there are these frameworks for using Python or a Python like language client side, it is indeed possible to have some modules in a code base that are used both client side and server side. Of those, I am most familiar with Brython which has achieved a nice level of Python 3.x compatibility and I indeed have a project sharing code client side and server side.
The re-used code would have to be refactored to abstract any I/O (like getting user input, or getting values from a database), of couse, since these are fundamentally different things on server side, and client side. Still, some core logic can be in place that is reused both sides.
However third party python modules, like Pycrypto won't work client side (you could probably code a xmlrpc/jsonrpc like call to use it server side) -
and although Python's hashlib is not implemented now in Brython, the project has got a momentum that opening a feature request for at least the same codecs that exist in javascript could be fulfilled in a matter of days.
(bugs/features requests can be open at github.com/brython-dev/brython)
(PS. I just found out, to my dismay, that currently there is no standard way to compute any hash, not even md5, in Javascript without third party modules - that just emphasize the utilities of frameworks like Brython or coffescript which can bring up a bundle of functionality in a clean way) | 0 | 0 | 1 | 0 | 2015-01-20T05:30:00.000 | 1 | 0.197375 | false | 28,038,384 | 0 | 0 | 1 | 1 | Client side tool to extract values such as common name serial number and public key from pfx file which is loaded by client, and then sign the public key and send to server..
I have completed the backend python code which will import modules from OpenSSL.Crypto library..
How to execute the same in client side?.. i.e signing operation should be done in client side,
In google i found like Brython, skulpt, pyjams help in this.. But i m confused to start.. Any suggestions? |
get_or_create: is it a 'get' or a 'create'? | 28,041,761 | 1 | 0 | 3,290 | 0 | python,peewee | According to source code, no way to find out. Also, according to documentation, it is not recommended to use this method.
I suggest to use try/except/else clause. | 0 | 0 | 0 | 0 | 2015-01-20T09:11:00.000 | 3 | 1.2 | true | 28,041,429 | 0 | 0 | 1 | 1 | AFAIK, peewee's Model.get_or_create() doesn't return a flag that indicates a creation, unlike django's get_or_create(). Is there a good way to check if an instance returned by get_or_create() is freshly created?
Thanks |
Does django store instance values before changing it by default | 28,045,449 | 0 | 0 | 42 | 0 | python,django,versioning | As an other answer mentions, Django doesn't store old values by default. You can do this yourself by grabbing the old value and storing it to another attribute on your model on save. | 0 | 0 | 0 | 0 | 2015-01-20T09:53:00.000 | 2 | 0 | false | 28,042,290 | 0 | 0 | 1 | 1 | For a model instance does Django store the model instance value by default that I could retrieve before it has been changed? Example I would like to get the status(model attribute) changed for a given date? I am able to check the attribute from LogEntry, But is there some default which stores the actual old value that can be retrieved before the status value had been changed? I am aware of versioning add ons in django. |
django work with a Thermal Printer in Raspberry PI | 28,060,170 | 0 | 0 | 349 | 0 | python,linux,django,printing,raspberry-pi | install a print server on the pi and serve the printer. you may need some sort of tunnel so that the VPS can reach the pi. | 0 | 0 | 0 | 1 | 2015-01-21T05:00:00.000 | 1 | 0 | false | 28,059,937 | 0 | 0 | 1 | 1 | I have a website in django, I only going to visit the website using a Raspberry Pi, I need print a data, and for print I am using a Thermal Printer in the Raspberry Pi.
I can print from the Raspberry pi using
("/dev/ttyAMA0",19200,timeout=5)
for obtain serial communication
This work fine but only when the project is hosting local in the raspberry Pi , but the django project is hosting in a VPS with ubuntu then I have problems for printer from the Raspberry PI.
because in ubuntu there are not
"/dev/ttyAMA0"
How I can work with this thermal Printer from a django project for print correctly using a RaspberryPi |
AMPPS Yosemite Python configuration | 28,284,966 | 1 | 0 | 259 | 0 | python,macos,apache,ampps | As far as I can tell, AMPPS does not work on Yosemite at all (@ v2.8) | 0 | 0 | 0 | 0 | 2015-01-21T09:14:00.000 | 1 | 1.2 | true | 28,063,378 | 0 | 0 | 1 | 1 | I am have just recently acquired a new Mac (Yosemite OSX 10.10) I am reconfiguring everything and I need to work with external configs and Python on some new projects. Which bring me to two additional question:
how to include an extra configuration with an external config file ? can I just include it to the httpd.conf of Apache from Ampps GUI? would I need to do additional settings in the Admin Panel ?
how do I set up the mod_wsgi in Ampps, is there a specific set of actions to trigger ? will I need some specific workflow to get it to work with my external config (bunch of virtual hosts in which some application run on Python)
Thanks in advance. |
Odoo - Write null to numeric column | 28,069,999 | 7 | 8 | 4,136 | 0 | python,mysql,openerp-7,odoo | You can't: the Odoo ORM does not support null numeric values.
If you really need to distinguish an "empty" value from a zero value, you need a workaround: either use a string field (simpler, but needs additional checks to allow only number and it's harder to perform calculations) or use a second boolean field to mark empty values. | 0 | 0 | 0 | 0 | 2015-01-21T14:19:00.000 | 1 | 1.2 | true | 28,069,439 | 0 | 0 | 1 | 1 | In Odoo/OpenERP 7, I have a nullable numeric column called balance
'balance': fields.float(string='Balance',digits=(20,2))
I am trying to use Python code to update None into the field
self.write(cr, uid, [1], { 'balance':None })
but, rather frustratingly, Python treats None the same as 0 so I end up with 0 in the DB instead of the expected Null.
Any pointers on how I can use the write command to store a null value? |
How do I make my django application perform a job at a fixed time everyday? | 28,076,369 | 2 | 0 | 140 | 0 | python,django,scheduled-tasks,celery,django-celery | Use a simple cron job to trigger a custom Django management command. | 0 | 0 | 0 | 0 | 2015-01-21T20:34:00.000 | 2 | 0.197375 | false | 28,076,316 | 0 | 0 | 1 | 2 | Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired.
While I can definitely write the function, how do I make Django run at everyday at a fixed time?
I have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in? |
How do I make my django application perform a job at a fixed time everyday? | 28,076,358 | -1 | 0 | 140 | 0 | python,django,scheduled-tasks,celery,django-celery | Use a threading.Thread to schedule a continuous event loop. In your thread, use time.sleep to create a gap before the next occurrence of the event. | 0 | 0 | 0 | 0 | 2015-01-21T20:34:00.000 | 2 | -0.099668 | false | 28,076,316 | 0 | 0 | 1 | 2 | Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired.
While I can definitely write the function, how do I make Django run at everyday at a fixed time?
I have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in? |
How to handle static/media file permission on flask? | 28,084,606 | 2 | 1 | 1,641 | 0 | python,nginx,flask | Serve your image through Flask instead of your web server, treat it like any other url with permissions. Nginx is obviously a much better choice to serve your static files but it won't integrate with Flask. | 0 | 0 | 0 | 0 | 2015-01-22T08:20:00.000 | 2 | 0.197375 | false | 28,084,065 | 0 | 0 | 1 | 1 | I've created an application in which media files(files that are uploaded by users, not css/js) are served statically by another server on the subdomain like: media.example.com/path/to/image.jpg. How can I limit access to the images so that only certain people who are logged in and have permission can see them?
Please note that persmissions on page in which an image is displayed are working but I want to further limit access to the images themselves so image urls can't be shared.
Thanks |
Django password_change_done viewable only on redirect from password_change view (on succesful password change) | 28,103,925 | 0 | 0 | 100 | 0 | python,django,django-forms,django-templates,django-views | Probably the best way to do that is to use the session:
When the password_change view is valid and before redirecting to the password_change_done view, just set a password_changed session attribute to True, something like this:
request.session['password_changed'] = True
After that, in your password_change_done view, check if password_changed is True and only then actually display the view, something like:
if request.session.get('password_changed'):
# render password_change_done view
else:
# redirect to the password_change view | 0 | 0 | 0 | 0 | 2015-01-23T05:06:00.000 | 1 | 0 | false | 28,103,374 | 0 | 0 | 1 | 1 | I require the password_change_done url to be visible only when the password_change view redirects to it (on successful change of password). Otherwise on going to the password_change_done view, it must redirect to the password_change view
How can this be done? |
Django: calling a function before session expires | 28,107,498 | 2 | 0 | 312 | 0 | python,django,function,session | You can't.
This question betrays a fundamental misunderstanding of how both sessions and web applications work. Web code is stateless; there is nothing "running" for any user in between the requests that user makes. If a user doesn't make any requests for longer than the session timeout, the only time the server code knows about it is the next time they actually do make a request: at which point the code will compare the last request time with the current time and either treat the session as valid or expired. If the user goes away and never comes back, there is simply no way the server will ever know. | 0 | 0 | 0 | 0 | 2015-01-23T09:36:00.000 | 1 | 1.2 | true | 28,106,854 | 0 | 0 | 1 | 1 | So i'm using the request.session.set_expiry(NUMBER_OF_SECONDS) in order to check if the user of my webpage has been inactive for a number of seconds and clossing the session when it happens. The problem is that i want to call a function for doing some things jsut before the session expires and i don't know how can I do that.
Thanks in advance! |
How to send an HTTP PUT request using urllib2 or requests | 28,115,962 | 0 | 0 | 831 | 0 | django,python-2.7 | Found the answer:
req = urllib2.Request(url=your_url, data=your_data)
req.get_method = lambda: 'PUT' | 0 | 0 | 1 | 0 | 2015-01-23T17:10:00.000 | 1 | 0 | false | 28,115,111 | 0 | 0 | 1 | 1 | In my Django app I need to send an HTTP PUT request to a url.
What is the proper syntax for that? |
DjangoCMS: how to auto-add default plugins in placeholders | 29,008,788 | 0 | 3 | 790 | 0 | python,django,django-cms | One more hint: static placeholders are good for this purposes. | 0 | 0 | 0 | 0 | 2015-01-24T11:32:00.000 | 3 | 0 | false | 28,125,037 | 0 | 0 | 1 | 1 | I have a few placeholders in my DjangoCMS template (par example, header, contetent and footer). I want to automatically populate any newly-created pages with default items: header placeholder with header plugin and footer placeholder with footer plugin.
How can it be done? |
Duplicating an entire Django project | 28,133,201 | 3 | 0 | 1,706 | 0 | python,django | Properly written django project will work from any directory. The only thing you need to change is the database settings and, may be, some paths in settings.py. | 0 | 0 | 0 | 0 | 2015-01-25T04:18:00.000 | 1 | 1.2 | true | 28,133,177 | 0 | 0 | 1 | 1 | Is it possible to duplicate an entire Django project and rename it?
For example, let's say Client1 asks me for a Django project. I would name the entire project Client1. Client2 now comes and asks for the exact same file. Can I simply copy and paste Client1's project and rename it to Client2, or do I need to rename a few other things?
Thank you in advance for the clarification! |
How to fill data in a base html file Django | 28,135,065 | 0 | 0 | 77 | 0 | python,html,django | Yes. You need to use Context Processor. Google "django context procoessor" it'll come up with many results. | 0 | 0 | 0 | 0 | 2015-01-25T09:40:00.000 | 2 | 0 | false | 28,135,050 | 0 | 0 | 1 | 1 | I have a base html file (for which code shouldn't be necessary) that requires some tags in the menu to be filled with id numbers (which are dynamic, and can't be hard coded). It seems to me that writing code to populate the tags for each view violates the DRY principle, and as such there should be some way to provide variables to a base html document. How does one do this, if it's possible? |
Bottle, how to get_cookie during AJAX request (same domain) | 28,137,747 | 1 | 1 | 167 | 0 | ajax,python-3.x,cookies,xmlhttprequest,bottle | I tried to set_cookies('test', 123, secret='mysecret') under AJAX request, it worked, but still couldn't find previous cookies.
Then I remarked that my previous cookies, called cook1 and cook2, written under 'normal' http request, if they had same domain, had different 'path' (under Chrome ressource explorer). They were set under path '/XXX/dev' and my AJAX request was just under path '/XXX'
So I modified my AJAX request from /XXX/do_stuff to point to '/XXX/dev/do_stuff', and then, surprise ! cook1 and cook2 could be read by my AJAX request.
Not sure if it's a Bottle bug or if such behaviour is designed on purpose (in this case, if someone can explain to me why...), but at least I have my solution. | 0 | 0 | 0 | 0 | 2015-01-25T11:52:00.000 | 2 | 0.099668 | false | 28,136,063 | 0 | 0 | 1 | 1 | I use bottle set/get cookie mecanism to track my user_id (with 'secret' param when calling set/get_cookie()
During normal http(s) request everything is fine but when making a xhr request (same domain)user_id = request.get_cookie('user_id', secret='mysecret') returns None.
When checking on client browser, cookie and key/value are still available.
How to deal with it ?
(I've always been told that xhr requests are http requests, so from same domain, cookies should be shared, no ? is problem arrising from Bottle 'secret' handling ?) |
Cannot find PRAW config file when wrapping application with py2app | 30,129,259 | 1 | 0 | 399 | 0 | python,pyinstaller,py2app,praw | I came across this error today - not in the context of py2app, but after a pip upgrade of praw. In case you still have this problem (unlikely :)) and/or in the interest of posterity, here's how I was able to fix it: I noticed that the error was in reading the praw.ini file, which very much exists on my system. The real problem was the owner of the file was root, and the owner only had read privileges. Changing that to have my account read/execute privileges to everything inside praw fixed the issue. | 0 | 0 | 0 | 0 | 2015-01-26T18:07:00.000 | 1 | 1.2 | true | 28,156,037 | 1 | 0 | 1 | 1 | I'm trying to wrap my Python script into an application using py2app, but when I try to run the app I'm getting this PRAW related error:
Exception: Could not find config file in any of: ['/Users/username/CS/Applicationame/dist/applicationname.app/Contents/Resources/lib/python2.7/site-packages.zip/praw/praw.ini', '/Users/username/.config/praw.ini', 'praw.ini']
The strange thing is I navigated to the first path, unzipped site-packages.zip and found praw.ini inside /praw, so I'm not really sure why I'm getting this error. I've also tried using pyinstaller but I get the same error. |
Django app shows the same instance every time I hit the server | 28,159,360 | 0 | 1 | 98 | 0 | python,django,django-deployment | The built-in development server (that you get by doing python manage.py runserver) will refresh whenever you make a change. Apache will not (by default).
You either need to restart apache, or you need to set maximum-requests=1 in your WSGI config.
The way to go is to run the built-in dev server for development, and then deploy to an apache server for production. | 0 | 0 | 0 | 0 | 2015-01-26T18:32:00.000 | 2 | 0 | false | 28,156,422 | 0 | 0 | 1 | 1 | I have a sample Django app which is being hosted on an Apache2 server using mod_wsgi. Currently I am testing it only on the loopback address (127.0.0.1). So this is what I do:
Open a tab and go to the loop back address. And then I work on the Django app.
Now when I start another tab and go to the loopback address, the Django app does not start from scratch. It shows me the exact same thing happening in the other tab.
How do I avoid this situation? Will it be resolved automatically if I run the app on the web? I am very new to this and I have not been able find a solution on google. I can provide any file needed to resolve the issue. |
Virtualenv installed package not found | 28,159,200 | 0 | 0 | 196 | 0 | python,django | Make sure your wsgi file points to the right virtualenv! | 0 | 0 | 0 | 0 | 2015-01-26T21:30:00.000 | 1 | 1.2 | true | 28,159,111 | 1 | 0 | 1 | 1 | I installed a django-secure into a virtualenv using pip. The install was normal. The module shows up in the virtualenv pip list and in virtualenvs/dev/lib/python2.7/site-packages. I get the following error when running my code.
ImportError: No module named djangosecure
The folder is in there and there is an init. No install issues. What am I doing wrong and how do I fix it? |
Django Hide Processing Page | 28,180,194 | 1 | 0 | 34 | 0 | python,django,django-views | I think the flow would look more like:
Question_Page -> Post Data View (processes the data from the question page) -> redirect to Output page (based upon data results).
The only page someone would "see" is the "Question Page" and "Output page"... now if processing takes a long time, they could click submit again on the "Question Page". There are lots of ways to deal with that in javascript. | 0 | 0 | 0 | 0 | 2015-01-27T21:11:00.000 | 1 | 1.2 | true | 28,180,074 | 0 | 0 | 1 | 1 | I have a generic set up where you take an assessment which kicks you to a processing page which massages the data, stores it, and then funnels you to the correct output page. You never actually see the processing page it runs and sorts you to the results. I'm concerned this could be exploited. Is there a way to hide this completely without losing my flexibility?
Current flow
Question_Page -> Processing Page -> Output Page (depends upon what you took as determined by the processing page)
I'd like to keep this as some sort of function within a view if possible. |
View running application output in the browser, how? | 28,188,969 | 1 | 0 | 1,186 | 0 | java,c#,python,ide,desktop-application | You need a web application.Now this web application when loads send request to backend code that backend code will do SSH to remote machine and read the file from specific location.Now that read stream will be send back in response and displayed on web based UI. In these type of application few thinks matters.
1) Like if you whole file at once then it will take time to display that content to user.Better idea will be read around 100 lines at once and when user scroll down then again send request to web server to read next 100 lines in this way you can decrease response time and better user experience. | 0 | 1 | 0 | 0 | 2015-01-28T09:34:00.000 | 2 | 0.099668 | false | 28,188,783 | 0 | 0 | 1 | 1 | I have a simple cloud IDE,I want to make it able to build and run applications remotely, the target application's source files will be in a remote server in isolated virtual machine (e.g Windows 8.1,or Ubuntu 14.04). It's not difficult to build that application but how to run it and view its output to users ?
What if it's a desktop application (suppose it's written in C# or Java or Python)?
Note: users access there applications only using browsers (e.g Firefox,Chrome,...)
Edit: desktop application may contains GUI stuff not only console ;) |
Right Auth with AngularJS, Django and external API service | 28,196,456 | 0 | 0 | 246 | 0 | python,django,angularjs,api | Depending from your needs you should think about storing the token in the session storage in the local storage or in a cookie(in this case the cookie is used as a storage mechanism and not as an authentication mechanism). | 0 | 0 | 0 | 0 | 2015-01-28T15:05:00.000 | 1 | 0 | false | 28,195,547 | 0 | 0 | 1 | 1 | I'm developing my first AngularJS application with Django as backend.
My overall architecture is composed of:
Public API json-rpc server (from which I must retrive data previous authentication process (the client send a user/password with a POST request, and then, the server response with a token string).
Django framework, I use this because I need to have some models and MySQL db for additional data; and because the Public API server doesn't support CORS (is a old version) and I've created an API Proxy with one view of Django.
Angular JS App that it served by Django.
Now, when the client first send user/password with AngularJS -> Django -> API server, the server respond with token, and henceforward the Client use token to make next requests.
My question is: What's the right approach to retain the token on the client (AngularJS) (or on Django if required) after the user did login??
Do you have any suggestion on my architecture?
Thanks in advance... and... sorry for my English :) |
Is migration required in a Django application? | 28,201,899 | 2 | 2 | 228 | 0 | python,django | Migrations are not required. They can be useful for creating and tracking database changes via code, but Django applications will run properly without them. | 0 | 0 | 0 | 0 | 2015-01-28T20:32:00.000 | 2 | 0.197375 | false | 28,201,859 | 0 | 0 | 1 | 2 | I want to use Django with nothing but legacy databases. Lots of them. I want to use raw SQL in my model(s).
Do I need migration to make Django function properly? I don't want to use migration because I don't want Django to do anything with or to my databases. I prefer to use SQL and return data. |
Is migration required in a Django application? | 28,201,926 | 2 | 2 | 228 | 0 | python,django | No, you don't need to use migrations.
(Also, it may be relevant to note that you can use raw SQL, but Django will still set up some things for you so you can use its ORM, even with legacy databases. But migrations are not one of these things it does for you.) | 0 | 0 | 0 | 0 | 2015-01-28T20:32:00.000 | 2 | 1.2 | true | 28,201,859 | 0 | 0 | 1 | 2 | I want to use Django with nothing but legacy databases. Lots of them. I want to use raw SQL in my model(s).
Do I need migration to make Django function properly? I don't want to use migration because I don't want Django to do anything with or to my databases. I prefer to use SQL and return data. |