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
Edit database outside Django ORM
35,273,897
3
7
670
1
python,django,git,postgresql
The migrations system does not look at your current schema at all. It builds up its picture from the graph of previous migrations and the current state of models.py. That means that if you make changes to the schema from outside this system, it will be out of sync; if you then make the equivalent change in models.py and create migrations, when you run them you will probably get an error. For that reason, you should avoid doing this. If it's done already, you could apply the conflicting migration in fake mode, which simply marks it as done without actually running the code against the database. But it's simpler to do everything via migrations in the first place. git has no impact on this at all, other than to reiterate that migrations are code, and should be added to your git repo.
0
0
0
0
2016-02-08T15:31:00.000
2
0.291313
false
35,273,294
0
0
1
1
If one is using Django, what happens with changes made directly to the database (in my case postgres) through either pgadmin or psql? How are such changes handled by migrations? Do they take precedence over what the ORM thinks the state of affairs is, or does Django override them and impose it's own sense of change history? Finally, how are any of these issues effected, or avoided, by git, if at all? Thanks.
Is jupyter replicating my data to a cloud server
35,287,484
2
1
392
0
python,jupyter,jupyter-notebook
Jupyter uses no cloud services, and should make no external requests when you are running it locally. The best way to think of a local install of Jupyter notebook is a desktop application that happens to use your web browser for its UI. It talks to the local filesystem, and relays that data to your browser over HTTP on localhost.
0
0
0
0
2016-02-08T20:12:00.000
1
0.379949
false
35,278,437
1
0
1
1
This is a pretty simple question. I if you download jupyter as a part of Anaconda. How is your data being secured. When I run jupyter it does go straight to an html page, but that page displays my local folders on the servers I am connected to. If I make a notebook, will that notebook be stored on a cloud server. Where does it go, and how can I keep all of my filee ("notebooks) local?
"scrapy list" command in my project directory starts a spider
35,303,023
0
1
383
0
python,python-2.7,web-scraping,scrapy
The code was printing some print statements that made it delay the response which made me think it was crawling.
0
0
0
0
2016-02-08T21:27:00.000
1
0
false
35,279,661
0
0
1
1
I created a scrapy project form the command line and added two spiders, myspider1 and myspider2. Whenever I run "scrapy crawl myspider1" or ""scrapy crawl myspider2" it starts "myspider1". When I run "scrapy list" it also starts myspider1 I am running this under a vertualenv in python but I can't understand why it does this. It seems that whenever I run a command with scrapy it always executes the first spider in my spiders folder. Any idea on why this is happening?
Google App Engine - Is it necessary to call self.response in handler?
35,283,754
8
3
311
0
python,google-app-engine
When your handler ends, the response goes to the client -- if you've never written anything to the response, then it will be an empty response (should come with an HTTP 204 status, but browsers are notoriously resigned to broken servers like the one you're apparently planning to create:-). Nothing about this will cause "the instance GAE creates to handle that request will stay alive so to speak indefinitely". After at most 60 seconds (for auto-scaled modules, which are the default choice), things will time out and a 500 HTTP status will go to the browser.
0
1
0
0
2016-02-09T02:29:00.000
1
1.2
true
35,282,924
0
0
1
1
I'm developing with GAE Python. If I have a URL that routes to a handler, is it necessary to actually call self.response.out.write or self.render(if I'm using a template)? I'm thinking if I don't specify a response.out call, then the instance GAE creates to handle that request will stay alive so to speak indefinitely?
Django model with hundreds of fields
35,295,319
0
3
390
0
python,django
You could group them into a few separate models, linked by OneToOneFields to the main model. That would "namespace" your data, and namespaces are "one honking great idea".
0
0
0
0
2016-02-09T08:55:00.000
3
0
false
35,287,620
0
0
1
1
I have a model with hundreds of properties. The properties can be of different types (integer, strings, uploaded files, ...). I would like to implement this complex model step by step, starting with the most important properties. I can think of two options: Define the properties as regular model fields Define a separate model to hold each property separately, and link it to the main model with a ForeignKey I have not found any suggestions on how to handle models with lots of properties with django. What are the advantages / drawbacks of both approaches?
Deploying Django update to live server
35,299,971
0
1
671
0
python,django,deployment,django-south
It would be much safer to use a backup of the live data to test it locally Changes should never be tested in live production. You should try to at least have a test server that mimics the live one to push to first is there anything else I should be aware of? Depends what versions of apps your changing from and to. Django for example, occasionally introduces changes that aren't backwards compatible
0
0
0
0
2016-02-09T18:21:00.000
1
0
false
35,299,374
0
0
1
1
Django is not my main framework, I was hired on contract to update an already existing (live) Django application. Now is time for deployment of my updates to the live server, so I thought I would ask to make sure my process will not cause any problems. The Django version that was being used was extremely old (2012) and I updated it to one of the recent versions a few months back. This update is the one that worries me most with deployment. Back in 2012 apparently Django still used South for migrations, now it has been integrated. Since there is some existing data on the live server, I'm concerned that the migration will not play nicely. Any pitfalls I should be aware of regarding this? As my plan, I'm going to perform a full backup of the existing server/database, then upgrade Django & the dependencies in INSTALLED_APPS to the current version used on my development server, then copy over the files, and perform migration. Should this process be sufficient? Or is there anything else I should be aware of?
Returning Items in scrapy's start_requests()
35,317,246
1
5
1,541
0
python,scrapy
I think using a spider middleware and overwriting the start_requests() would be a good start. In your middleware, you should loop over all urls in start_urls, and could use conditional statements to deal with different types of urls. For your special URLs which do not require a request, you can directly call your pipeline's process_item(), do not forget to import your pipeline and create a scrapy.item from your url for this as you mentioned, pass the url as meta in a Request, and have a separate parse function which would only return the url For all remaining URLs, your can launch a "normal" Request as you probably already have defined
0
0
1
0
2016-02-09T18:57:00.000
2
1.2
true
35,300,052
0
0
1
1
I am writing a scrapy spider that takes as input many urls and classifies them into categories (returned as items). These URLs are fed to the spider via my crawler's start_requests() method. Some URLs can be classified without downloading them, so I would like to yield directly an Item for them in start_requests(), which is forbidden by scrapy. How can I circumvent this? I have thought about catching these requests in a custom middleware that would turn them into spurious Response objects, that I could then convert into Item objects in the request callback, but any cleaner solution would be welcome.
Django template filters not working at all
35,306,452
0
0
313
0
django,postgresql,python-3.x,django-templates,django-template-filters
Turns out this had nothing to do with Django itself, which is not surprising. The data migration which happened between the last and current version broke the newlines in the raw data. Therefore the linebreaksbr was working, but didn't find any linebreaks.
0
0
0
0
2016-02-10T02:06:00.000
1
0
false
35,305,671
0
0
1
1
Currently I have a working Django 1.9 application using Python 3.5 in development. The database is Postgres 9.4.2.0. I have a TEXT type field in the database which contains raw input gathered from users, which is then rendered back for other users to read. The raw text contains newlines and whatnot which look like: chat.freenode.net\r\n#randomchannel The HTML template itself attempts to replace the line breaks with break tags and escape anything else {{ post.body|linebreaksbr|escape }} But it doesn't seem to matter what filters I add to the post.body, it always renders the raw \r\n and never replaces the values with <br> tags. I am not getting any errors in the development server and the rendering of the template works fine, it just seems the filters are not working. I'm pulling my hair our trying to work out why these filters are not working. Does anyone have any ideas?
Adding custom fields to a django model (without changes in source code)
35,466,901
0
8
1,657
0
python,django,database-schema
I know it sounds like an awful hack, but maybe you can build an interface that creates text files? One file would be models.py, with model definitions, and excluding this model from migrations with managed = False Another file is the SQL with DROP and CREATE table if the customer wants a new table, or just ALTER table. Another script can run the SQL script, copy the models.py file to the correct directory, and reload django.
0
0
0
0
2016-02-10T08:53:00.000
6
0
false
35,310,552
0
0
1
2
A customer wants to add custom fields to a django model we provide. He wants to do this on his own, without programming. These things should be addable: boolean (yes/no) fields. Optional "unset" single choice fields multiple choice fields single line text fields textarea fields date Example: The customer wants to add a field he calls "was successful". And the field > should have these choices: yes/no/unset. Defaulting to unset. Things would be easy if I could do it by creating or extending a model. But in this case no source code changes are allowed :-( How to solve this? Update Querying for instances with given values needs to be supported. Example: Show all instances where "was successful" is True.
Adding custom fields to a django model (without changes in source code)
35,414,612
2
8
1,657
0
python,django,database-schema
Well, when I had such problem, I used to create a custom field model, with a name field and a type field, usually a choice field with choices for the possible field types. You can also add a is_active field to filter the active and inactive CustomFields. Than, when I create the for, I search this objects to know which fields I must have in that form. To store the data, I'd have another model, called CustomFieldAnswer, or somethink like this. This model should have a ForeignKey to the main model that should have this data, and the custom field. Doing so, You can have any kinds of fields for yout model dinamically and wothout you client needing to code anything. You could use metaprogramming to create acutual fields in a form based on the query in the CustomFields. Or, you could just put the fields in the template and change the type of the input for each CustomField. Hope that helps!
0
0
0
0
2016-02-10T08:53:00.000
6
0.066568
false
35,310,552
0
0
1
2
A customer wants to add custom fields to a django model we provide. He wants to do this on his own, without programming. These things should be addable: boolean (yes/no) fields. Optional "unset" single choice fields multiple choice fields single line text fields textarea fields date Example: The customer wants to add a field he calls "was successful". And the field > should have these choices: yes/no/unset. Defaulting to unset. Things would be easy if I could do it by creating or extending a model. But in this case no source code changes are allowed :-( How to solve this? Update Querying for instances with given values needs to be supported. Example: Show all instances where "was successful" is True.
Working of the distil networks bot detection
61,044,312
0
2
4,932
0
python,security,web-scraping
I personally drown it in proxies. 1 proxy for 4 requests before blocked, then I change proxy. I've several tens of thousands of free proxies, so it's not a big problem. But it's not very fast, so I set concurrency to 1k or about that.
0
0
1
0
2016-02-10T11:40:00.000
2
0
false
35,314,206
0
0
1
2
I am trying to scrape a website using Scrapy framework in python. But i am getting the captchas. The server implements the bot detection using Distil netwrok bot detection. Is there anyway i can work around with it?
Working of the distil networks bot detection
35,330,104
-8
2
4,932
0
python,security,web-scraping
You can get over it by using tools like Selenium. It is a web testing framework that automatically loads the web browser to mimic a normal user. Once a page loads, you can scrape the content with tools such as Scrapy or Bs4. Continue loading the next page, then scrape. It's slower than normal scrapers but it does the job and gets through most detectors like Incapsula. Hope that helps.
0
0
1
0
2016-02-10T11:40:00.000
2
-1
false
35,314,206
0
0
1
2
I am trying to scrape a website using Scrapy framework in python. But i am getting the captchas. The server implements the bot detection using Distil netwrok bot detection. Is there anyway i can work around with it?
Storing unstructured data with ramses to be searched with Ramses-API?
35,405,127
0
1
95
0
python,json,elasticsearch
This is Chrisses answer, copied from gitter.im: You can use the dict field type for "unstructured data", as it takes arbitrary json. If the db engine is postgres, it uses jsonfield under the hood, and if the db engine is mongo, it's converted to a bson document as usual. Either way it should index automatically as expected in ES and will be queryable through the Ramses API. The following ES queries are supported on documents/fields: nefertari-readthedocs-org/en/stable/making_requests.html#query-syntax-for-elasticsearch See the docs for field types here, start at the high level (ramses) and it should "just work", but you can see what the code is mapped to at each level below down to the db if desired: ramses: ramses-readthedocs-org/en/stable/fields.html nefertari (underlying web framework): nefertari-readthedocs-org/en/stable/models.html#wrapper-api nefertari-sqla (postgres-specific engine): nefertari-sqla-readthedocs-org/en/stable/fields.html nefertari-mongodb (mongo-specific engine): nefertari-mongodb-readthedocs-org/en/stable/fields.html Let us know how that works out, sounds like it could be a useful thing. So far we've just used that field type to hold data like user settings that the frontend wants to persist but for which the API isn't concerned.
0
1
0
0
2016-02-10T15:13:00.000
2
1.2
true
35,318,866
0
0
1
1
I would like to give my users the possibility to store unstructured data in JSON-Format, alongside the structured data, via an API generated with Ramses. Since the data is made available via Elasticsearch, I try to achieve that this data is indexed and searchable, too. I can't find any mentioning in the docs or searching. Would this be possible and how would one do it? Cheers /Carsten
(psycopg2.OperationalError) SSL SYSCALL error: Software caused connection abort
44,923,869
1
4
3,963
1
python,apache,flask,amazon-redshift
I solved this error by turning DEBUG=False in my config file [and/or in the run.py]. Hope it helps someone.
0
0
0
0
2016-02-10T18:00:00.000
1
0.197375
false
35,322,629
0
0
1
1
I am using apache with mod_wsgi in windows platform to deploy my flask application. I am using sqlalchemy to connect redshift database with connection pool(size 10). After few days suddenly I am getting follwoing error. (psycopg2.OperationalError) SSL SYSCALL error: Software caused connection abort Can anybody suggest why I am getting this error and how to fix? If I do the apache restart then this error gone. But after few days it again comeback.
How does Django know the host name for a FileField?
35,324,781
1
1
102
0
python,django
I think by default django uses HOST = '' that equals 127.0.0.1. You can change it in settings.py however I do not know how to use two different hosts.
0
0
0
0
2016-02-10T18:39:00.000
1
1.2
true
35,323,318
0
0
1
1
How does Django know the host name for a FileField that points to my MEDIA_ROOT location? I need to replace the current host name by another one. How do I do it?
How to locate a virtualenv install
35,326,564
2
2
5,340
0
python,django
Create your own virtualenv If all fails, just recreate the virtualenv from the requirements.txt and go from there Find out how the old app was being launched If you insist on finding the old one, IMO the most direct way is to find how is the production Django app being ran. Look for bash scripts that start it, some supervisor entries etc If you find how it starts, then you can pinpoint the environment it is launched in (e.g. which virtualenv) Find the virtualenv by searching for common files Other than that you can use find or locate command to search for files we know to exist in a virtualenv like lib/pythonX.Y/site-packages, bin/activate or bin/python etc
0
0
0
0
2016-02-10T21:39:00.000
2
0.197375
false
35,326,476
1
0
1
2
Deploying to a live server for an existing Django application. It's a very old site that has not been updated in 3+ years. I was hired on contract to bring it up to date, which included upgrading the Django version to be current. This broke many things on the site that had to be repaired. I did a test deployment and it went fine. Now it is time for deployment to live and I am having some issues.... First thing I was going to do is keep a log of the current Django version on server, incase of any issues we can roll back. I tried logging in Python command prompt and importing Django to find version number, and it said Django not found. I was looking further and found the version in a pip requirements.txt file. Then I decided to update the actual django version on the server. Update went through smoothly. Then I checked the live site, and everything was unchanged (with the old files still in place). Most of the site should have been broken. It was not recognizing any changes in Django. I am assuming the reason for this might be that the last contractor used virtualenv? And that's why it is not recognizing Django, or the Django update are not doing anything to the live site? That is the only reason I could come up with to explain this issue, as since there is a pip requirements.txt file, he likely installed Django with pip, which means Python should recognize the path to Django. So then I was going to try to find the source path for the virtualenv with command "lsvirtualenv". But when I do that, even that gives me a "command not found" error. My only guess is that this was an older version of virtualenv that does not have this command? If that is not the case, I'm not sure what is going on. Any advice for how I find the information I need to update the package versions on this server with the tools I have access to?
How to locate a virtualenv install
35,345,062
0
2
5,340
0
python,django
Why not start checking what processes are actually running, and with what commandline, using ps auxf or something of the sort. Then you know if its nginx+uwsgi or django-devserver or what, and maybe even see the virtualenv path, if it's being launched very manually. Then, look at the config file of the server you find. Alternatively, look around, using netstat -taupen, for example, which processes are listening to which ports. Makes even more sense, if there's a reverse proxy like nginx or whatever running, and you know that it's proxying to. The requirements.txt I'd ignore completely. You'll get the same, but correct information from the virtualenv once you activate it and run pip freeze. The file's superfluous at best, and misleading at worst. Btw, if this old contractor compiled and installed a custom Python, (s)he might not even have used a virtualenv, while still avoiding the system libraries and PYTHONPATH. Unlikely, but possible.
0
0
0
0
2016-02-10T21:39:00.000
2
0
false
35,326,476
1
0
1
2
Deploying to a live server for an existing Django application. It's a very old site that has not been updated in 3+ years. I was hired on contract to bring it up to date, which included upgrading the Django version to be current. This broke many things on the site that had to be repaired. I did a test deployment and it went fine. Now it is time for deployment to live and I am having some issues.... First thing I was going to do is keep a log of the current Django version on server, incase of any issues we can roll back. I tried logging in Python command prompt and importing Django to find version number, and it said Django not found. I was looking further and found the version in a pip requirements.txt file. Then I decided to update the actual django version on the server. Update went through smoothly. Then I checked the live site, and everything was unchanged (with the old files still in place). Most of the site should have been broken. It was not recognizing any changes in Django. I am assuming the reason for this might be that the last contractor used virtualenv? And that's why it is not recognizing Django, or the Django update are not doing anything to the live site? That is the only reason I could come up with to explain this issue, as since there is a pip requirements.txt file, he likely installed Django with pip, which means Python should recognize the path to Django. So then I was going to try to find the source path for the virtualenv with command "lsvirtualenv". But when I do that, even that gives me a "command not found" error. My only guess is that this was an older version of virtualenv that does not have this command? If that is not the case, I'm not sure what is going on. Any advice for how I find the information I need to update the package versions on this server with the tools I have access to?
Migrations error in Django after moving to new server
35,343,687
0
0
772
1
python,django,postgresql,django-migrations
Try running migrate --fake-initial since you're getting the "relation already exists" error. Failing that, I would manually back up each one of my migration folders, remove them from the server, then re-generate migration files for each app and run them all again from scratch (i.e., the initial makemigrations).
0
0
0
0
2016-02-11T10:39:00.000
1
1.2
true
35,336,992
0
0
1
1
I'm developing a Django 1.8 application locally and having reached a certain point a few days ago, I uploaded the app to a staging server, ran migrations, imported the sql dump, etc. and all was fine. I've since resumed local development which included the creation of a new model, and changing some columns on an existing model. I ran the migrations locally with success, but after rsync-ing my files to the staging server, I get a 'relation already exists' error when running manage.py migrate. And when I visit the admin page for the new model, I get a 'column does not exist' error. It seems as though the migrations for this model were partially successful but I cannot migrate the entirety of the model schema. I've tried commenting out parts of the migration files, but was not successful. Would it be possible to create the missing columns via psql? Or is there some way of determining what is missing and then manually write a migration to create the missing database structure? I'm using Django 1.8.6, Python 3.4.3, and PostgreSQL 9.3.6. Any advice on this would be great. Thanks.
Can I put my views.py file in the project folder of django?
35,339,613
4
1
725
0
python,django
This will work fine. Views can be wherever you want. You can add the package that is your site (the one that has settings.py in it) to INSTALLED_APPS, and then a models.py in it, management commands, et cetera will also work fine. Apps are handy when things become big and you want to split them into smaller parts.
0
0
0
0
2016-02-11T12:33:00.000
1
1.2
true
35,339,460
0
0
1
1
I am developing a project using django python server. I have created my project on django and put all my files including views.py in the project folder and I am using it without creating any app and its working fine. Is this the right way of doing it (or) I need to create an app instead and put all my files in the project ?
Combining Python and Javascript in a chrome plugin
35,349,167
0
6
7,214
0
javascript,python,google-chrome-extension
The only way to get the output of a Python script inside a content script built with Javascript is to call the file with XMLHttpRequest. As you noted, you will have to use an HTTPS connection if the page is served over HTTPS. A workaround for this is to make a call to your background script, which can then fetch the data in whichever protocol it likes, and return it to your content script.
0
0
1
0
2016-02-11T17:46:00.000
2
0
false
35,346,456
0
0
1
1
I'm writing a chrome extension that injects a content script into every page the user goes to. What i want to do is to get the output of a python function for some use in the content script (can't write it in javascript, since it requires raw sockets to connect to my remote SSL server). I've read that one might use CGI and Ajax or the like, to get output from the python code into the javascript code, but i ran into 3 problems: I cannot allow hosting the python code on a local server, since it is security sensitive data that only the local computer should be able to know. Chrome demands that HTTP and HTTPS can not mix- if the user goes to an HTTPS website, i can't host the python code on a HTTP server. I don't think Chrome even supports CGI on extensions-when i try to access a local file, all it does is print out the text (the python code itself) instead of what i defined to be its output (I tried to do so using Flask). As I said in 1, I shouldn't even try this anyway, but this is just a side note. So my question is, how do i get the output of my python functions inside a Content Script, built with javascript?
What is the best way to store list of links to cloud files in django model
35,364,106
0
0
516
0
python,django,django-models
So you have one model in which you want to save a list of strings (links). The easiest way to do that is by creating a separate model with a textfield and a one-to-many relation.
0
0
0
0
2016-02-12T13:35:00.000
3
0
false
35,363,982
0
0
1
1
I am currently working on a project which involves a django model which should have a field containing links to images on AWS S3. The field should be a list of strings but django has no default field for this. I have searched online and a way to solve this is by creating another model called imagesModel and link them by ForeignKey. But in my case I really only need a list of strings, so I believe there should be an easier way to accomplish this? Some other people suggest creating a custom field to hold the list of strings and some suggest using JSON field to hold the list of strings. I think it should be rather common to store links to images on cloud in django models and there should be a conventional way to do this. Any help please?
Asynchronous unblocked Execution/triggering of python script through javascript
35,366,240
0
0
68
0
javascript,python,ajax,cgi
From the question I read that you have already managed to run a Python script in a web server via CGI and you already know how to do an HTTP (ajax) request from your JavaScript to that web service. When you now close the page in your browser (or an excavator cuts your line), the backend python script is not terminated. In fact, how should the backend even know that you have closed the page? Your Python script is still running in the backend, but no one will be left to capture the HTTP response of the web server and display it to you. However, when you want to start some kind of demon, a program that is supposed to run in the backend for a very long time, then your Python script should spin off that task via a Popen in a variant that keeps the child process alive, even when the script has returned it's HTTP response (and possibly even the web server has shut down). This pattern is sometimes used to remote control little servers that mock IoT devices in test environments. Just start and stop the simulation via some fire-and-forget HTTP requests triggered from a simple interactive web page.
0
0
0
1
2016-02-12T13:40:00.000
1
0
false
35,364,084
0
0
1
1
I am currently working on an application ROFFLE, I may not be very good in terming correctly, What I am able to do right now? User goes on a website, he clicks on a button and an ajax request is done to python file (test.py) but when he exits, the request is aborted and the processing done till yet has gone waste What I want to do? As user clicks the button, the processing starts. The script should not be killed even if the user leaves the webpage. In simple words, the Javascript part should be limited to trigger/queue the python script to execute (with input provided online) which has to be deployed by a web server that supports it via CGI How can this be implemented? Please note: 1. This is a web application and cannot be a software
How can I add to $PATH with tox?
35,371,901
2
3
1,975
0
python,django,testing,protractor,tox
I think it should work if you modify your path in the manage.py file to include django-protractor directory, because the Django management command line uses manage.py.
0
0
0
1
2016-02-12T20:32:00.000
2
1.2
true
35,371,697
0
0
1
1
I'm using tox to run protractor tests which will test an application which uses django+angularjs, there is a glue library (django-protractor) which makes this easier, except that it makes the call to protractor inside a django management command, and relies on $PATH to show it where protractor is. So if I set the $PATH properly before running tox, it works fine, but I'd rather not require all the devs to do that manually.
How to deal with nested forms?(ERROR: mechanize._form.ParseError: nested FORMs)
35,401,852
0
0
336
0
python,mechanize
br.select_form(predicate=lambda f: f.attrs.get('id', None) == 'email-form') This may help you in your function for selecting the form..
0
0
0
0
2016-02-14T06:01:00.000
2
0
false
35,388,878
1
0
1
1
I'm trying to submit a form in a website and when I run the code, it gives me the error: mechanize._form.ParseError: nested FORMs So I checked and in the website, there are 2 forms that are inside each other. the form that I need, which is the first one, is closed properly. Is there anyway to deal with that?
Run Alembic migrations on Google App Engine
35,395,267
1
8
1,816
1
python,google-app-engine,flask,google-cloud-sql,alembic
You can whitelist the ip of your local machine for the Google Cloud SQL instance, then you run the script on your local machine.
0
1
0
0
2016-02-14T11:17:00.000
3
0.066568
false
35,391,120
0
0
1
1
I have a Flask app that uses SQLAlchemy (Flask-SQLAlchemy) and Alembic (Flask-Migrate). The app runs on Google App Engine. I want to use Google Cloud SQL. On my machine, I run python manage.py db upgrade to run my migrations against my local database. Since GAE does not allow arbitrary shell commands to be run, how do I run the migrations on it?
Openerp information messages
35,422,853
0
2
34
0
python,openerp,openerp-7
You can create a wizard with cancel and proceed button within
0
0
0
0
2016-02-14T15:57:00.000
2
0
false
35,393,776
0
0
1
1
Is it possible to create information message with options like proceed or cancel in OpenERP ? If it is possible how to create one ?
How use changefeed with 2 tables?
35,417,780
0
0
35
0
python,rethinkdb
The easiest thing to do would be to denormalize your data so that your changefeed only has to look at one table.
0
0
0
0
2016-02-15T16:47:00.000
1
0
false
35,414,707
0
0
1
1
I use rethinkdb changefeed and I need to catch event from one table with condition from another: first table contains some information, second table contains info about user and I need catch change in first table by the specific user. I tryed join tables and use changefeed with it, but it not works good. Are there ways for it?
How can I model this behavior in Django?
35,422,055
1
1
105
0
python,django,forms,model,message
I assume that you will have some view which will render page on which user of your site will be able to read the unread notifications. So I think you can simply add to notifications model bool field unread. This field is set up when there is new notification to true. After user render page with unread notifications this view simply change this filed to false. When you query using where(ureaded==true) for notifications one more time those will be avoided.
0
0
0
0
2016-02-16T01:14:00.000
2
0.099668
false
35,422,002
0
0
1
1
I want to develop a notification system with Django. So I have an button (and a count of unread messages), that show all messages to the user, so the counter returns to zero again. How can detect my database, that the user already has read the messages and reset the counter? I dont think that I can emulate this with forms, isn't it?
Google App Engine Console shows more entities than I created
35,578,109
1
0
70
0
python,google-app-engine,google-cloud-datastore,google-console-developer
If you check the little question-mark near the statistics summary it says the following: Statistics are generated every 24-48 hours. In addition to the kinds used for your entities, statistics also include system kinds, such as those related to metadata. System kinds are not visible in your kinds menu. Note that statistics may not be available for very large datasets. Could be any of these.
0
1
0
0
2016-02-16T02:14:00.000
1
0.197375
false
35,422,495
0
0
1
1
I recently deployed my app on GAE. In my Datastore page of Google Cloud Console, in the Dashboard Summary, it shows that I have 75 entities. However, when I click on the Entities tab, it shows I have 2 entities of one kind and 3 entities of another kind. I remember creating these entities. I'm just curious where the 75 entities comes from? Just checking if I'm doing something wrong here.
When Mongoengine rebuild indexes?
35,648,604
1
3
349
1
python,mongodb,mongoengine
Mongoengine do not rebuild index automaticly. Mongoengine track changes in models (btw dont work if you add sparse to your filed(if field dont have unique options)) and then fire the ensureIndex in mongoDB. But when its fire - make sure you delete oldest index version manualy(Mongoengine doesn't) in mongoDB. The problem is: if you add sparse to filed w.o unique option - this changes dont mapped in mongoDB index. You need to combine unique = True, sparse = True If you change indexs in models - you need to manualy delete old indexes in mongoDB.
0
0
0
0
2016-02-16T16:11:00.000
1
1.2
true
35,437,458
0
0
1
1
When Mongoengine rebuild(update) a information about indexes? I mean, if a added or change some field (added uniques or sparse option to filed) or added some meta info in model declaration. So question is: When mongoengine update it? How do they track changes?
Django import-export leading zeros for numerical values in excel
35,437,885
0
1
281
0
python,django,excel,django-import-export
An easy fix would be adding an apostrophe (') at the beginning of each number when doing using import-export. This way Excel will recognize those numbers as a text.
0
0
0
0
2016-02-16T16:19:00.000
2
0
false
35,437,656
0
0
1
1
I am faced with the following problem: when I generate .csv files in python using django-import-export even though the field is a string, when I open it in Excel the leading zeros are omitted. E.g. 000123 > 123. This is a problem, because if I'd like to display a zipcode I need the zeros the way they are. I can cover it in quotes, but that's not desirable since it will grab unnecessary attention and it just looks bad. I'm also aware that you can do it in Excel files manually by changing the data type, but I don't want to explain that to people who are using my software. Any suggestions? Thanks in advance.
Create regular backups from OS X to the cloud
35,442,348
4
5
35
0
python,django,macos
This is what version control is for. Sign up for an account at Github, Bitbucket, or Gitlab, and push your code there.
0
1
0
0
2016-02-16T18:43:00.000
1
1.2
true
35,440,612
0
0
1
1
I'm developing a Django project on my MacBook Pro. Constantly paranoid that if my house burns down, someone stoling my MB, hard drive failure or another things that are not likely, but catastrophic if it occurs. How can I create or get automatic backup every 1 hour from my OS X directory where the Django project is to a service like Dropbox or whatever cloud hosting company there might be a solution for. Is there a Python script that does this? I can't be the only one that has thought of this before.
update existing cache data with newer items in django
35,447,745
3
1
1,927
0
python,django,caching,django-models,django-views
You ask about "caching" which is a really broad topic, and the answer is always a mix of opinion, style and the specific app requirements. Here are a few points to consider. If the data is per user, you can cache it per user: from django.core.cache import cache cache.set(request.user.id,"foo") cache.get(request.user.id) The common practice it to keep a database flag that tells you if the user's data changed since it was cached. So before you fetch the data from cache, check only this flag from the DB. If the flag says nothing changed, get the data from cache. If it did change, pull from DB, replace the cache, and set the flag again. The flag check should be fast and simple: one table, indexed by user.id, and a boolean flag field. This will squeeze a lot of index rows into a single DB page, and enables a fast fetching of a single one field row. Yet you still get a persistent updated main storage, that prevents the use of not updated cache data. You can check this flag in a middleware. You can run expiry in many ways: clear cache when user logs out, run a cron script that clears items, or let the cache backend expire items. If you use a flag check before you use the cache, there is no issue in keeping items in cache except space, and caching backends handle that. If you use the django simple file cache (which is easy, simple and zero config), you will have to clear the cache. A simple cron script will do.
0
0
0
0
2016-02-17T03:01:00.000
1
1.2
true
35,447,087
0
0
1
1
I want to use caching in Django and I am stuck up with how to go about it. I have data in some specific models which are write intensive. records will get added continuously to the model. Each user has some specific data in the model similar to orders table. Since my model is write intensive I am not sure how effective caching frameworks in Django are going to be. I tried Django view specific caching and I am try to develop a view where first it will pick up data from the cache. Then I will have another call which will bring in data which was added to the model after the caching was done. What I want to do is add the updated data to the original cache data and store it again. It is like I don't want to expire my cache, I just want to keep adding to my existing cache data. may be once in 3 hrs I can clear it. Is what I am doing right. Are there better ways than this. Can I really add to items in existing cache. I will be very glad for your help
Scrapy: Create Project returning error
35,451,490
1
4
4,043
0
python,web-scraping,scrapy
Looks like you are trying the command scrapy startproject stack inside python interactive shell. Run the same command directly on bash shell, and not inside python shell. And you don't need import scrapy command to create a scrapy project.
0
0
0
0
2016-02-17T08:23:00.000
1
1.2
true
35,451,340
0
0
1
1
I'm learning scrapy to create a crawler that could crawl website and get back the results, however on creating a new project, it is returning an error. I tried creating a folder manually, but again it returned an error. Any idea how to resolve this. SyntaxError: invalid syntax import scrapy scrapy startproject stack
Lock the system
35,453,880
1
0
52
0
python,django
Add some boolean field (answered, is_answered.. etc) and check on every "Response" click if it answered. Hope it will help.
0
0
0
0
2016-02-17T10:02:00.000
2
0.099668
false
35,453,451
0
0
1
1
I am writing a mini-CRM system that two users can login at the same time and they can answer received messages. However, the problem is that they might response the same message because messages can only disappear when they click "Response" button. Is there any suggestion to me to lock the system?
Wing IDE not stopping at break point for Google App Engine
35,457,609
2
2
544
0
python,google-app-engine,debugging,breakpoints
As often happens with these things, writing this question gave me a couple of ideas to try. I was using the Personal edition ... so I downloaded the professional edition ... and it all worked fine. Looks like I'm paying $95 instead of $45 when the 30 day trial runs out.
0
1
0
0
2016-02-17T12:52:00.000
2
0.197375
false
35,457,300
0
0
1
2
I'm new to Python, Wing IDE and Google cloud apps. I've been trying to get Wing IDE to stop at a breakpoint on the local (Windows 7) Google App Engine. I'm using the canned guestbook demo app and it launches fine and responds as expected in the web browser. However breakpoints are not working. I'm not sure if this is important but I see the following status message when first starting the debugger: Debugger: Debug process running; pid=xxxx; Not listening (too many connections) ... My run arguments are as per the recommendation in the Wing IDE help file section "Using Wing IDE with Google App Engine", namely: C:\x\guestbook --max_module_instances=1 --threadsafe_override=false One problem I found when trying to follow these instructions. The instructions say go into Project Properties and the Debug/Execute tab and set the Debug Child Processes to Always Debug Child Process. I found this option doesn't exist. Note also that in the guestbook app, if I press the pause button, the code breaks, usually in the python threading.py file in the wait method (which makes sense). Further note also that if I create a generic console app in Wing IDE, breakpoints work fine. I'm running 5.1.9-1 of Wing IDE Personal. I've included the Google appengine directory and the guestbook directories in the python path. Perhaps unrelated but I also find that sys.stdout.write strings are not appearing in the Debug I/O window.
Wing IDE not stopping at break point for Google App Engine
42,961,127
5
2
544
0
python,google-app-engine,debugging,breakpoints
I have copied the wingdbstub.py file (from debugger packages of Wing ide) to the folder I am currently running my project on and used 'import wingdbstub' & initiated the debug process. All went well, I can now debug modules.
0
1
0
0
2016-02-17T12:52:00.000
2
0.462117
false
35,457,300
0
0
1
2
I'm new to Python, Wing IDE and Google cloud apps. I've been trying to get Wing IDE to stop at a breakpoint on the local (Windows 7) Google App Engine. I'm using the canned guestbook demo app and it launches fine and responds as expected in the web browser. However breakpoints are not working. I'm not sure if this is important but I see the following status message when first starting the debugger: Debugger: Debug process running; pid=xxxx; Not listening (too many connections) ... My run arguments are as per the recommendation in the Wing IDE help file section "Using Wing IDE with Google App Engine", namely: C:\x\guestbook --max_module_instances=1 --threadsafe_override=false One problem I found when trying to follow these instructions. The instructions say go into Project Properties and the Debug/Execute tab and set the Debug Child Processes to Always Debug Child Process. I found this option doesn't exist. Note also that in the guestbook app, if I press the pause button, the code breaks, usually in the python threading.py file in the wait method (which makes sense). Further note also that if I create a generic console app in Wing IDE, breakpoints work fine. I'm running 5.1.9-1 of Wing IDE Personal. I've included the Google appengine directory and the guestbook directories in the python path. Perhaps unrelated but I also find that sys.stdout.write strings are not appearing in the Debug I/O window.
Python requests vs java webservices
35,458,539
0
0
254
0
java,python,web-services,python-requests,legacy
Maybe you could add a man-in-the-middle. A socket server who gets the unix strings, parse them into a sys-2 type of message and send it to sys-2. That could be an option to not re-write all calls between the two systems.
0
1
0
0
2016-02-17T13:03:00.000
2
0
false
35,457,531
0
0
1
2
I have a legacy web application sys-1 written in cgi that currently uses a TCP socket connection to communicated with another system sys-2. Sys-1 sends out the data in the form a unix string. Now sys-2 is upgrading to java web service which in turn requires us to upgrade. Is there any way to upgrade involving minimal changes to the existing legacy code. I am contemplating the creating of a code block which gets the output of Sys-1 and changes it into a format required by Sys-2 and vice versa. While researching, I found two ways of doing this: By using the "requests" library in python. Go with the java webservices. I am new to Java web services and have some knowledge in python. Can anyone advise if this method works and which is a better way to opt from a performance and maintenance point of view? Any new suggestions are also welcome!
Python requests vs java webservices
35,458,442
0
0
254
0
java,python,web-services,python-requests,legacy
Is there any way to upgrade involving minimal changes to the existing legacy code. The solution mentioned, adding a conversion layer outside of the application, would have the least impact on the existing code base (in that it does not change the existing code base). Can anyone advise if this method works Would writing a Legacy-System-2 to Modern-System-2 converter work? Yes. You could write this in any language you feel comfortable in. Web Services are Web Services, it matters not what they are implemented in. Same with TCP sockets. better way to opt from a performance How important is performance? If this is used once in a blue moon then who cares. Adding a box between services will make the communication between services slower. If implemented well and running close to either System 1 or System 2 likely not much slower. maintenance point of view? Adding additional infrastructure adds complexity thus more problems with maintenance. It also adds a new chunk of code to maintain, and if System 1 needs to use System 2 in a new way you have two lots of code to maintain (Legacy System 1 and Legacy/Modern converter). Any new suggestions are also welcome! How bad is legacy? Could you rip the System-1-to-System-2 code out into some nice interfaces that you could update to use Modern System 2 without too much pain? Long term this would have a lower overall cost, but would have a (potentially significantly) larger upfront cost. So you have to make a decision on what, for your organisation, is more important. Time To Market or Long Term Maintenance. No one but your organisation can answer that.
0
1
0
0
2016-02-17T13:03:00.000
2
1.2
true
35,457,531
0
0
1
2
I have a legacy web application sys-1 written in cgi that currently uses a TCP socket connection to communicated with another system sys-2. Sys-1 sends out the data in the form a unix string. Now sys-2 is upgrading to java web service which in turn requires us to upgrade. Is there any way to upgrade involving minimal changes to the existing legacy code. I am contemplating the creating of a code block which gets the output of Sys-1 and changes it into a format required by Sys-2 and vice versa. While researching, I found two ways of doing this: By using the "requests" library in python. Go with the java webservices. I am new to Java web services and have some knowledge in python. Can anyone advise if this method works and which is a better way to opt from a performance and maintenance point of view? Any new suggestions are also welcome!
What options are there for verifying that mturk is requesting my ExternalQuestion and not a 3rd party?
35,503,013
1
0
59
0
python,django,authorization,mechanicalturk
Every request from AWS will include additional URL parameters: workerId, assignmentId, hitId. That's probably the easiest way to identify a request coming from MTurk. There may be headers, as well, but they're not documented anywhere.
0
0
1
0
2016-02-19T01:44:00.000
1
1.2
true
35,495,874
0
0
1
1
I have a django application that I want to host a form on to use as the template for an ExternalHit on Amazon's Mechanical Turk. I've been trying to figure out ways that I can make it so only mturk is authorized to view this document. One idea I've been considering is looking at the request headers and confirming that the request came from Amazon. However, I couldn't find any documentation regarding any of these topics and I am worried that if the source of the request ever changes the page will become inaccessible to mturk. Anyone have any suggestions or solutions that they have implemented? Fyi, I'm using python/django/boto.
How to setup FastCGI setting of IIS with GDAL libs
35,591,876
0
0
134
0
python,django,iis,fastcgi,gdal
Solved it by restart the machine
0
0
0
1
2016-02-19T04:36:00.000
1
1.2
true
35,497,392
0
0
1
1
I set up a django website via IIS manager, which is working fine, then I add a function by using GDAL libs and the function is working fine. And also it is fine if I run this website by using CMD with this command python path\manage.py runserver 8000 But it cannot run via IIS I got error is DLL load failed: The specified module could not be found., which from from osgeo import gdal, osr My guess is I need to set environment variables to FastCGI Settings of IIS I set these to environment variables collections but does not work. GDAL_DATA C:\Program Files (x86)\GDAL\gdal-data GDAL_DRIVER_PATH C:\Program Files (x86)\GDAL\gdalplugins Any help would be appreciated
AWS Lambda parameter passing
42,859,631
0
0
1,250
0
python,amazon-web-services,aws-lambda
You also have to include the query string parameter in the section Resources/Method Request.
0
0
0
1
2016-02-19T12:12:00.000
2
0
false
35,505,089
0
0
1
1
I am creating an api with AWS API Gateway with Lambda functions. I want to be able to make an API call with the following criteria: In the method request of the API i have specified the Query String: itemid I want to be able to use this itemid value within my lambda function I am using Python in Lambda I have tried putting the following in the Mapping template under the Method execution, however get an error: -{ "itemid": "$input.params('itemid')" }
Django: Can template tags prevent content to be rendered to the clients?
35,516,808
1
0
59
0
python,django,performance
Yes, any content within the {% if condition %} and {% endif %} tags will not be sent the client if condition evaluates to False. It is not hidden via CSS, the content will simply not exist in the response. It will also reduce the size of your HTTP response.
0
0
0
0
2016-02-19T23:07:00.000
1
0.197375
false
35,516,720
0
0
1
1
{% if foo == 1 %} <-- blah blah blah -->> {% endif %} If the if block above evaluates the false, would the content inside the if block still be rendered to the client but hidden instead? If not, is this method an acceptable way to reduce page load?
Django deployed project not running subprocess shell command
35,524,148
4
1
309
0
python,django,shell,subprocess,gunicorn
1) User who runs gunicorn has no permissions to run .sh files 2) Your .sh file has no rights to be runned 3) Try to user full path to the file Also, which error do you get when trying to run it on the production?
0
1
0
0
2016-02-20T13:37:00.000
1
1.2
true
35,524,022
0
0
1
1
I have a django 1.9 project deployed using gunicorn with a view contains a line subprocess.call(["xvfb-run ./stored/all_crawlers.sh "+outputfile+" " + url], shell=True, cwd= path_to_sh_file) which runs fine with ./manage.py runserver but fails on deployment and (deployed with gunicorn and wsgi). Any Suggestion how to fix it?
Include django rest pandas dataframe Index field in json response
38,318,621
0
0
363
0
python,django,django-rest-framework
One simple way would be to just reset the index in transform_dataframe method. df = df.reset_index() This would just add a new index and set your old index as a column, included in the output.
0
0
0
0
2016-02-21T08:39:00.000
1
0
false
35,534,039
0
1
1
1
Backgroud I am using django-rest-pandas for serving json & xls. Observation When I hit url with format=xls, I get complete data in the downloaded file. But for format=josn, the index field of dataframe is not part of the records. Question How can I make django-rest-pandas to include dataframe's index field in json response? Note that the index field is present as part of serializer (extending serializer.ModelSerializer).
Django: removing non-used files
35,534,947
5
3
1,427
0
python,django,refactoring
This is not neccessery since django will pick only the updated files, and the whole idea of collectstatic is that you don't have to manually manage the static files. However, if the old files do take a lot of space, once in while you can delete all the files and directories in the static directory, and then run collectstatic again. Then the /static/ dir will include only the updated files. Before you run this, check how much time does it take, and prepare for maintenance. Note: Delete and re-create all files may still require reload of these files by the client browsers or a CDN. It depends on your specific configuration: CDN, caching headers that use the file creation dates, etc.
0
0
0
0
2016-02-21T08:56:00.000
1
1.2
true
35,534,170
0
0
1
1
Is the any automated way to remove (or at least mark) unused non-used (non-referenced) files located in /static/ folder and its sub-folders in Django project?
if __name__ == "__main__" condition with flask/Elastic Beanstalk
35,546,210
0
1
1,304
0
python,amazon-web-services,flask,amazon-elastic-beanstalk
My best guess is that adding if __name__ == '__main__' didn't fix anything, but it coincidentally happened to work that time.
0
0
0
0
2016-02-22T04:27:00.000
1
1.2
true
35,545,822
0
0
1
1
I was setting up a simple flask app on AWS with Elastic Beanstalk, but had a bug that would result in a timeout error when visiting the page ERROR: The operation timed out. The state of the environment is unknown. when running 'eb create'). Ultimately I fixed it by inserting the standard if __name__ == '__main__': condition before appplication.run() which I had originally excluded. My question is: Why should the conditional be necessary for Elastic Beanstalk to run the application? I thought the only purpose of __name__ == '__main__' was so that code does not run when used as a module and I don't see why the absence of the conditional would prevent code from running.
Rebuilding Django development server database
35,551,670
1
1
3,441
0
python,mysql,django
You should delete the migrations folder inside your app folder. You should also delete the database file, if there is one (for SQLite there is a file called db.sqlite3 in the root project folder, but I'm not sure how this works for MySQL). Then run makemigrations and migrate.
0
0
0
0
2016-02-22T08:50:00.000
2
0.099668
false
35,549,309
0
0
1
1
I'm trying to reset my django database so I've run manage.py sqlflush and run that output in MySQL. I've then run manage.py flush. I think this should clear everything. I've then run manage.py makemigrations which seemed to identify all tables that would need building but when I run manage.py migrate it says nothing needs doing and so I now don't have any tables when I run my app.
PhantomJS was placed in path and can execute in terminal, but PATH error in Python
46,802,328
1
4
8,984
0
python,selenium,phantomjs
If you were able to execute in Terminal, just restart PyCharm and it will synchronize the environment variables from the system. (You can check in "RUN" => "Edit Configurations")
0
0
1
0
2016-02-22T23:07:00.000
4
0.049958
false
35,565,733
1
0
1
1
note: PhantomJS runs in PyCharm environment, but not IDLE I have successfully used PhantomJS in Python in the past, but I do not know what to do to revert to that set up. I am receiving this error in Python (2.7.11): selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. I have tried to 'symlink' phantomjs to the path (usr/local/bin [which is also in the path]), and even manually locate /usr/local/bin to place phantomjs in the bin folder. However, there is still a path error in python. What am I missing?
How to use classic Django app with Django REST framework?
35,583,466
2
0
422
0
python,django,rest,django-rest-framework
"Normal" Django views (usually) return HTML pages. Django-Rest-Framework views (usually) return JSON. I am assuming you are looking for something more like a Single page application. In this case you will have a main view that will be the bulk of the HTML page. This will be served from "standard" Django view returning HTML (which will likely include a fair bit of JavaScript). Once the page is loaded the JavaScript code will makes requests to the DRF views. So when you interact with the page, JavaScript will request Json, and update (not reload) the page based on the contents of the JSON. Does that make sense?
0
0
0
0
2016-02-23T10:26:00.000
1
0.379949
false
35,574,857
0
0
1
1
I want to use Django REST framework for my new project but I am not sure if I can do it efficiently. I would like to be able to integrate easily classical Django app in my API. However I don't know how I can proceed to make them respect the REST framework philosophy. Will I have to rewrite all the views or is there a more suitable solution?
django "python manage.py validate" error : unknown command 'validate'
35,579,891
1
10
7,322
0
django,python-3.4
With python manage.py these commands are listed: Available subcommands: [auth] changepassword createsuperuser [django] check compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages makemigrations migrate sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver [sessions] clearsessions [staticfiles] collectstatic findstatic runserver There is no "validate" command in the list.
0
0
0
0
2016-02-23T12:10:00.000
3
0.066568
false
35,577,248
0
0
1
2
With running this command: python manage.py validate I faced with this error: Unknown command: 'validate' What should I do now? For more explanations: Linux Virtualenv Python 3.4.3+ Django (1, 9, 2, 'final', 0)
django "python manage.py validate" error : unknown command 'validate'
35,597,374
0
10
7,322
0
django,python-3.4
With this command: pip install Django==1.8.2 the problem will be solved. Django==1.9.2 does not support some commands.
0
0
0
0
2016-02-23T12:10:00.000
3
0
false
35,577,248
0
0
1
2
With running this command: python manage.py validate I faced with this error: Unknown command: 'validate' What should I do now? For more explanations: Linux Virtualenv Python 3.4.3+ Django (1, 9, 2, 'final', 0)
How to include template (with CSS) onto a template which is being rendered?
35,588,407
0
0
116
0
python,html,css,jinja2
You can use flask, and put your css stylesheet in a folder named "static", at the root of your project. Call this file "style.css".
0
0
0
0
2016-02-23T16:48:00.000
1
0
false
35,583,348
0
0
1
1
I am relatively new to Jinja and templating and have been struggling to get this sorted for some time now.. Here's my layout of folders: templates base content form styles newstyle I have a base template with blockhead/block sidebar/block content/block form layout. I extend it to my content template which has lots of HTML notes I have collected under the block content. This has then been extended to form template which is a dynamic block and takes user inputs to login and post comments. All this should be viewed on the same web page, when I render form.html using jinja_env.get_template(template) along with args. But its not working. Either I see only my sidebar and form block or I see only my content but never all the three... I tried to 'include' base onto content template and include content onto form but this messes up the CSS. Can anyone help?? Also I am a bit confused about to use dynaminc links using url_for which I came across in one of stackoverflow questions ?? Which Template should this be used in??
Custom user dashboard in django
35,698,893
1
1
1,209
0
python,django,dashboard
I wasn't able to elaborate my question coz am a django newbie, but after a week of trying a lot of different things I found a way out. For the dealers and other non staff users I created a dashboard and also overiding the registration to suit my project. Its now working fine.
0
0
0
0
2016-02-23T21:09:00.000
2
1.2
true
35,588,202
0
0
1
2
I have a system that has two types of users with different privileges, the first user is the admin who can access all objects from the database, the second one is a dealer who can only view information pertaining to them alone.(There are many dealers) This is how the system iworks: the admin creates a coupon code and issues it to a person (already done) then that person goes to a dealer who is supposed to check if that coupon code exists. when a dealer logs in he is supposed to be redirected to a dashboard that has the number of items he has sold and to whom. To sell a new item he needs to check if that coupon code exists and if it does then access a form to fill in the item details(I have a model for issued_items) How would I implement a custom admin page for the dealer without affecting the admin dashboard. I created a dealer with super-admin and changed his permissions so that he is only able to change specific models, problem is, the models appear with all objects in that model even the ones by other dealers. I have thought(not tried yet) of creating a view,and a template and redirect login but if i do this then i override the admin (not so sure)Probably create a new app for the dealer???????
Custom user dashboard in django
35,592,084
2
1
1,209
0
python,django,dashboard
This sounds like a situation where you want the functionality to be loosely coupled to prevent headaches down the road, so I'd go with option 3. Leave the admin for the admins and create a new dealer app for the dealers to go to, with a regular view/model/template that they'll be required to login to see.
0
0
0
0
2016-02-23T21:09:00.000
2
0.197375
false
35,588,202
0
0
1
2
I have a system that has two types of users with different privileges, the first user is the admin who can access all objects from the database, the second one is a dealer who can only view information pertaining to them alone.(There are many dealers) This is how the system iworks: the admin creates a coupon code and issues it to a person (already done) then that person goes to a dealer who is supposed to check if that coupon code exists. when a dealer logs in he is supposed to be redirected to a dashboard that has the number of items he has sold and to whom. To sell a new item he needs to check if that coupon code exists and if it does then access a form to fill in the item details(I have a model for issued_items) How would I implement a custom admin page for the dealer without affecting the admin dashboard. I created a dealer with super-admin and changed his permissions so that he is only able to change specific models, problem is, the models appear with all objects in that model even the ones by other dealers. I have thought(not tried yet) of creating a view,and a template and redirect login but if i do this then i override the admin (not so sure)Probably create a new app for the dealer???????
Which approach to use for customizing django-registration-redux
35,593,731
0
0
102
0
python,django
First of all, if you want to override almost every part of redux, wont it be better to use built-in django authentication and to extend it as you wish? Yes, you are on the right way. You need to override those things you do not like by coping them to your project and then by changing the copy. Though it's will be a cleaner code if you place templates in templates/registration, views in views.py and etc, actually you can do in some other way you wish.
0
0
0
0
2016-02-24T01:49:00.000
1
0
false
35,591,797
0
0
1
1
The first thing I did was of course customizing forms, views and templates in site-packages. And then I learned that everything will be reset to default after upgrading the package. So now I decided to create a new application "accounts" and make customizations there. My question is which approach is better (haven't tried any, sorry) First approach: Set INCLUDE_REGISTER_URL = False in accounts.views import RegistrationView and create MyRegistrationView (same thing with forms) in accounts.urls include registration.backends.default.urls and create my own urlpattern for MyRegistrationView create custom templates in templates/registration put registration above django.contrib.admin in INSTALLED_APPS Second approach: in accounts.views import RegistrationView and create MyRegistrationView (same thing with forms) Create complete replica of registration.backends.default.urls in accounts.urls with my new custom template names put custom templates inside my accounts app Or are there any better approaches? (probably are)
Django Allauth mails stop working when I change my smtp provider (mandrill)
35,596,437
0
0
86
0
python,django,email,mandrill,django-allauth
Turns out I needed to add DEFAULT_FROM_EMAIL to my settings.py file. I don't understand why it works with a gmail address and not a custom one, but this fixed it.
0
0
0
1
2016-02-24T07:41:00.000
1
1.2
true
35,596,059
0
0
1
1
I started my app with a gmail account, and have recently upgraded to Mandrill. I am not using the API, just changed my smtp settings through env variables. When I add the new mandrill smtp provider, my in-app mails work perfectly, but allauth's mails do not work at all. (I can see they are not rejected or bounced through mandrill's data, they're just not sent). Any help?
deployment of scrapy selenium project
35,968,793
0
0
146
0
python,selenium,deployment,scrapy
As for my problem with phantomjs it was solved by reinstalling it and increasing the droplet memory .. and for the other message with the other browsers I used "xvfb-run -a" it was a temporary solution but it worked ...
0
0
1
0
2016-02-24T11:13:00.000
1
1.2
true
35,600,560
0
0
1
1
I am new to scrapping. I have a scrapy spider that uses selenium for items interaction I tried to run it on a digitalocean droplet but it fails to runs the phantomjs driver all the time like it's kinda blocked raising exception: BadStatusLine: '' and any other webdrivers are unstable according to the display issue and xvfb. raising irregularly Message: The browser appears to have exited before we could connect. is there any idea what should i do where where i can deploy it ?
Unicode issue using flask and mssql guids with FreeTDS
35,608,084
0
0
167
1
python,sql-server,flask,jinja2
Well, this feels like a hack, but since the only time I'm ever using these guid's is when i'm reading them from the database, I just did: CAST(REC_GUID_ID as VARCHAR(36)) as REC_GUID_ID And now they are in a format that everything seems to read just fine.
0
0
0
0
2016-02-24T14:31:00.000
1
1.2
true
35,604,937
0
0
1
1
I have a flask app that recently had to start using mssql generated guid's as primary keys (previously it was just integers). The guid's are latin-1 encoding. Also, I am not using sqlalchemy. Now, when I'm trying to display the queried mssql guid's in a flask jinja2 template, I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc1 in position 0: ordinal not in range(128). I've tried: unsetting the LANG on the linux host Forcing utf-8 in FreeTDS config (this was already done) escaping in the jinja template using python3, no luck switching from pypyodbc to pyodbc3, but the problem presists Nothing seems to work. If I import sys and set the decoding to utf-8, the error changes replacing ascii with utf-8, but the jinja template will not render the guid's. Any thoughts? Thanks for reading. Also to note, my dev environment is on windows 7 and this issue does not crop up there. It's only on the linux server.
Django, Angular, & DRF: Authentication to Django backend vs. API
35,726,205
0
5
698
0
python,django,django-rest-framework,django-rest-auth
To anyone that stumbles onto this question, I couldn't figure out how to make the hybrid approach work. Having Django serve pages that each contained API calls seemed OK, but I never saw any requests made to the API- I believe due to some other security issues. I'm sure it's possible, but I decided to go for the single page app implementation after all to make things simpler.
0
0
0
0
2016-02-24T16:32:00.000
1
1.2
true
35,607,753
0
0
1
1
I'm building an app with a Django backend, Angular frontend, and a REST API using Django REST Framework for Angular to consume. When I was still working out backend stuff with a vanilla frontend, I used the provided Django authentication to handle user auth- but now that I'm creating a REST based app, I'm not sure how to approach authentication. Since all user data will be either retrieved or submitted via the API, should API authentication be enough? If so, do I need to remove the existing Django authentication middleware? Right now, when I try to hit API endpoints on an early version of the app, I'm directed to what looks like the normal Django login form. If I enter a valid username and password, it doesn't work- just prompts to login again. Would removing the basic Django authentication prevent this? I want to be prompted to login, however I'm not sure how to handle that with these technologies. The package django-rest-auth seems useful, and the same group makes an Angular module- but the docs don't go much past installation and the provided endpoints. Ultimately, I think the core of this question is: how do I entirely switch authentication away from what's provided by Django to something like django-rest-auth or one of the other 3rd party packages recommended by DRF? edit: I made this comment below, but I realized that I need to figure out how combined auth will work. I'm not building a single page app, so individual basic pages will be served from Django, but each page will hit various API endpoints to retrieve the data it needs. Is there a way to have something like django-rest-auth handle all authentication?
Programmatically managing Cassandra permissions
35,617,799
0
2
54
0
javascript,python,ruby,cassandra
Not sure you tried this approach, add tenant info with all your table keys, this way you write your class method to prepare query with tenant will append to it. 1) "ClientA:Name" .... 2) "ClientB:Name"...
0
0
0
0
2016-02-24T19:39:00.000
1
0
false
35,611,473
0
0
1
1
I'm wondering about the best way to manage multitenancy in Cassandra. I have a web app, and I want all users in the web app to have a namespaced area in Cassandra. I can do this via cqlsh (create user with password + grants), but I can't find documentation on it for the ruby, python, or javascript drivers. Any help? EDIT: Right now, I'm using the ruby driver and just using session.execute but this seems suboptimal for security reasons.
Is it possible to deploy Django with Sqlite?
35,615,302
-2
0
3,302
1
python,django,postgresql,sqlite,heroku
sure you can deploy with sqlite ... its not really recommended but should work ok if you have low network traffic you set your database engine to sqlite in settings.py ... just make sure you have write access to the path that you specify for your database
0
0
0
0
2016-02-24T23:23:00.000
3
-0.132549
false
35,615,273
0
0
1
1
I've built a Django app that uses sqlite (the default database), but I can't find anywhere that allows deployment with sqlite. Heroku only works with postgresql, and I've spent two days trying to switch databases and can't figure it out, so I want to just deploy with sqlite. (This is just a small application.) A few questions: Is there anywhere I can deploy with sqlite? If so, where/how?
Should I generate *.pyc files when deploying?
35,619,259
5
5
2,979
0
python,deployment,pyc
Sure, you can go ahead and precompile to .pyc's as it won't hurt anything. Will it affect the first or nth pageload? Assuming Flask/WSGI runs as a persistent process, not at all. By the time the first page has been requested, all of the Python modules will have already been loaded into memory (as bytecode). Thus, server startup time will be the only thing affected by not having the files pre-compiled. However, if for some reason a new Python process is invoked for each page request, then yes, there would (probably) be a noticeable difference in performance and it would be better to pre-compile. As Klaus said in the comments above, the only other time a pageload might be affected is if a function happens to try and import a module that hasn't already been imported. This will require the module to be parsed and converted to bytecode then loaded into memory before being able to continue.
0
0
0
1
2016-02-25T04:10:00.000
1
0.761594
false
35,618,159
0
0
1
1
When developing a Python web app (Flask/uWSGI) and running it on my local machine, *.pyc files are generated by the interpreter. My understanding is that these compiled files can make things load faster, but not necessarily run faster. When I deploy this same app to production, it runs under a user account that has no write permissions on the local file system. There are no *.pyc files committed to source control, and no effort is made to generate them during the deploy. Even if Python wanted to write a .pyc file at runtime, it would not be able to. Recently I started wondering if this has any tangible effect on the performance of the app, either in terms of the very first pageview after the process starts, or consistently throughout its entire lifetime. Should I throw a python -m compileall in as part of my deploy scripts?
'pip' command doesn't execute in console2 but executes in windows command prompt
35,623,671
0
1
36
0
python,django
Check PATH environment variable in console2. It should contains path to the pip executable. In Windows Command-Prompt the syntax is echo %PATH% To get a list of all environment variables enter the command set
0
0
0
0
2016-02-25T09:41:00.000
1
1.2
true
35,623,515
1
0
1
1
I have downloaded console2 for windows. Using that I wanted to setup django framework, but console2 couldn't recognize 'pip' as a command. When I tried the same command in windows command prompt, 'pip' was recognized by windows command prompt. Why so?
Slash in parameter Django
35,633,712
0
1
979
0
python,django
You will have to use a different separator character between parameters than inside parameters. After parameters have been matched, you can always replace that separator by the slash that should actually be there inside the parameters. So, either those parameters that use a slash internally allow for some other safe character like a dash or a dot (meaning that there is a character that cannot occur otherwise due to the nature of the respective parameter), or you have to decide on some separator character and create some escaping rule.
0
0
0
0
2016-02-25T16:39:00.000
2
0
false
35,633,187
0
0
1
1
I'm using Django as a restful api, and i have urls like url(r'^datavore/(?P<configuration>.*)/(?P<dataset>.*)/(?P<varname>.*)/(?P<region>[a-z-A-Z\_]+)/(?P<date_range>.*)/filelist/$', views.filelist,name="filelist"), my problem is when the dataset parameter contains '/' it modify the structur of my url the dataset parameter contains only the string after the / . Any idea how to fix this ?
Django virtual environment disaster
35,637,631
2
1
108
0
python,django,bash
I assume you're using virtualenv. If so, do you know where it put the bin directory? If so, run source bin/activate. After that, when you try runserver, it should use the correct Python instance. More complete: source /path/to/bin/activate But I typically run source bin/activate from the directory that contains the related bin.
0
1
0
0
2016-02-25T20:20:00.000
2
0.197375
false
35,637,516
0
0
1
1
I am working on a django app on my macbook with Yosemite. My app was in a virtual environment. I restarted my terminal and when I cd'd to my app it was no longer in the virtual environment and now doesn't run. And all my virtual environment commands give me -bash: command not found. I fully recognize this is a very noobie question but I really want to work on my app and I have tried everything I could find on google and stackoverflow. Please help. Preferably with the commands I need to type from my command line - thank you!
Fill the current time based on the selection of the country in html dropdown
35,643,411
0
0
397
0
javascript,php,jquery,python,html
One way to do it is to get the country name of the select tag with $( "#myselect option:selected" ).text(); or it's value with $( "#myselect" ).val(); and then use a switch statement to change the date time field.
0
0
0
0
2016-02-26T04:01:00.000
2
0
false
35,643,223
0
0
1
1
I have an HTML drop-down where country names are specified.And there is another field where a date time field is specified. When a user selects a country i want the date-time field to be filled with current date-time of that particular country.Please let me know in what all ways this can be done and how. Thanks in advance.
How do I make a custom email template for django-registration-redux password reset?
35,650,368
4
0
606
0
python,django
Based on itzmeontv's answer: To override original templates in registration application. create folder templates inside your base app if it doesn't exist create folder registration inside it. So folder looks like <yourapp>/templates/registration Inside yourapp/templates/registration , create htmls with same name as in registration app. For ex : password_change_form.html. So it will look like <yourapp>/templates/registration/password_change_form.html. Make sure that your base app comes before registration in INSTALLED_APPS.
0
0
0
0
2016-02-26T08:49:00.000
2
0.379949
false
35,647,221
0
0
1
1
As the question says, I'm using django-registration-redux and I've made templates for the registration emails and pages but can't figure out how to make the template for the password reset email. I'm using django 1.9
How to connect between HTML button and python(or flask) function?
35,647,647
2
0
1,304
0
python,html,flask
You can't trigger anything on the server without making a request to a URL. If you don't want the page to reload, you can either redirect back to the original page after your action is finished, or you can use Ajax to make the request without changing the page; but the request itself is always to a URL.
0
0
0
0
2016-02-26T09:06:00.000
1
1.2
true
35,647,516
0
0
1
1
In flask programming, people usually use 'url_for' such as {{url_for = 'some url'}} This way have to make URL(@app.route), template(HTML) and map each other. But, I just want to send email when I click submit button in HTML modal. For this, There is no page reloading. To do this, I think I have to connect between button and python function without URL, return(response) I wonder that how to make it, help me please, I'm beginner in flask programming.
Is it ok to rely on lots of third party packages?
35,656,339
3
0
96
0
python,django
Well, I think this a lot based on your opinion. Personally I would say it's a good idea to use a lot of third party packages. It enables you to develop faster and why inventing the wheel all over again? Advantages: faster development DRY, don't reinvent the wheel higher likelihood that the tools are time-tested and have bugs worked out (@erip) Disadvantages: support of third party packages could be dropped. sometimes they don't fit your needs exactly if open source license changes, you're suddenly without support or liable to a legal battle (@Sayse)
0
0
0
0
2016-02-26T15:56:00.000
1
0.53705
false
35,656,229
1
0
1
1
My organization uses django for our website so we have the opportunity to use pypi packages, but we don't seem to have used many in the past and developers have written there own solutions instead. I've always used lots of packages in my own project. Is there really any downside to using these packages?
Django: Difference between using server through manage.py and other servers like gunicorn etc. Which is better?
35,657,627
8
33
10,890
0
python,django,gunicorn,django-manage.py
manage.py runserver is only a development server, it is not meant for production under any circumstance. You need to use something like Apache, uWSGI, NGINX or some other server to serve your django project once it's ready for deployment.
0
0
0
0
2016-02-26T16:49:00.000
2
1
false
35,657,332
0
0
1
2
I have been running my beginner Django projects with manage.py runserver. I see suggestions to use gunicorn instead. What is the difference ?
Django: Difference between using server through manage.py and other servers like gunicorn etc. Which is better?
35,660,663
79
33
10,890
0
python,django,gunicorn,django-manage.py
nginx and gunicorn are probably the most popular configuration for production deployments. Before detailing why gunicorn is recommended over runserver, let's quickly clarify the difference between nginx and gunicorn, because both state that they are web servers. NGINX should be your entrance point to the public, it's the server listening to port 80 (http) and 443 (https). Its main purpose is handling HTTP requests, that is applying redirects, HTTP Auth if required, managing TSL/SSL Certificates and - among other things - decides where your requests is finally going to. E.g. there maybe a node.js app living on localhost:3000 that awaits requests on/foo/api while gunicorn is waiting at localhost:8000 to serve your awesome app. This functionality of proxying incoming requests to so called upstream services (in this case node.js and gunicorn) is called reverse-proxy. GUNICORN is a server that translates HTTP requests into Python. WSGI is one of the interfaces/implementations that does that (e.g., the text parts of http headers are transformed into key-value dicts). Django's built-in development web server (what you get when you run manage.py runserver) provides that functionality also, but it targets a development environment (e.g., restart when the code changes), whereas Gunicorn targets production. Gunicorn has many features that Django's built-in server is lacking: gunicorn can spawn multiple worker processes to parallelize incoming requests to multiple CPU cores gunicorn has better logging gunicorn is generally optimized for speed gunicorn can be configured to fine grades depending on your setup gunicorn is actively designed and maintained with security in mind There are web servers other than gunicorn, but gunicorn (inspired by ruby's unicorn) is very popular and easy to setup, and hence is not only a good starting point, but a professional solution that is used by large projects.
0
0
0
0
2016-02-26T16:49:00.000
2
1.2
true
35,657,332
0
0
1
2
I have been running my beginner Django projects with manage.py runserver. I see suggestions to use gunicorn instead. What is the difference ?
Is github3py thread-safe?
35,702,676
0
0
77
0
python,thread-safety,github3.py
To give you a more thorough answer, Aviv, since you're simply sharing instances and calling methods, then it is absolutely threadsafe. Some of the questions of requests thread-safety are mostly around cookies, their expiration, and their revocation. Cookies aren't used by github3.py to talk to the GitHub API so you should be fine.
0
0
0
0
2016-02-28T13:01:00.000
2
1.2
true
35,682,844
1
0
1
1
Does anytone knows if github3py is threadsafe. Specifically: GitHub.repository() Repository.iter_pulls() Repository.branch() Repository.create_status() None of the threads edit the objects, just share the instances and call the methods. Thanks
What is the best approach to design model fields that is like a list in Django?
35,691,578
1
0
33
0
python,django,list,model
I think the best way to organize your 'SysApp - documents' relationship, assuming that each document is related to only one sysapp, is to use ForeignKey, as you mentioned. In that case you'll only have to create 2 models: the first one is SysApp with a name field and the second is Document with fields title, url to file, description and a foreignkey to SysApp. Now you can create documents and attach them to the sys you want. So you do not need to specify document_2, document_3 etc. fields. If you need to attach one document to more than one sysapp use ManyToMany instead of ForeignKey.
0
0
0
0
2016-02-29T01:17:00.000
1
0.197375
false
35,690,489
0
0
1
1
Let's say I have a model called 'SysApp'. Each system has 5 documents. Each document has fields: Title URL to the file (external url) Description Rather than defining multiple fields like title_1, url_1, description_1, title_2, url_2, description_2 (Hardcoded approach) is there a better way to handle this type of use case? One way of doing is to create a model storing each document and then SysApp will reference each document using a ForeignKey. However I still have to create field like document_1, document_2 etc. Also it would be quite difficult for editors to manage when there are 100+ SysApp and 3-400+ documents. Is it possible to manage these fields like a list or dictionary? Thank you
Tenancy and sub-tenancy in Django
35,694,308
0
1
50
0
python,django,django-models,multi-tenant
You need to look at foreign key based fields in particular the many to many field. You can then use manytomany through a role object which captures information about roles i.e. See the django docs for excellent examples
0
0
0
0
2016-02-29T07:01:00.000
1
0
false
35,693,644
0
0
1
1
I'm having a SaaS application which needs a main user (like the owner of the business who would use the SaaS) to be the admin of that particular tenancy. Now the main user needs of have multiple sub users (like a user looking for sales, other for purchase, etc). Now my question is single level tenancy is possible in Django. How can I do the second one? Any help will be highly appreciated.
postgres database: When does a job get killed
35,707,179
3
1
2,227
1
python,database,postgresql,sqlalchemy,flask-sqlalchemy
Just the message "killed" appearing in the terminal window usually means the kernel was running out of memory and killed the process as an emergency measure. Most libraries which connect to PostgreSQL will read the entire result set into memory, by default. But some libraries have a way to tell it to process the results row by row, so they aren't all read into memory at once. I don't know if flask has this option or not. Perhaps your local machine has more available RAM than the server does (or fewer demands on the RAM it does have), or perhaps your local machine is configured to read from the database row by row rather than all at once.
0
0
0
0
2016-02-29T17:01:00.000
2
0.291313
false
35,705,211
0
0
1
1
I am using a postgres database with sql-alchemy and flask. I have a couple of jobs which I have to run through the entire database to updates entries. When I do this on my local machine I get a very different behavior compared to the server. E.g. there seems to be an upper limit on how many entries I can get from the database? On my local machine I just query all elements, while on the server I have to query 2000 entries step by step. If I have too many entries the server gives me the message 'Killed'. I would like to know 1. Who is killing my jobs (sqlalchemy, postgres)? 2. Since this does seem to behave differently on my local machine there must be a way to control this. Where would that be? thanks carl
Calling bokeh api from python / flask for charts -- becoming slower with each call
38,001,749
0
1
125
0
python,charts,flask,bokeh
I also face this problem. It turns out Bokeh stores data in its curdoc across requests. I fix this by manually clearing bokeh document everytime at the end of each request with: curdoc().clear()
0
0
0
0
2016-02-29T22:51:00.000
1
0
false
35,711,344
0
0
1
1
I am running a flask application which makes calls to a bokeh api for generating charts to be rendered in html. The first time I generate the chart, it is taking about 0.07s. The second time, about 0.14s. The third time about 0.21s, and so on. I must be doing something wrong. Wondering if anyone has any thoughts on how to fix this. Thank You. Neela.
How to make django task.py code editable in admin panel?
35,730,732
0
0
53
0
python,django
As Peter was saying it is definitely a bad idea. If you must do it, then below one might be little better: Create a view to render a form, where user can choose the task name, class name, and then a text area to write his function or task (or) totally new task.py itself (as per your requirement). Once submitted, in the backend check for pep8 code formatting and (having a copy of your entire source code in your server/somewhere) and copy this new file there and run python manage.py shell to just basic sanitize the code. Restrict the access to this form based on users model (users). Again as Peter was saying this is totally spectacular security hole.
0
0
0
0
2016-03-01T01:02:00.000
1
0
false
35,712,823
0
0
1
1
I have some functions as tasks in my tasks.py file in django and I want to be able to edit the code of each task in my administration panel. Is there any way of doing this. If possible, I would also like to be able to add more tasks in my tasks.py file directly through administration panel without having to go into tasks.py file to add a new task function. If anyone can point me in the right direction, that would be really appreciated.
Run python script inside java on android
59,486,412
1
5
3,858
0
java,android,python
Running a python script inside android app is not practical at the moment, but what you can do is creating a HTTP web service for interpreting python and sending back the results to the android application. Then it's just Android app communicating with a HTTP web service which is simpler than packing an interpreter. This way it makes the app lighter too.
0
0
0
1
2016-03-01T06:28:00.000
1
1.2
true
35,716,086
0
0
1
1
Is it possible to run "python" script inside "Java" in an android app? The main app will be Java but some cryptography should be done in "python" Is it possible to do this?
Ckan backup and restore
35,729,219
4
5
1,289
1
python,ckan
Backup CKAN's databases (the main one and Datastore one if you use it) with pg_dump. If you use Filestore then you need to take a backup copy of the files in the directory specified by ckan.storage_path (default is /var/lib/ckan/default) Restore the database backups (after doing createdb) using psql -f. Then run paster db upgrade just in case it was from an older ckan version. Then paster --plugin=ckan search-index rebuild. In an emergency use rebuild_fast instead of rebuild, but I think it might create some duplicates entries, so to be certain you could then do rebuild -r to do it again carefully but slowly. initialize [the datastore database] from the resources folder (if there is a way) I don't think the CKAN Data Pusher has a command-line interface to push all the resources. It would be a good plan for you to write one and submit a PR for everyone's benefit.
0
0
0
0
2016-03-01T15:31:00.000
1
1.2
true
35,726,924
0
0
1
1
I'm trying to write some documentation on how to restore a CKAN instance in my organization. I have backuped and restored successfully CKAN database and resources folder but i don't know what i have to do with datastore db. Which is the best practice? Use pg_dump to dump the database or initialize it from the resources folder (if there is a way)? Thanks. Alex
Celery task history
38,764,411
5
5
4,109
0
python,celery,flower
You can use the persisent option,eg: flower -A ctq.celery --persistent=True
0
1
0
0
2016-03-01T15:32:00.000
2
0.462117
false
35,726,948
0
0
1
1
I am building a framework for executing tasks on top of Celery framework. I would like to see the list of recently executed tasks (for the recent 2-7 days). Looking on the API I can find app.backend object, but cannot figure out how to make a query to fetch tasks. For example I can use backends like Redis or database. I do not want to explicitly write SQL queries to database. Is there a way to work with task history/results with API? I tried to use Flower, but it can only handle events and cannot get history before its start.
Django - What constitutes an app?
35,732,320
1
2
100
0
python,django
Python\Django is modular. App should include just those models which usually solve 1 concrete task. If some of models from p.1 can be usefull in other tasks, then probably would be better to create a new apps for those models. Ie if some models are shared between multiple tasks then there is a logic to make a new apps with those models. For example you have a forum app. This forum has such features like, polls, registrations, PM, etc. Logically everything seems to be combined together. However, if your site is just a forum - ok, but if there are other content, for example blogs with comments, then "registration model" can be made as a separate app and can be shared between parts of site such as "blogs with comments" and "forum". Regarding admin\frontend. Ive seen apps\projects with more than 10 models together. Based on the forum example above, if the admin part does not do any task out of scope of your app, then I would make admin and front-end inside of one app. Otherwise, if admin has any relation to another task, which is out of scope of your main app - admin should be as a seperate app.
0
0
0
0
2016-03-01T19:13:00.000
2
0.099668
false
35,731,438
0
0
1
1
I'm build a Django app with a number of models (5-10). There would be an admin side, where an end-user manages the data, and then a user side, where other end-users can only read the data. I understand the point of a Django app is to encourage modularity, but I'm unsure as to "where the line is drawn" so-to-speak. In "best practices terms": Should each model (or very related groups of models) have their own app? Should there be an 'admin' app and then a 'frontend' app? In either case, how do the other apps retrieve and use models/data inside other apps?
Django - MySQL : 1146 Table doesn't exist
35,777,867
1
0
2,782
1
mysql,django,python-3.x,django-database
So here is the answer for all the django (or coding in general) noobs like me. python manage.py createcachetable I totally forgot about that and this caused all the trouble with "app_cache doesn't exist". At least in this case... I changed my database to PostgreSQL, but I am sure it also helps with MySQL...
0
0
0
0
2016-03-01T20:25:00.000
2
0.099668
false
35,732,758
0
0
1
2
Hello everybody this is my first post, I made a website with Django 1.8.9 and Python 3.4.4 on Windows 7. As I was using SQLite3 everything was fine. I needed to change the database to MySQL. I installed MySQL 5.6 and mysqlclient. I changed the database settings and made the migration ->worked. But when I try to register a new account or logging into the admin (made createsuperuser before) I get this Error: (1146, "Table 'community_db.app_cache' doesn't exist") I restarted the server and restarted command prompt. What also confuses me is the next row: C:\Python34\lib\site-packages\MySQLdb\connections.py in query, line 280 I was reading that there isn't any MySQLdb for Python 3 Would be nice if there is any help. I already spent such a long time for this website and I tried to solve this problem like allllll the other ones before, but for this one I can't find any help via google/stackover. I don't know what to do
Django - MySQL : 1146 Table doesn't exist
35,733,218
0
0
2,782
1
mysql,django,python-3.x,django-database
I would assume this was an issue with permissions. As in the web-page connects with a user that doesn't have the proper permissions to create content. If your tables are InnoDB, you'll get the table doesn't exist message. You need the ib* files in the root of the MySQL datadir (e.g. ibdata1, ib_logfile0 ib_logfile1) If you don't have these files, you might need to fix permissions by logging directly into your DB
0
0
0
0
2016-03-01T20:25:00.000
2
0
false
35,732,758
0
0
1
2
Hello everybody this is my first post, I made a website with Django 1.8.9 and Python 3.4.4 on Windows 7. As I was using SQLite3 everything was fine. I needed to change the database to MySQL. I installed MySQL 5.6 and mysqlclient. I changed the database settings and made the migration ->worked. But when I try to register a new account or logging into the admin (made createsuperuser before) I get this Error: (1146, "Table 'community_db.app_cache' doesn't exist") I restarted the server and restarted command prompt. What also confuses me is the next row: C:\Python34\lib\site-packages\MySQLdb\connections.py in query, line 280 I was reading that there isn't any MySQLdb for Python 3 Would be nice if there is any help. I already spent such a long time for this website and I tried to solve this problem like allllll the other ones before, but for this one I can't find any help via google/stackover. I don't know what to do
Is the following principle the right for autobahn python?
35,795,470
1
0
59
0
python,c,html,websocket,autobahn
Autobahn|Python provides both a WebSocket implementation for Python and an implementation for a client for the WAMP protocol on top of that. You can use the WebSocket part on its own to implement your WebSocket server.
0
0
1
1
2016-03-02T09:08:00.000
1
0.197375
false
35,742,708
0
0
1
1
I'm researching about WebSockets atm and just found Autobahn with Autobahn|Python. I'm not sure that I understand the function of that toolset (?) correctly. My intention is to use a WebSocket-Server for communication between a C program and a HTML client. The idea is to let the C program connect via WebSocket to the Server and send the calculation progress of the C program to every HTML client that is connected to that WebSocket-Server. Am I able to write a WebSocket Server with Autobahn|Python and then connect with an HTML5-client and a C program client?
Python Mobile Test on AWS Device Farm (M2Crypto Issue)
35,782,735
0
0
96
0
python,amazon-web-services,m2crypto
Device Farm requires your python test should be able to execute on Linux_X64 platform. You could create and package your test bundle on linux_x64 platform, then try to run it on Device Farm.
0
0
0
1
2016-03-03T14:39:00.000
1
0
false
35,775,144
0
0
1
1
I'm working on Python Image Recognition test for Android devices. It works on local; but when I try to build it for AWS, I always get the following error: copying M2Crypto\SSL__init__.py -> build\lib.win32-2.7\M2Crypto\SSL running build_ext building 'M2Crypto.__m2crypto' extension swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c swig.exe -python -Ic:\python27\include -Ic:\python27\PC -Ic:\pkg\include -includeall -modern -builtin -outdir build\lib.win32-2.7\M2Crypto -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i error: command 'swig.exe' failed: No such file or directory I've already tried almost every solution I found on Internet but nothing changed. I'm using Windows 8.1 and Python 2.7 What should I do? How should I fix this problem? Thank you in advance.
Testing Django template with ajax GET request - ajax request isn't invoking
35,795,049
1
0
277
0
javascript,python,ajax,django,django-templates
The django.test.Client is not a browser, it just makes HTTP requests, thus doesn't know anything about ajax/javascript. One of the following should help you use django.test.Client and assert that the template has the ajax call to the correct url, i.e.: assert that the response contains <script>myAjaxCallTo('/some/url/')</script> test the ajax endpoint in isolation that it returns to correct response use selenium (together with the django.test.LiveServerTestCase)
0
0
0
0
2016-03-04T11:24:00.000
1
0.197375
false
35,794,831
0
0
1
1
I've faced with some problem during implementing test for template rendering. There are two views: General Block with required data General(1) template displays some data. This template contains ajax GET call for retrieving data from additional view (2). I want to check these data in my template(1) with test. I use client.get(url) for invoking my template (1). But seems that ajax GET request isn't invoking during test and I can't figure out why.
Change password form while session is deleted
35,800,668
1
0
30
0
python,django
The approach what you are following is not correct. If you want to force the user to change the password, set the flag and if flag is true redirect the user to change the password. If you kill the user will be redirected to login page by default in any web application. Thanks.
0
0
0
0
2016-03-04T16:03:00.000
1
0.197375
false
35,800,558
0
0
1
1
Periodically, I force some users to log out (because their passwords have to be changed) and for that I delete their Session cookie. What's happening next is that these users are redirected to the login screen. How could I implement their redirection to a template that the only thing they can do is to change their password? Nikos
Python temporary directory to execute other processes?
35,809,112
1
1
1,712
0
python,temp
tempfile.mkstemp creates a file that is normally visible in the filesystem and returns you the path as well. You should be able to use this to create your input and output files - assuming javac will atomically overwrite the output file if it exists there should be no race condition if other processes on your system don't misbehave.
0
0
0
0
2016-03-05T01:57:00.000
2
1.2
true
35,809,076
1
0
1
1
I have a string of Java source code in Python that I want to compile, execute, and collect the output (stdout and stderr). Unfortunately, as far as I can tell, javac and java require real files, so I have to create a temporary directory. What is the best way to do this? The tempfile module seems to be oriented towards creating files and directories that are only visible to the Python process. But in this case, I need Java to be able to see them too. However, I also want the other stuff to be handled intelligently if possible (such as deleting the folder when done or using the appropriate system temp folder)
lxml runs in interpreter but not through apache/mod_wsgi
35,821,295
0
0
362
0
python,django,apache,lxml,libxslt
Fixed by removing libexslt.so files from usr/lib64/.
0
0
0
0
2016-03-05T21:48:00.000
1
0
false
35,820,328
0
0
1
1
I have a django app that requires Python (3.4) lxml package. I had a fair amount of trouble building the c shared libraries libxslt and libxml2 that lxml depends on in my red hat server environment. However, pip install lxml now completes successfully and I can import and use lxml in the command line interpreter. When I restart apache, importing lxml within my django app causes the error: ImportError: /usr/local/lib/python3.4/site-packages/lxml/etree.cpython-34m.so: undefined symbol: exsltMathXpathCtxtRegister I have checked that my LD_LIBRARY_PATH is set the same in both environments (/usr/lib). I notice that when I reinstall lxml through pip, pip tells me that it is building against libxml2/libxslt found at /usr/lib64. I have removed all libxml2.so and libxslt.so files found at /usr/lib64/ and been confounded to find that pip continues to tell me that it is building against lib64, that the install completes successfully, and that lxml still works correctly at command line but not through apache. pip also says that the detected version of libxslt that it's using in the install is 1.1.23. However, I've used strace to see that when I import using the interpreter, the library that is loaded is /usr/lib/libxslt.so.1.1.28. I don't know of any tool or technique to find out what library is being loaded through apache.. Does anyone have any theories as to what is going on or how to debug the issue? Thanks in advance!
What is django app usage?
35,843,074
1
1
73
0
python,django-models
Apps are logical modules. One app can contain several models. Your project could have users and blog apps. users would have User and Group models, blog would have Post, Tag and PostTag models. Views within single app usually have same URL prefix and their own URL routing. Within app all database migrations are executed consecutively whereas it's your responsibility to specify dependencies between migrations from different modules. Try to keep logical bounds between apps as weak as possible.
0
0
0
0
2016-03-07T11:45:00.000
1
0.197375
false
35,842,899
0
0
1
1
I want to know if I've understand the main point of django app usage. Every app has a models.py file which create tables in our database, correst? For example I want to create a personal CMS. I should create an app, to create tables for my posts details, and should create an other app to creating tables for my users that want to sign up into my blog, in order to keep their username and password in the database, and I also can create an other app to create a separate tables to save other data..... Do I think correctly?! What are django apps exactly for?
Is it a good practice to save images in the backend database in mysql/django?
35,844,490
1
3
1,276
1
python,mysql,django
The best way to do this is to store the images in your server in some specific, general folder for this images. After that you store a string in your DB with the path to the image that you want to load. This will be a more efficient way to do this.
0
0
0
0
2016-03-07T12:54:00.000
3
0.066568
false
35,844,303
0
0
1
1
I am trying to create my personal web page. So in that I needed to put in the recommendations panel , which contains recommendations by ex employees/friends etc. So I was planning to create a model in django with following attributes:- author_name author_designation author_image author_comments I have following questions in my mind related to image part:- Is it good practice to store images in the backend database?(database is for structured information from what i understand) How to store images so that scaling the content and managing it becomes really easy?
Run a script in background in flask
35,866,759
1
0
1,153
0
python,multithreading,flask
You can render a simple html file at your default route that make an Ajax request to a specific route which will start your script and when the script is finished return the data and catch them in your ajax request to display the data on your page. During the process of your script you can display a loader to show that something is happening
0
0
0
0
2016-03-08T11:44:00.000
1
0.197375
false
35,866,453
0
0
1
1
I am writing an app using Flask that runs a shell script and displays its output in a web page. This works fine. The thing is when I run the script, it takes a long time and the page is loading during the whole time that the script is executed. What I want is that the script runs in the background and when it ends it displays the result. Is there a way to do that?
Flask redirecting requests to urls containing '@'
35,878,062
0
1
511
0
python,flask,url-routing,werkzeug
It turns out that 9000 was right: the '@' sign is a perfectly legal character in the URL. As such, that shouldn't be what Flask was complaining about. Much less obvious than the conversion of '@' to '%40' in the redirected URL is that the trailing slash was missing from the initial request. When writing my question, I was so focused on the change from '@' to '%40' (which is, as it turns out, the same thing in URL terms) that I didn't notice the missing trailing slash at the end of the first URL and mistakenly included it when writing this question. Adding the trailing slash to the POST URL, regardless of whether that URL contained '@' or '%40', fixed the issue. If Flask replaces '@' with '%40' when redirecting, that is nothing to worry about. The real problem is likely caused by something else entirely.
0
0
0
0
2016-03-08T20:25:00.000
1
1.2
true
35,877,333
0
0
1
1
I am re-implementing a legacy system as a Flask app and must keep url patterns as they are. One of the urls includes a user's full email address directly (in other words, the email address is part of the url and not as a GET parameter). When I send requests to this url, Flask automatically responds with a redirect to the same url except that the '@' sign in the email address is replaced with '%40'. For example, a request to /users/new/[email protected]/ is redirected to /users/new/user%40example.com/. I even receive this response from Flask when I send up POST requests directly to the second url, so I'm assuming that the '%40' is automatically translated into an '@' character when processed for the request. How do I get Flask to accept requests to urls that include the '@' sign without redirecting? This may be Werkzeug's fault, as Flask's URL resolving system is built on Werkzeug. EDIT: I Incorrectly included a trailing slash in the initial request URL listed in this question. My problem was in fact caused by the absence of the slash, not the replacement of '@' with '%40'.
Live Video Encoding and Streaming on a Webpage
35,886,856
0
6
8,409
0
python,video,ffmpeg,video-streaming,http-live-streaming
You could use FFmpeg to mux the video stream in to H.264 in a mp4 container and then that can be directly used in a HTML5 video element.
0
0
1
0
2016-03-08T23:56:00.000
2
0
false
35,880,417
0
0
1
1
I am trying to show live webcam video stream on webpage and I have a working draft. However, I am not satisfied with the performance and looking for a better way to do the job. I have a webcam connected to Raspberry PI and a web server which is a simple python-Flask server. Webcam images are captured by using OpenCV and formatted as JPEG. Later, those JPEGs are sent to one of the server's UDP ports. What I did up to this point is something like a homemade MJPEG(motion-jpeg) streaming. At the server-side I have a simple python script that continuously reads UDP port and put JPEG image in the HTML5 canvas. That is fast enough to create a perception of a live stream. Problems: This compress the video very little. Actually it does not compress the video. It only decreases the size of a frame by formatting as JPEG. FPS is low and also quality of the stream is not that good. It is not a major point for now but UDP is not a secure way to stream video. Server is busy with image picking from UDP. Needs threaded server design. Alternatives: I have used FFMPEG before to convert video formats and also stream pre-recorded video. I guess, it is possible to encode(let say H.264) and stream WebCam live video using ffmpeg or avconv. (Encoding) Is this applicable on Raspberry PI ? VLC is able to play live videos streamed on network. (Stream) Is there any Media Player to embed on HTML/Javascript to handle network stream like the VLC does ? I have read about HLS (HTTP Live Stream) and MPEG-DASH. Does these apply for this case ? If it does,how should I use them ? Is there any other way to show live stream on webpage ? RTSP is a secure protocol. What is the best practice for transport layer protocol in video streaming ?
Django deployed app/project can't write to a file
35,923,950
0
1
810
0
python,django,apache,apache2.4
The real solution is to install your data files in /srv/data/myapp or some such so that you can give the webserver user correct permissions to only those directories. Whether you choose to put your code in /var/www or not, is a separate question, but I would suggest putting at least your wsgi file there (and, of course, specifying your <DocumentRoot..> correctly.
0
0
0
0
2016-03-10T17:39:00.000
1
0
false
35,923,494
0
0
1
1
I am working on a Django based application whose location on my disk is home/user/Documents/project/application. Now this application takes in some values from the user and writes them into a file located in a folder which is under the project directory i.e home/user/Documents/project/folder/file. While running the development server using the command python manage.py runserver everything worked fine, however after deployment the application/views.py which accesses the file via open('folder/path','w') is not able to access it anymore, because by default it looks in var/www folder when deployed via apache2 server using mod_wsgi. Now, I am not putting the folder into /var/www because it is not a good practise to put any python code there as it might become readable clients which is a major security threat. Please let me know, how can I point the deployed application to read and write to correct file.
Writing personal translation app using my own database to work on android
35,925,616
0
1
115
0
java,android,python,android-studio,translate
Android studio covers basically every aspect you've mentioned. You'll probably need to google a lot to learn how to implement individual things. Short guide: (research on your own how to do each step) You can use SQLite database for storing your data. Add your media (sound files) to resources and then play them or whatever Android keyboard supports different languages, just set it to Romanian You will need some basic understanding of Android programming if you want to do this. I'm uncertain how much time you're willing to put into this, but it should be doable in 2-3 weeks, heavily depending on your previous coding experience.
0
0
0
0
2016-03-10T19:22:00.000
1
1.2
true
35,925,402
0
0
1
1
I would like to make an app that lets you search for part of a word or phrase, then returns the closest results from a personal database of words I have learnt in another language. Once the results have been returned I would like the option to play the sound file with the associated results. I can write the database in whatever program I need, and the sounds files would be in either wav or mp3 format. The app would also need to allow the user to input foreign letters, there are about 10 extra required as I am using Romanian. These could be separate on the screen if necessary, as in separate to the keyboard input. Would this be an easy enough project to undertake, what sort of size would it be, I am more than happy to spend about a week on it. I am familiar with coding, particularly in Python, so writing in Python would be best, but I can use Java also. This would need to work on the android system. What is the best program to use to write the app?
Dynamic bindings in Django template
35,926,366
0
0
200
0
django,python-2.7,django-templates
This isn't really a template question. Templates are rendered before they ever get to the browser, so there is quite simply no such thing as a dynamic templates in this sense (and, to be clear, this is a consequence of the way the web works, not a limitation of Django). The only solution is javascript. If you don't want to render everything in hidden forms, then you will need to dynamically request the form items via Ajax in response to row clicks.
0
0
0
0
2016-03-10T19:58:00.000
1
1.2
true
35,926,056
0
0
1
1
What is the idiomatic way to create dynamic bindings in a Django template? For example, I have a template that has a list of items along the left. This list is bound to a model in my view context and displayed with a {% for %} loop On the right, is a form that is supposed to display the values of the selected row in the table on the left. When the user clicks on a row in my table, I want the form on the right to change to reflect the new values of the selected row. I cannot seem to find any easy way to do this in Django without submitting a form, which seems counterintuitive OR creating one form for every row in my list and then just showing / hiding the form in question (which also seems undesirable.)
Cannot install djangorestframework on ec2 instance with pip
35,937,820
0
0
273
0
python,amazon-ec2,django-rest-framework
The problem is pip will open a https connection to pyip. Re-check outbound security rule of the instance and add https rule
0
0
0
0
2016-03-11T10:28:00.000
1
0
false
35,937,769
0
0
1
1
I use a micro ec2 instance with python 2.7.10 installed. When i try to install djangorestframework with "pip install djangorestframework", it failed and here is the log: Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')'
How to install BeautifulSoup4 for Python 2.7 while also having Python 3.4 installed?
35,941,194
0
0
757
0
python,windows,python-2.7,bs4
I guess you can run pip2 install bs4 and pip3 install bs4 to install them separately on different python versions
0
0
0
0
2016-03-11T13:05:00.000
1
1.2
true
35,941,011
0
0
1
1
I have both Python 2.7.11 and Python 3.4.1 installed on my Windows 8.1 system. I had installed BeautifulSoup4 with pip to run a code (not mine). However, pip automatically installed bs4 to Python 3.4.1. (I checked that it was installed in C://Python34/lib/site-packages/bs4) I have use the command prompt, change directory to C:\Python27 (where Python 2.7 is installed), and pip install bs4 from that directory, but it didn't work. I had copied the bs4 folder from Python 3.4, but it didn't work either. It only gave another Import Error: No module named html.entities. How can I install bs4 on Python 2.7? Thanks in advance.