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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Python / Django | How to store sent emails?
| 30,368,302 | 5 | 3 | 559 | 0 |
python,django
|
I think the easiest way before messing up with middleware or whatever is to simply create a model for your logged emails and add a new record if send was successful.
| 0 | 0 | 0 | 1 |
2015-05-21T08:22:00.000
| 3 | 1.2 | true | 30,368,271 | 0 | 0 | 1 | 2 |
I was wondering how can I store sent emails
I have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.
|
How to do django syncdb in version 1.4.2?
| 30,392,918 | 3 | 1 | 2,775 | 1 |
python,django,django-models,django-syncdb
|
Thanks Amyth for the hints.
btw the commands is a bit different, i will post a 10x tested result here.
Using south
1. setup the model
python manage.py schemamigration models --initial
dump data if you have to
python manage.py dumpdata -e contenttypes -e auth.Permission --natural > data.json
syncdb
python manage.py syncdb
python manage.py migrate models
load the data back into the db
python manage.py loaddata data.json
Afterwards, you may use
python manage.py schemamigration models --auto
python manage.py migrate models
after every change you made in the models schema
A few notes
1. Unloading the database and reload it is essential, because if not doing so the first migration will tell you already have those models.
2. The -e contenttypes -e auth.Permission --natural parameter in dumpdata is essential otherwise exception will be thrown when doing loaddata.
| 0 | 0 | 0 | 0 |
2015-05-22T03:38:00.000
| 2 | 1.2 | true | 30,387,974 | 0 | 0 | 1 | 1 |
How to do syncdb in django 1.4.2?
i.e. having data in database, how to load the models again when the data schema is updated?
Thanks in advance
|
Django project - serve one of the apps on different domain
| 30,391,339 | 3 | 1 | 1,601 | 0 |
python,django,django-views,django-urls
|
You could run each each domain site independently using their own settings.
This way you can control how much they share using the same codebase.
Create separate settings for both sites. Where each of the settings specify a different ROOT_URLCONF and any extra setting required such as ALLOWED_HOSTS.
Create two separate URL files for each site so you can specify exactly what URLs you want to make available for that given domain, make sure this is specified in each ROOT_URLCONF setting.
Run each site as a separate instance using the settings you have already created. Example using the development server.
python manage.py --settings package.settings.site_a
| 0 | 0 | 0 | 0 |
2015-05-22T07:45:00.000
| 2 | 0.291313 | false | 30,391,105 | 0 | 0 | 1 | 1 |
I have django project with consist of multiple apps.
One app contains all core functions and code (common models etc). I serve it on one domain.
Now I want to add new app which will use some of the other app's models BUT all URLS of this app should be served on different domain.
Is it possible?
|
Future migration of djangos permission system
| 30,767,919 | 0 | 0 | 22 | 0 |
python,django
|
From your description, you will need to use (something like) django-guardian.
Default Django permissions only apply to models(/tables). You cannot give someone permission to edit a specific article, category, comment or tag (only all articles, all categories, etc).
| 0 | 0 | 0 | 0 |
2015-05-22T20:25:00.000
| 1 | 0 | false | 30,405,350 | 0 | 0 | 1 | 1 |
I'm starting to use django and read a lot of documentation in the last days. I also read about the permission system as well as about other systems like django guardian package. I'm trying to implement a multi-user blogging system and I'm not sure if I shall use django permissions or something else, like django guardian. Is there a rule of thumbs? Is migrating easy (starting with standard permissions and later on something else).
Thank you!
|
Pyenv choose virtualenv directory
| 36,550,830 | 12 | 16 | 12,162 | 0 |
python-3.x,virtualenv,pyenv
|
Short answer: You can’t, as far as I know.
It wouldn’t really work either, right? If you use pyenv virtualenv to install a virtualenv into a repo, and you clone that repo to another machine… how would pyenv on the new machine know to take control of the virtualenv in the repository?
Also, “you probably shouldn’t do that”. Virtualenvs are not 100% decoupled from the underlying Python installation, and aren’t really all that portable. And do you really want to litter your repositories with a bunch of easily replicated junk? The “right” way to go about things is probably to to maintain a requirements.txt for pip — that way you can easily reproduce your development environment wherever you clone your repo.
That all said, there’s nothing stopping you from using plain old virtualenv to create a virtualenv anywhere you like, even if you installed virtualenv into a Python interpreter under pyenv control. That virtualenv itself will of course not be administered by pyenv, but you can still use it as you always did…
| 0 | 0 | 0 | 0 |
2015-05-22T23:54:00.000
| 4 | 1.2 | true | 30,407,446 | 1 | 0 | 1 | 1 |
I just began to use pyenv to manage my python versions, and began to use the pyenv virtualenv plugin to manage my virtualenvs, and so far, I have loved it. One thing I miss however, is that with virtualenv, you could actually place virtual environments in repository directories so that your repository was a completely reproducible environment. Does anyone know of a way to choose the directory of your virtualenv in pyenv?
|
When are create and update called in djangorestframework serializer?
| 30,409,455 | 20 | 33 | 20,210 | 0 |
python,django,django-rest-framework
|
I finally understand how the .create() and .update() work in Serializer (especially ModelSerializer) and how they are connected to Viewsets (especially ModelViewSet). I just want clarify the concept more clearly if someone comes to this question.
Basically, the 4 methods CRUD in ModelViewSet: .create(), .retrieve(), .update(), and .destroy() will handle the calls from HTTP verbs. By default, the .create() and .update() from ModelViewSet will call the .create() and .update() from ModelSerializer by calling the .save() method from the BaseSerializer class.
The save() method will then determine whether it will call .create() or .update() in ModelSerializer by determining whether the object self.instance exists or not.
| 0 | 0 | 0 | 0 |
2015-05-23T05:05:00.000
| 3 | 1 | false | 30,409,076 | 0 | 0 | 1 | 1 |
I'm currently implementing djangorestframework for my app RESTful API. After playing around with it, I still do not clearly understand what .create(self, validated_data) and .update(self, validated_data) used for in the serializer. As I understand, CRUD only calls the 4 main methods in viewsets.ModelViewSet: create(), retrive(), update(), and destroy().
I also have already tried to debug and print out stuff to see when the .create() and .update() methods are called in both ModelViewSet and ModelSerializer. Apparently, only the methods in ModelViewSet are called when I do the HTTP verbs. However, for ModelSerializer, I don't see any calls in those 2 methods. I just want to know what are those methods used for in ModelSerializer since I see that people override those methods a lot in the serializer.
|
Debugging ANT script initiated via a Python script
| 30,913,800 | 0 | 0 | 112 | 0 |
python,eclipse,debugging,ant,pydev
|
When dealing with multiple languages, the way for debugging is regular debugging in one and remote debugging in the other... I'm guessing the ant debug uses the regular java debug which supports remote debugging, so, you can probably try that (although I haven't tried it here to confirm).
| 0 | 1 | 0 | 1 |
2015-05-23T12:06:00.000
| 1 | 0 | false | 30,412,458 | 0 | 0 | 1 | 1 |
I have a set of Python scripts that sets up various parameters/properties for ANT script based on various conditions that are checked in the Python scripts and then invokes/executes the appropriate ANT build script.
I initiate the Python script from my Eclipse IDE. I have the PyDev plug-in installed in Eclipse.
I am able to debug the python script but cannot debug the ANT scripts, maybe because it doesn't get invoked as 'Run ANT Script'.
Is there a way to debug an ANT script initiated by Python (or any other mechanism for that matter)?
|
What is the difference between creating db tables using alembic and defining models in SQLAlchemy?
| 30,425,438 | 52 | 19 | 10,088 | 1 |
python,flask,sqlalchemy,alembic
|
Yes, you are thinking about it in the wrong way.
Let's say you don't use Alembic or any other migration framework. In that case you create a new database for your application with the following steps:
Write your model classes
Create and configure a brand new database
Run db.create_all(), which looks at your models and creates the corresponding tables in your database.
So now consider the case of an upgrade. For example, let's say you release version 1.0 of your application and now start working on version 2.0, which requires some changes to your database. How can you achieve that? The limitation here is that db.create_all() does not modify tables, it can only create them from scratch. So it goes like this:
Make the necessary changes to your model classes
Now you have two options to transfer those changes to the database:
5.1 Destroy the database so that you can run db.create_all() again to get the updated tables, maybe backing up and restoring the data so that you don't lose it. Unfortunately SQLAlchemy does not help with the data, you'll have to use database tools for that.
5.2 Apply the changes manually, directly to the database. This is error prone, and it would be tedious if the change set is large.
Now consider that you have development and production databases, that means the work needs to be done twice. Also think about how tedious would it be when you have several releases of your application, each with a different database schema and you need to investigate a bug in one of the older releases, for which you need to recreate the database as it was in that release.
See what the problem is when you don't have a migration network?
Using Alembic, you have a little bit of extra work when you start, but it pays off because it simplifies your workflow for your upgrades. The creation phase goes like this:
Write your model classes
Create and configure a brand new database
Generate an initial Alembic migration, either manually or automatically. If you go with automatic migrations, Alembic looks at your models and generates the code that applies those to the database.
Run the upgrade command, which runs the migration script, effectively creating the tables in your database.
Then when you reach the point of doing an upgrade, you do the following:
Make the necessary changes to your model classes
Generate another Alembic migration. If you let Alembic generate this for you, then it compares your models classes against the current schema in your database, and generates the code necessary to make the database match the models.
Run the upgrade command. This applies the changes to the database, without the need to destroy any tables or back up data. You can run this upgrade on all your databases (production, development, etc.).
Important things to consider when using Alembic:
The migration scripts become part of your source code, so they need to be committed to source control along with your own files.
If you use the automatic migration generation, you always have to review the generated migrations. Alembic is not always able to determine the exact changes, so it is possible that the generated script needs some manual fine tuning.
Migration scripts have upgrade and downgrade functions. That means that they not only simplify upgrades, but also downgrades. If you need to sync the database to an old release, the downgrade command does it for you without any additional work on your part!
| 0 | 0 | 0 | 0 |
2015-05-24T15:30:00.000
| 2 | 1.2 | true | 30,425,214 | 0 | 0 | 1 | 1 |
I could create tables using the command alembic revision -m 'table_name' and then defining the versions and migrate using alembic upgrade head.
Also, I could create tables in a database by defining a class in models.py (SQLAlchemy).
What is the difference between the two? I'm very confused. Have I messed up the concept?
Also, when I migrate the database using Alembic, why doesn't it form a new class in my models.py? I know the tables have been created because I checked them using a SQLite browser.
I have done all the configurations already. The target for Alembic's database and SQLALCHEMY_DATABASE-URI in config.py are the same .db file.
|
Email API for connecting in a marketplace?
| 30,427,829 | 0 | 0 | 74 | 0 |
javascript,php,python,email
|
What you're describing would be handled largely by your backend. If this were my project, I would choose the following simple route:
Store the messages the buyers/sellers send in your own database, then simply send notification emails when messages are sent. Have them reply to each other on your own site, like Facebook and eBay do.
An example flow would go like this:
(Gather the user and buyer's email addresses via registration)
Buyer enters a message and clicks 'Send Message' button on seller's page
Form is posted (via AJAX or via POST) to a backend script
Your backend code generates an email message
Sets the 'To' field to the seller
Your seller gets an email alert of the potential buyer which shows the buyer's message
The Seller then logs on to your site (made easy by a URL in the email) to respond
The Seller enters a response message on your site and hits 'Reply'
Buyer gets an email notification with the message body and a link to your site where they can compose a reply.
...and so on. So, replies would have to be authored on-site, rather than as an email 'reply.'
If you choose to go this route, there are some simple 3rd party "transactional email" providers, which is the phrase you'd use to find them. I've personally used SendGrid and found them easy to set up and use. They have a simple plug in for every major framework. There is also Mandrill, which is newer but gets good reviews as well.
| 0 | 0 | 1 | 1 |
2015-05-24T19:12:00.000
| 1 | 0 | false | 30,427,300 | 0 | 0 | 1 | 1 |
I'm looking into what it would take to add a feature to my site so this is a pretty naive question.
I'd like to be able to connect buyers and sellers via an email message once the buyer clicks "buy".
I can see how I could do this in java script, querying the user database and sending an email with both parties involved. What I'm wondering is if there's a better way I can do this, playing monkey in the middle so they only receive an email from my site, and the it's automatically forwarded to the other party. That way they don't have to remember to hit reply-all, just reply. Also their email addresses remain anonymous.
Again assuming I generate a unique subject line with the transaction ID I could apply some rules here to just automatically forward the email from one party to the other but is there an API or library which can already do this for you?
|
How to get Facebook posts of same type grouped into one, separately?
| 30,502,981 | 1 | 0 | 67 | 0 |
python,facebook,facebook-graph-api
|
Facebook aggregates all your friend birthday posts in a single post. Once the posts are aggregated there is no way to retrieve the individual post as they don't longer exist.
| 0 | 0 | 1 | 0 |
2015-05-24T22:43:00.000
| 1 | 1.2 | true | 30,429,084 | 0 | 0 | 1 | 1 |
I'm using Facebook Graph API to get all the posts on my own timeline.
There is a problem. Because it was my birthday yesterday and all of the posts were done on my profile by others(my friends), these posts are shown as clubbed into one.
This is the response I get in one of the posts when I make an API call at /v2.1/me/feed
189 friends posted on your timeline for your birthday.
But I want to read(get) the posts separately. How can I do that?
|
Django model for datetime availability
| 30,434,626 | 1 | 0 | 1,007 | 0 |
python,django
|
On the item's model, add two datetime fields, for example "bookedStart" and "bookedEnd". And have a function isBooked() that checks if a given datetime or the current datetime is in that time frame, and return True if it is, or False otherwise.
If the users should be able to add multiple time frames (at once) when an item is available or not, you can make a separate model for it, for example BookedItem, and add in it start and end datetime fields, and foreign fields to the user and item. And again, a isAvailable() or isBooked() function.
| 0 | 0 | 0 | 0 |
2015-05-25T08:39:00.000
| 2 | 0.099668 | false | 30,434,228 | 0 | 0 | 1 | 1 |
I'm developing a sample application to book items from other users. I have hit a road block as I can't seem to figure out how to model when item is available to be rented.
Requirements:
Users can rent item per day or per hour.
Owner is able to select dates, hour an item is available.
Any ideas?
|
can one spider handle multiple items and multiple pipelines?
| 30,448,526 | 1 | 1 | 722 | 0 |
python,web,scrapy
|
Item refers to an item of data that it's scraped. You can also call it a record or an entry.
Spider is the thing that does crawling (starting requests and following links) and scraping (extracting data items from responses). They can schedule whatever amount of requests and extract whatever amount of items as you want, there isn't any limit.
Item pipelines are an abstraction to process the items that are extracted by a spider. The idea is that you can combine different "pipes" through which the data items will come through, and then you'll arrange them in a way that will accomplish whatever you need. Examples of use cases for pipelines are applying validation constraints, saving data into a database, doing some clean-up on the data (e.g., remove HTML tags), etc.
So, recapping:
Spiders extract data items, which Scrapy send one by one to a configured item pipeline (if there is possible) to do post-processing on the items.
| 0 | 0 | 0 | 0 |
2015-05-26T01:20:00.000
| 1 | 0.197375 | false | 30,448,027 | 0 | 0 | 1 | 1 |
New to scrapy.There are something confused me:what's the relationship between spiders,pipelines and items?
1.should one pipeline handle only one specific item or it can handle multiple items?
2.how to use one spider to crawl multiple items or I should use one spider just to crawl one item?
|
importing Twilio on google app engine
| 30,514,752 | 0 | 0 | 275 | 0 |
python,google-app-engine,twilio
|
Thanks for the input. I had already tried all of these things. When I ran the app on a local host I saw in the console that the error I was facing was with 'pytz'
Turns out that Twilio requires the Pytz dependency to be in the root directory of Google App Engine. They have not updated the documentation yet.
Hope that helps anyone in the future.
| 0 | 1 | 0 | 1 |
2015-05-27T09:39:00.000
| 3 | 1.2 | true | 30,478,647 | 0 | 0 | 1 | 1 |
I've seen other similar questions but none of the solutions are working for me. I am trying to get Twilio working with Google App Engine. I am using the python API and can't seem to get it to work. I tried a few tactics:
used pip install twilio
downloaded the twilio file directly into my root directory
sym linked the required files according to a few tutorials
nothing seems to work. When I write the line "import twilio.twiml" it makes the google app engine crash and say "error: server error:
What is the best way to import Twilio and load into the google app engine server?
|
CSRF verification fails when trying to login in an already logged in application Django
| 30,481,509 | 5 | 7 | 1,581 | 0 |
python,django
|
This is to be expected. The login operation rotates the CSRF token, otherwise it would be possible to use the token from outside the authenticated session.
Hence what happens in your case:
Retrieve login page in Tab 1 (with unauthenticated "form" CSRF token)
Retrieve login page in Tab 2 (with unauthenticated "form" CSRF token)
Login in Tab 1, CSRF "cookie" token gets cycled server side, browser cookie gets updated
Try to login in Tab 2, sends new cookie (tabs do not separate sessions), but old "form" token.
Second login request is rejected (because "form" token and "cookie" token mismatch).
This is an interaction between the fact that using multiple browser tabs do not separate sessions and the fact that the login operation cycles the "cookie" CSRF token sent to you by the server.
Any page loaded before the login operation that takes place in the same session (e.g. in a different browser tab) will now have an incorrect CSRF "form" token.
| 0 | 0 | 0 | 0 |
2015-05-27T11:34:00.000
| 2 | 0.462117 | false | 30,481,279 | 0 | 0 | 1 | 1 |
Here is what I did:
I have two tabs open on my browser, and I have the login form loaded in both the tabs.
I login with the required credentials on first tab.
I again try to login by providing the credentials on the second tab.
I get an error on the second tab : CSRF verification failed. Request aborted.
I have used the {% csrf_token %} in my login form and CsrfViewMiddleware in settings.py.
Also, I tried the same with the default admin application and got the same error.
|
How to connect a Machine Learning classifier to a Web App?
| 30,491,984 | 2 | 2 | 1,275 | 0 |
python,node.js,machine-learning,sentiment-analysis
|
Flask is a relatively simple web framework. It will suit your need to get the user-submitted text into a python function, without too much boilerplate code or complexity. There are alternatives, most notably Tornado.
I do wonder why you would stack two REST interfaces on top of eachother. Do you need the node.js application for specific reasons? If not, you can simplify your architecture.
| 0 | 0 | 0 | 0 |
2015-05-27T19:31:00.000
| 2 | 0.197375 | false | 30,491,507 | 0 | 0 | 1 | 1 |
I'm trying to build a sentiment classifier web app, but I don't understand who to connect the machine learning component with the web app. I've built the client-side web app that's running on a NodeJS server, and I've trained a sentiment classifier that saved as a Python script.
My goal is to have users submit text on the web app, send it to the Python script, classify, and send the result back via JSON.
How should I setup the Machine Learning-Web App pipeline?
One suggestion was to load the Python script in Flask, and use Flask as a REST API. It seems as though using Flask would be overkill since I only need to do one task.
|
Django 1.8, Using Admin app as the main site
| 30,493,396 | 3 | 0 | 165 | 0 |
python,django
|
This seems like a bad idea.
Out of the box, the information architecture presented by the admin interface is going to be very flat where views essentially mirror what's in the database 1:1. I can imagine a slim subset of users in internal IT apps or similar where that may be appropriate but the compromises in usability are serious, without modifying the admin interface so much that you'll probably wish you had done your app the traditional way by the time you were done.
If usability and information architecture are not serious concerns or requirements for your app, then you may proceed apace.
| 0 | 0 | 0 | 0 |
2015-05-27T21:16:00.000
| 2 | 1.2 | true | 30,493,289 | 0 | 0 | 1 | 1 |
I am about to begin work on a project that will use Django to create a system with three tiers of users. Each user will login into the dashboard type interface (each user will have different types of tools on the dashboard). There will be a few CRUD type interfaces for each user tier among other things. Only users with accounts will be able to interact with the system (anyone visiting is greeted with a login screen).
It seems that many people recommend to simply modify the default Admin app to fit the requirements. Is this an ideal solution and if so, how do I set so the admin interface is at the site's root (instead of admin/). Also, any documentation on in-depth and secure modification of the admin interface (along with the addition of different user tiers) would be appreciated.
|
Django 1.8, Multiple Custom User Types
| 60,831,884 | 0 | 22 | 14,610 | 0 |
python,django,authentication
|
You should need just use Groups Django mechanism - you need to create four groups like userA and let say common and check whether user is in first or second group - then show him appropriate view
| 0 | 0 | 0 | 0 |
2015-05-28T01:59:00.000
| 2 | 0 | false | 30,495,979 | 0 | 0 | 1 | 1 |
I am creating a Django site that will have 4 types of users;
Super Admin: Essentially manages all types of users
UserTypeA: Can login to site and basically will have a CRUD interface for some arbitrary model. Also has extra attributes (specific info that only pertains to TypeA users)
UserTypeB: Can login to site and has extra information that pertains specifically to TypeB users, also can create and manage TypeC user accounts
UserTypeC: Can login to site and has extra information that pertains only to TypeC users.
Noting that I plan on creating a custom interface and not utilizing the built-in admin interface. What would be the best method for implementing this user structure? I would prefer to use Django's built-in authentication system (which manages password salting and hashing, along with session management etc), but I would be open to using some other authentication system if it is secure and production ready.
EDIT: Also, my plan is to use 1 log-in screen to access the site and utilize the permissions and user type to determine what will be available on each user's dashboard.
EDIT: Would it be possible to accomplish this by using an app for each user type, and if so how would this be done with a single log-in screen.
|
How to clear history and run all migrations from the beginning?
| 62,187,440 | 2 | 4 | 7,131 | 0 |
python,migration,alembic
|
Alembic is keeping track of the migrations in the alembic_version table on your database.
Simple drop the table to start from scratch using the following command:
DROP TABLE alembic_version;
And then try to run your migration again!
| 0 | 0 | 0 | 0 |
2015-05-28T13:23:00.000
| 4 | 0.099668 | false | 30,507,853 | 0 | 0 | 1 | 1 |
How I can clear history using alembic? I couldn't find this option in alembic history. I want to run from the first migration rather than the last applied.
|
django models request get id error Room matching query does not exist
| 30,517,111 | 3 | 1 | 1,484 | 1 |
django,python-3.x,django-queryset,models
|
You are looking into request.POST, even if the request.method is not equal to 'POST'. This will not work, because when the request is not an HTTP-post, the POST-member of your request is empty.
| 0 | 0 | 0 | 0 |
2015-05-28T20:59:00.000
| 3 | 0.197375 | false | 30,517,002 | 0 | 0 | 1 | 1 |
i have two models, when i do request.POST.get('room_id') or ('id') i'm getting an error Room matching query does not exist.
how to solved this problem? help me
class Room(models.Model):
status = models.BooleanField('Status',default=True)
name = models.CharField('Name', max_length=100, unique=True)
class Book(models.Model):
date = models.DateTimeField('Created',auto_now_add=True)
from_date = models.DateField('Check-in')
to_date = models.DateField('Check-out')
room = models.ForeignKey(Room, related_name='booking')
i need detail room request get id, booked dates range(from_date,to_date)
def room_detail(request,pk):
room = get_object_or_404(Room,pk=pk)
if request.method == 'POST':
form = BookForm(request.POST,room=room)
if form.is_valid():
s = form.save(commit=True)
s.save()
return redirect(request.path)
else:
form = BookForm()
#roomid = Room.objects.values('id')
type = request.POST.get('id') # or get('room_id')
rooms = Room.objects.get(id=type)
start_dates = rooms.booking.values_list('from_date',flat=True)
end_dates = rooms.booking.values_list('to_date',flat=True)
dates = [start + timedelta(days=i) for start, end in zip(start_dates,end_dates) for i in range((end-start).days+1)]
c = {}
c['form'] = form
return render_to_response('rooms_detail.html',c)
please help me, thanks in advance
|
Inconsistently slow queries in production (RDS)
| 30,519,353 | 0 | 0 | 1,181 | 1 |
python,postgresql,amazon-rds,gevent
|
You could try this from within psql to get more details on query timing
EXPLAIN sql_statement
Also turn on more database logging. mysql has slow query analysis, maybe PostgreSQL has an equivalent.
| 0 | 0 | 0 | 0 |
2015-05-29T00:34:00.000
| 2 | 0 | false | 30,519,299 | 0 | 0 | 1 | 1 |
First, the server setup:
nginx frontend to the world
gunicorn running a Flask app with gevent workers
Postgres database, connection pooled in the app, running from Amazon RDS, connected with psycopg2 patched to work with gevent
The problem I'm encountering is inexplicably slow queries that are sometimes running on the order of 100ms or so (ideal), but which often spike to 10s or more. While time is a parameter in the query, the difference between the fast and slow query happens much more frequently than a change in the result set. This doesn't seem to be tied to any meaningful spike in CPU usage, memory usage, read/write I/O, request frequency, etc. It seems to be arbitrary.
I've tried:
Optimizing the query - definitely valid, but it runs quite well locally, as well as any time I've tried it directly on the server through psql.
Running on a larger/better RDS instance - I'm currently working on an m3.medium instance with PIOPS and not coming close to that read rate, so I don't think that's the issue.
Tweaking the number of gunicorn workers - I thought this could be an issue, if the psycopg2 driver is having to context switch excessively, but this had no effect.
More - I've been working for a decent amount of time at this, so these were just a couple of the things I've tried.
Does anyone have ideas about how to debug this problem?
|
django-simple-history cannot import name error for model import in management command
| 62,368,839 | 2 | 2 | 1,268 | 0 |
python,django,python-2.7,django-models
|
To track history for a model and fix ur issues to use of this code.
pip install django-simple-history
| 0 | 0 | 0 | 0 |
2015-05-29T09:52:00.000
| 1 | 0.379949 | false | 30,526,510 | 0 | 0 | 1 | 1 |
I am using django-simple-history for maintaining the history for each model. Now when I import the model in my management command it gives
import error "cannot find import name 'ModelName'".
Any Help regarding this.?
|
Running complex calculations (using python/pandas) in a Django server
| 30,549,380 | 2 | 1 | 2,516 | 0 |
python,django,python-2.7,numpy
|
I assume your question is about "how do I do these calculations in the restful framework for django?", but I think in this case you need to move away from that idea.
You did everything correctly but RESTful APIs serve resources -- basically your model.
A computation however is nothing like that. As I see it, you have two ways of achieving what you want:
1) Write a model that represents the results of a computation and is served using the RESTful framework, thus your computation being a resource (can work nicely if you store the results in your database as a way of caching)
2) Add a route/endpoint to your api, that is meant to serve results of that computation.
Path 1: Computation as Resource
Create a model, that handles the computation upon instantiation.
You could even set up an inheritance structure for computations and implement an interface for your computation models.
This way, when the resource is requested and the restful framework wants to serve this resource, the computational result will be served.
Path 2: Custom Endpoint
Add a route for your computation endpoints like /myapi/v1/taxes/compute.
In the underlying controller of this endpoint, you will load up the models you need for your computation, perform the computation, and serve the result however you like it (probably a json response).
You can still implement computations with the above mentioned inheritance structure. That way, you can instantiate the Computation object based on a parameter (in the above case taxes).
Does this give you an idea?
| 0 | 0 | 0 | 0 |
2015-05-30T14:02:00.000
| 1 | 1.2 | true | 30,547,102 | 0 | 0 | 1 | 1 |
I have developed a RESTful API using the Django-rest-framework in python. I developed the required models, serialised them, set up token authentication and all the other due diligence that goes along with it.
I also built a front-end using Angular, hosted on a different domain. I setup CORS modifications so I can access the API as required. Everything seems to be working fine.
Here is the problem. The web app I am building is a financial application that should allow the user to run some complex calculations on the server and send the results to the front-end app so they can be rendered into charts and other formats. I do not know how or where to put these calculations.
I chose Django for the back-end as I expected that python would help me run such calculations wherever required. Basically, when I call a particular api link on the server, I want to be able to retrieve data from my database, from multiple tables if required, and use the data to run some calculations using python or a library of python (pandas or numpy) and serve the results of the calculations as response to the API call.
If this is a daunting task, I at least want to be able to use the API to retrieve data from the tables to the front-end, process the data a little using JS, and send it to a python function located on the server with this processed data, and this function would run the necessary complex calculations and respond with results which would be rendered into charts / other formats.
Can anyone point me to a direction to move from here? I looked for resources online but I think I am unable to find the correct keywords to search for them. I just want a shell code kind of a thing to integrate into my current backed using which I can call some python scripts that I write to run these calculations.
Thanks in advance.
|
Deploy python web server on AWS Elastic Beanstalk
| 30,565,453 | 2 | 1 | 284 | 0 |
python,amazon-web-services,websocket,webserver,amazon-elastic-beanstalk
|
AWS doesn't "know" anything about your content. The webserver that you install will be configured to point to the "root" directory in which index.html (or something equivalent) should be.
Since it depends on which webserver (django, flask, Jinja etc) you install - you should lookup its documentation!
| 0 | 0 | 0 | 0 |
2015-06-01T03:57:00.000
| 1 | 1.2 | true | 30,565,431 | 0 | 0 | 1 | 1 |
I'm deploying an python web server on AWS now and I have a some question about it. I'm using websocket to communicate between back end and front end.
Do I have to use framework like django or flask?
If not, where should I put the index.html file? in other word, after deploying, how do AWS know the default page of my application?
Thanks in advance.
|
GAE - Share user authentication across apps
| 30,570,660 | 1 | 0 | 51 | 0 |
python,google-app-engine,flask,google-authentication,google-app-engine-python
|
You can't reuse the Users service authentication across different applications. A possible solution could be using a OAuth2 (or a similar mechanism) - create an application (or use one of you existing applications) which will be the authentication provider. Each application will redirect to the authentication provider where the user will get authenticated, and then redirected back. If the user is already authenticated, they will not need to authenticate again when switching applications. This way you won't be able to use the Users service on the end applications, only in the provider, so you will need to rely on another way to store the currently logged in user in each application (like datastore+memcache).
| 0 | 1 | 0 | 0 |
2015-06-01T08:17:00.000
| 1 | 0.197375 | false | 30,568,702 | 0 | 0 | 1 | 1 |
Let's say I run two different apps on different domains, coded in Python flask and running as GAE instances; one is site.co.uk and one is site.us.
If I use the GAE authentication on one site is it possible to have them authenticated for the other site too? I don't really want to make them have to authenticate for each country specific domain.
|
Django how to not use cached queryset while iterating?
| 30,579,869 | 1 | 0 | 49 | 0 |
python,django,django-queryset
|
You can reload each object in the start of the loop body. Just use TheModel.objects.get(pk=curr_instance.pk) to do this.
| 0 | 0 | 0 | 0 |
2015-06-01T13:53:00.000
| 1 | 1.2 | true | 30,575,409 | 0 | 0 | 1 | 1 |
I have a queryset which I iterate through in a loop. I use data from the queryset to change data inside the queryset which might be needed in a lter step of the loop.
Now the queryset is only loaded once at the beginning of the loop. How can I make django reload the data in every iteration?
|
How is a django app different from a python package?
| 30,590,516 | 4 | 1 | 55 | 0 |
python,django
|
Django app is actually a python package that follows the Django convention. Django-admin startapp is just a helper command to create the files in that convention. If you want to create an app without using startapp, then can create a folder and create __init__.py file and create the necessary files(for views and models). And you should include it in the INSTALLED_APPS. That's all.
| 0 | 0 | 0 | 0 |
2015-06-02T07:36:00.000
| 2 | 1.2 | true | 30,590,085 | 1 | 0 | 1 | 2 |
If I create a normal python package (with __init__.py), instead of manage.py startapp won't I still be able to use it like a django app.?
|
How is a django app different from a python package?
| 30,590,448 | 1 | 1 | 55 | 0 |
python,django
|
Yes, you will be able to use it as a django app. Django is a web framework, hence its main aim is to allow their users to focus on their applications rather than to make them hard-code every single bit of information.
| 0 | 0 | 0 | 0 |
2015-06-02T07:36:00.000
| 2 | 0.099668 | false | 30,590,085 | 1 | 0 | 1 | 2 |
If I create a normal python package (with __init__.py), instead of manage.py startapp won't I still be able to use it like a django app.?
|
How to add some external links to ROBOT Framework Test Statistics in log.html and output.xml?
| 30,597,578 | 1 | 2 | 2,191 | 0 |
python,robotframework
|
You want to add top-level metadata.
And that metadata would be an HTML link.
Create a suit setup for the master suite (create a file called __init__.robot in
the parent test folder)
And in it:
*** Settings ***
Documentation The main init phase for all robot framework tests.
Suite Setup Setup
*** Keywords ***
Setup
Set Suite Metadata Link to my cool external site http://www.external.com top=True
| 0 | 0 | 0 | 0 |
2015-06-02T07:37:00.000
| 3 | 0.066568 | false | 30,590,100 | 0 | 0 | 1 | 1 |
How can I customize my robot framework log.html and output so that I can add some external links to my output files like log.html and output.xml file.
|
Can I link Django permissions to a model class instead of User instances?
| 30,592,097 | 1 | 0 | 111 | 0 |
python,django,database-design
|
django.contrib.auth has groups and group permissions, so all you have to do is to define landlords and tenants groups with the appropriate permissions then on your models's save() method (or using signals or else) add your Landlord and Tenant instances to their respective groups.
| 0 | 0 | 0 | 0 |
2015-06-02T09:16:00.000
| 1 | 0.197375 | false | 30,591,965 | 0 | 0 | 1 | 1 |
I know how permissions/groups/user work together in a "normal" way.
However, I feel incomfortable with this way to do in my case, let me explain why.
In my Django models, all my users are extended with models like "Landlord" or "Tenant".
Every landlord will have the same permissions, every tenant will have other same permissions.. So it seems to me there is not interest to handle permission in a "user per user" way.
What I'd like to do is link the my Tenant and Landlord models (not the instances) to lists of permissions (or groups).
Is there a way to do this? Am I missing something in my modelisation? How would you do that?
|
html buttons calling python functions using bottle
| 30,595,791 | 3 | 1 | 617 | 0 |
python,html,boto,bottle
|
What I have ended up doing to fix this issue is used bottle to make a url which completes the needed function. Then just made an html button that links to the relevant url.
| 0 | 0 | 1 | 0 |
2015-06-02T09:36:00.000
| 1 | 0.53705 | false | 30,592,411 | 0 | 0 | 1 | 1 |
I'm currently trying to right a python script that overnight turns off all of our EC2 instances then in the morning my QA team can go to a webpage and press a button to turn the instances back on.
I have written my python script that turns the severs off using boto. I also have a function which when ran turns them back on.
I have an html doc with buttons on it.
I'm just struggling to work out how to get these buttons to call the function. I'm using bottle rather than flask and I have no Java SCript experience. So I would like t avoid Ajax if possible. I dont mind if the whole page has to reload after the button is pressed. After the single press the webpage isnt needed anyway.
|
How to import a 3rd party Python library into Bluemix?
| 30,603,436 | 4 | 2 | 1,450 | 0 |
python,ibm-cloud
|
The cause for this problem was that I was not correctly telling my Python app the needed configuration information when I pushed it out to Bluemix.
What I ended up having to do was add a requirements.txt file and a Procfile file into the root directory of my Python application, to draw that connection between my Python app and the needed libraries/packages.
In the requirements.txt file I specified the library packages needed by my Python app. These are the file contents:
web.py==0.37
wsgiref==0.1.2
where web.py==0.37 is the version of the web.py library that will be downloaded, and wsgiref==0.1.2 is the version of the web server gateway interface that is needed by the version of web.py I am using.
My Procfile contains the following information:
web: python .py $PORT
where myappname is the name of my Python app, and $PORT is the port number that my Python app uses to receive requests.
I found out too that $PORT is optional because when I did not specify $PORT my app ran with the port number under the VCAP_APP_PORT environment variable for my app.
From there it was just a matter of pushing my app out to Bluemix again only this time it ran fine.
| 0 | 0 | 0 | 0 |
2015-06-02T18:05:00.000
| 3 | 0.26052 | false | 30,603,407 | 0 | 0 | 1 | 1 |
My Python app needs web.py to run but I'm unable to figure out how to get it up to bluemix. I see no options using cf push. I tried to "import web" and added some additional code to my app without success.
When I push my Python app to bluemix without web.py it fails (naturally) since it does not have what it needs to run.
I'm sure I'm just missing an import mechanism. Any help?
|
Python Embed Web Server in Data Processing Node
| 32,857,200 | 0 | 0 | 124 | 0 |
python,python-2.7,flask,tornado,bottle
|
I would recommend you use a separate process for your app that will receive REST commands (use Pyramid or Flask), and have it send messages over RabbitMQ to the real time part. I like Kombu myself for interfacing with RabbitMQ, and your message bus will nicely decouple your web/rest needs from your event driven needs. Your event driven part just gets messages off the bus, and doesn't need to know anything about REST.
| 0 | 1 | 0 | 0 |
2015-06-03T04:28:00.000
| 1 | 0 | false | 30,610,850 | 0 | 0 | 1 | 1 |
I am working on a Python 2.7 project with a simple event loop that checks a variety of data sources (rabbitmq, mongodb, postgres, etc) for new data, processes the data and writes data to the next stage.
I would like to embed a web server in the application so it can receive simple REST commands, for shutting it down, diagnosis etc.
However, from reading the documentation on the available web servers it wasn’t clear if they will allow the event loop described above to function outside of the web server’s event loop. Ie. it looks like I would have to do something like launch the event loop using a REST call and have the loop live on an io thread, or similar.
Can someone explain which embedded server (cherrypy, bottle, flask, etc) / concurrency framework (tornado, gevent, twisted etc.) are best suited for this problem?
Thank you in advance!
|
Downsampling wav audio file
| 65,321,335 | -1 | 24 | 66,340 | 0 |
python,audio,wav,wave,downsampling
|
First, you need to import 'librosa' library
Use 'librosa.load' to resample the audio file
librosa.load(path,sr) initiallly sr(sampling rate) = 22050.If you want to preserve native sampling rate make sr=None. otherwise the audio will be resampled to the sampling rate provided
| 0 | 0 | 0 | 0 |
2015-06-03T12:10:00.000
| 6 | -0.033321 | false | 30,619,740 | 0 | 0 | 1 | 1 |
I have to downsample a wav file from 44100Hz to 16000Hz without using any external Python libraries, so preferably wave and/or audioop. I tried just changing the wav files framerate to 16000 by using setframerate function but that just slows down the entire recording. How can I just downsample the audio file to 16kHz and maintain the same length of the audio?
|
What are the names of session ids for Python and Ruby?
| 31,658,762 | 0 | 0 | 129 | 0 |
python,ruby-on-rails,session
|
Sorry for the delay, I have the asnwer of my question:
I captured the HTTP traffic of some python and ruby on rails applications, the most common sessions ids for each language are the following:
-Python:
sessionid
-Ruby on Rails: The format of session id is: `
_{Name of application}_session
For example, for my "ExampleRoRApp" application, the sessiond id is:
_ExampleRoRApp_session
Thanks for your comments.
| 0 | 0 | 0 | 1 |
2015-06-03T16:29:00.000
| 1 | 1.2 | true | 30,625,748 | 0 | 0 | 1 | 1 |
I want to know the names of session identifiers for Python and Ruby, for example, the names of session identifier for J2EE is JSESSIONID, for PHP is PHPSESSID.
Can you help me please?
|
Changing css styles from view in Django
| 30,631,241 | 1 | 4 | 6,764 | 0 |
python,html,css,django
|
You can do this is many ways.
In general you need to return some variable from your view to the html and depending on this variable select a style sheet, if your variable name will match you style sheet's name you can do "{{variable}}.css", if not you can use JQuery.
| 0 | 0 | 0 | 0 |
2015-06-03T21:25:00.000
| 3 | 0.066568 | false | 30,631,062 | 0 | 0 | 1 | 1 |
Sorry in advance if there is an obvious answer to this, I'm still learning the ropes with Django.
I'm creating a website which has 6 pre determined subjects (not stored in DB)
english, civics, literature, language, history, bible
each subject is going to be associated with a unique color.
I've got a template for a subject.html page and a view that loads from the url appname/subject/subjectname
what I need to do is apply particular css to style the page according to the subject accessed. for example if the user goes to appname/subject/english I want the page to be "themed" to english.
I hope I've made myself clear, also I would like to know if there is a way I can add actual css code to the stylesheet and not have to change attributes one by one from the back-end.
thanks very much!
|
managed paypal accounts with least friction?
| 30,634,280 | 2 | 0 | 47 | 0 |
python,paypal,oauth,payment
|
PayPal doesn't have a way for people to sign up entirely through your site, although there are some ways to facilitate the process. You'd probably have to call PayPal to get access to some of those as they are aimed primarily at larger businesses.
However, don't neglect the easy/automatic assistance that PayPal gives you: you can pay to any email account, and if that email is not already active on a PayPal account then the payment will be waiting for them when they activate that email into an existing or new PayPal account. So you can onboard merchants to your site and leave the PayPal signup for later, when money will be waiting for them to claim. Psychologically, walking away from money is harder than than deciding not to start processing :).
| 0 | 0 | 0 | 1 |
2015-06-04T00:07:00.000
| 2 | 1.2 | true | 30,632,887 | 0 | 0 | 1 | 1 |
I'd like to be able to pay the users of my site using PayPal Mass Payment. I think this is pretty straightforward if they have a PayPal account.
However, if they do not have a PayPal account, is there any way to have them sign up through my site, without leaving? Or just with a nice redirect? Whatever is least friction. I just don't want to lose users in the onboarding experience.
This is analogous to Stripe managed accounts, but I'm not sure if PayPal has such an analogue.
|
Serve dynamic data to many clients
| 30,648,878 | 0 | 0 | 29 | 0 |
python,vb.net
|
1) I am not very familiar with Python, but for the .net application you will likely want to push change notifications to it, rather than pull. The system.net.webclient.downloadstring is a request (pull). As I am not a Python developer I cannot assist in that.
3) As you are requesting data, it is possible to create some errors of the read/write while updating and reading at the same time. Even if this does not happen your data may be out of date as soon as you read it. This can be an acceptable problem, this just depends of how critical your data is.
This is why I would do a push notification rather than a pull. If worked correctly this can keep data synced and avoid some timing issues.
| 0 | 1 | 0 | 0 |
2015-06-04T15:24:00.000
| 1 | 0 | false | 30,647,952 | 1 | 0 | 1 | 1 |
I am writing a client-server type application. The server side gathers constantly changing data from other hardware and then needs to pass it to multiple clients (say about 10) for display. The server data gathering program will be written in Python 3.4 and run on Debian. The clients will be built with VB Winforms on .net framework 4 running on Windows.
I had the idea to run a lightweight web server on the server-side and use system.net.webclient.downloadstring calls on the client side to receive it. This is so that all the multi-threading async stuff is done for me by the web server.
Questions:
Does this seem like a good approach?
Having my data gathering program write a text file for the web server to serve seems unnecessary. Is there a way to have the data in memory and have the server just serve that so there is no disk file intermediary? Setting up a ramdisk was one solution I thought of but this seems like overkill.
How will the web server deal with the data being frequently updated, say, once a second? Do webservers deal with this elegantly or is there a chance the file will be served whilst it is being written to?
Thanks.
|
Django: call index function on page reload
| 30,649,463 | 1 | 0 | 519 | 0 |
python,django,url-routing
|
Well, that really is not how it works. Each view is separate and is only called from the URLs that map to it. If you have shared code, you probably want to either factor it out into separate functions that you can call from each view, or use something like a template tag or context processor to add the relevant information to the template automatically.
| 0 | 0 | 0 | 0 |
2015-06-04T16:35:00.000
| 1 | 1.2 | true | 30,649,428 | 0 | 0 | 1 | 1 |
I was wondering how to call my index(request) function thats in views.py upon every page reload. Currently index(request) only gets called when the app originally loads. Every other page reload after that calls another function in views.py called filter_report(request). The problem I am running into is that 85% of the code in filter_report(request) is also in index(request) and from my understanding you don't really want 2 functions that do a lot of the same stuff. What I would like to do is take that 15% of code that isn't in index(request) but is in filter_report(request) and split it into different methods and just have index(request) call those other methods based on certain conditionals.
|
Subtract one date from another and get int
| 30,669,335 | 0 | 0 | 171 | 0 |
python,django
|
Take the difference between two dates, which is a timedelta, and ask for the days attribute of that timedelta.
| 0 | 0 | 0 | 0 |
2015-06-05T14:36:00.000
| 1 | 0 | false | 30,669,269 | 1 | 0 | 1 | 1 |
How can I subtract on datefield from another and get result in integer?
Like 11.05.2015-10.05.2015 will return 1
I tried
entry.start_devation= each.start_on_fact - timedelta(days=data.calendar_start)
|
How to track Django model changes with git?
| 30,669,779 | 1 | 1 | 216 | 0 |
python,sql,django,git,workflow
|
You should track migrations. The only thing that you must keep an eye out for is at branch merge. If everyone uses a feature branch and develops on his branch then the changes are applied once the branch is integrated. At that point (pull request time or integration time) you need to make sure that the migrations make sense and if not fix them.
| 0 | 0 | 0 | 0 |
2015-06-05T14:51:00.000
| 4 | 0.049958 | false | 30,669,568 | 0 | 0 | 1 | 2 |
Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least).
When you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and/or run some Python code to update values at various places.
How to automate this? Is there a clean way to bundle these "model updates" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.
|
How to track Django model changes with git?
| 30,669,896 | 4 | 1 | 216 | 0 |
python,sql,django,git,workflow
|
All changes to models should be in migrations. If you "need to run a few custom SQL queries and/or run some Python code to update values" then those are migrations too, and should be written in a migration file.
| 0 | 0 | 0 | 0 |
2015-06-05T14:51:00.000
| 4 | 1.2 | true | 30,669,568 | 0 | 0 | 1 | 2 |
Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least).
When you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and/or run some Python code to update values at various places.
How to automate this? Is there a clean way to bundle these "model updates" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.
|
Are there any known negatives to using Requests in Flask to interface to Cloudant on Bluemix?
| 30,679,043 | 4 | 2 | 137 | 0 |
python,flask,couchdb,ibm-cloud,cloudant
|
The main advantage of using a Cloudant/CouchDB library is that you write less code. This can be significant in languages like Java where Rest and JSON handling is very cumbersome. However working with Rest and JSON in python using standard libraries is very easy.
However, the main disadvantages of using a Cloudant/CouchDB library are:
you have less control over the interaction with Cloudant which may make things like session management and http connection pooling much harder.
You don't get to learn the Cloudant API as this is abstracted away from you by the library.
Some libraries allow you do to things which can be problematic for scalability such as py-couchdb's functionality for creating temporary views.
Libraries may not implement the full Cloudant API so you may end up having to make Rest/JSON calls to access these features not implemented by the library.
| 0 | 0 | 0 | 0 |
2015-06-05T23:48:00.000
| 1 | 1.2 | true | 30,677,413 | 0 | 0 | 1 | 1 |
I am writing an app in Python Flask that makes use of the Python HTTP library Request to interface with Cloudant on Bluemix. It is an easy interface that allows me to directly access the Bluemix VCAP information for Cloudant and of course the Cloudant API. However it does not make use of the CouchDB package, which seems to be the most popular way to inteface to Cloudant.
Are there negatives in staying with Request as I scale up, and if so what would they be?i
|
Python/CGI on IIS - find user ID
| 30,683,908 | 1 | 0 | 591 | 0 |
python,iis,cgi
|
When using Windows authentication on IIS, the server variables should contain the username in two variables: AUTH_USER and REMOTE_USER
CGI offers access to all server variables, check your Python docs on how to access them.
| 0 | 0 | 0 | 1 |
2015-06-06T13:53:00.000
| 1 | 0.197375 | false | 30,683,672 | 0 | 0 | 1 | 1 |
I have a very basic CGI based front end hosted on an IIS server.
I'm trying to find the users within my shop that have accessed this site.
All users on the network sign on with their LAN (Windows) credentials and the same session would be used to access the site.
The python getpass module (obviously) returns only the server name so is there a way to find the user names of the visitors to the site?
The stack is Python 2.7 on IIS 8.0, Windows Server 2012
|
Stopping a Django Model function being run more than once, at once
| 30,684,683 | 0 | 1 | 49 | 0 |
python,django,django-models,concurrency
|
What you can do is lock the slot for the booking once the payment is initiated. That way you only "lose" availability for a few moments. The lock can be done on the same centralized system that holds the rest of the information. For instance you can scale up the application servers but keep a single entry point to the data source.
You release the lock once the payment is declined or confirm.
| 0 | 0 | 0 | 0 |
2015-06-06T14:39:00.000
| 2 | 0 | false | 30,684,113 | 0 | 0 | 1 | 1 |
I have a Django Model class for a booking slot. Once we have all the auxiliary data and payment is ready to be made, we get a live availability and allocate a booking. This whole last step of the process takes a couple of seconds (mostly waiting on the payment provider to clear). In theory two payments coming through at once could double-book a slot.
That's all handled by a single function Booking.book(). Is there any sane way I can limit so that only one instance can work at once and others are queued?
The deployment design is initially pretty simple but there could be scale to multiple servers eventually.
What's the proper way of doing this and what are its downsides?
|
Update object in form view without any fields in Django
| 30,691,728 | 0 | 0 | 448 | 0 |
python,django
|
I don't think you need either of those. A simple DetailView would be easier; just override the post method and do the update there.
| 0 | 0 | 0 | 0 |
2015-06-07T08:35:00.000
| 1 | 0 | false | 30,691,591 | 0 | 0 | 1 | 1 |
I want to create a view having a form, But the form should not show any fields.
In the view I has to be able to confirm/accept the object and thus change the status field of the object.
I guess I can make a simple view inheriting from FormView without creating any input fields, find the object in the dispatch method, and change the status field in the form_valid method.
But I wondered if it's better to use UpdateView since it has already implemented get_object, etc.
I have to use this approach many times, so I want to do it right the first time.
|
Can't open Django shell from PyCharm using manage.py shortcut
| 30,695,913 | 1 | 1 | 3,553 | 0 |
django,python-2.7,pycharm
|
Try PyCharm preferences.
Project: --> Project Interpreter --> -->
Ensure the correct python environment
Also double check your settings under
Build, Execution, Deployment --> Console --> Python Console
| 0 | 0 | 0 | 0 |
2015-06-07T16:15:00.000
| 1 | 1.2 | true | 30,695,739 | 0 | 0 | 1 | 1 |
I can run Django shell directly from terminal in PyCharm, but I can't run it from manage.py shortcut (tools -> manage.py task -> shell). But I can do any other operations using this shortcut.
When I am trying to run it using second way nothing happens.
I am using Django 1.7 and PyCharm 4.0.2.
|
Reduce number of choices in Django
| 30,699,316 | 0 | 0 | 64 | 0 |
python,django
|
You need to make a new form class that is a subclass of ModelForm. Then the __init__ method of the ModelForm class change one of the things in self.fields after calling the superclass constructor.
| 0 | 0 | 0 | 0 |
2015-06-07T22:13:00.000
| 1 | 0 | false | 30,698,999 | 0 | 0 | 1 | 1 |
I have an IntegerField with choices.
The list of choices consists of 10 different choices. I have different ModelForm using this integerfield.
In some of the modelforms I don't want to display all of the choices.
Can I in the ModelForm reduce the number of available choices?
|
What method gets called when you display an object?
| 30,721,227 | 1 | 0 | 47 | 0 |
python
|
Either
__repr__or __str__ will do it.
| 0 | 0 | 0 | 0 |
2015-06-09T00:27:00.000
| 2 | 0.099668 | false | 30,721,173 | 1 | 0 | 1 | 1 |
Assume I have a class that inherits from object. I create an instance of it pass that to print. It will display something like <__main__.ObjName object at 0xxxxxx>. Is there an object method that can be overridden to provide a return value when the object is accessed this way?
|
python django class based view and functional view
| 30,764,221 | 0 | 0 | 163 | 0 |
python,django,views
|
This question can be answered by another question:
What is the difference between procedural and object oriented programming?
Class based views provide you the power of OOP. Code becomes reusable and abstract. The modularity improves.
Performance wise, I guess there is no difference between a class based and a function based view. It all depends on with which you are more comfortable. Both are just meant for different styles of programming.
| 0 | 0 | 0 | 0 |
2015-06-10T15:43:00.000
| 2 | 0 | false | 30,761,147 | 0 | 0 | 1 | 1 |
I am just curious that which one is better django's Class Based View or Functional view and why.
I personally feel functional view is quiet easy but its lengthy and class based view can work with few lines of code.
Is there any performance issue with these views?
Can anyone guide me why to use django's CBV ? On later day will functional view be depriciated?
Thank you
|
Using Jmeter OS Process Sampler to collect script data
| 30,803,435 | 1 | 0 | 1,555 | 0 |
python,command,jmeter
|
Hi you just have to print the data you need to pass to jmeter, and then use one (or more) regular expression to extract values.
| 0 | 1 | 0 | 0 |
2015-06-10T15:52:00.000
| 2 | 0.099668 | false | 30,761,322 | 0 | 0 | 1 | 1 |
Is it possible to collect the output of a python script using the "OS Process Sampler"?
My python script does a database query and returns "r1=123 r2=456 r3=789"
Is there a way to collect the r1, r2, r3 values and graph them?
|
How do I Start/Stop AWS RDS Instances using Boto?
| 30,766,635 | 0 | 2 | 4,092 | 0 |
python,amazon-web-services,boto,amazon-rds,rds
|
No, that's probably the best you can do. The RDS API does not support the Stop/Start functionality of EC2 instances.
| 0 | 0 | 0 | 0 |
2015-06-10T20:01:00.000
| 4 | 1.2 | true | 30,766,187 | 0 | 0 | 1 | 2 |
I had a question about Amazon RDS. I wanted to Start/Stop AWS RDS Instances at my need . AWS Console does not allow me to do so.
The Only method I know is to take a snapshot of the rds instance and delete it and when I need it then a create rds instance using that snapshot.
Is there any better way to acheive the same using Boto?
|
How do I Start/Stop AWS RDS Instances using Boto?
| 53,375,932 | 0 | 2 | 4,092 | 0 |
python,amazon-web-services,boto,amazon-rds,rds
|
You can only start or stop AWS RDS instance of single availability zone instances. For your case, you will have to check if the multi-AZ option is enabled or disabled.
Incase your database is in Multiple availability zone, the best way would be to take the snapshot and restore it.
| 0 | 0 | 0 | 0 |
2015-06-10T20:01:00.000
| 4 | 0 | false | 30,766,187 | 0 | 0 | 1 | 2 |
I had a question about Amazon RDS. I wanted to Start/Stop AWS RDS Instances at my need . AWS Console does not allow me to do so.
The Only method I know is to take a snapshot of the rds instance and delete it and when I need it then a create rds instance using that snapshot.
Is there any better way to acheive the same using Boto?
|
Python - Can't install modules on mac
| 30,767,756 | -1 | 0 | 176 | 0 |
python,module,installation
|
You will often have to use sudo on mac, eg sudo python ...
This has been asked multiple times though, try searching before asking.
| 0 | 0 | 0 | 0 |
2015-06-10T21:34:00.000
| 2 | -0.099668 | false | 30,767,702 | 0 | 0 | 1 | 2 |
I've downloaded Beautiful Soup 4.3.2 and CD'ed to the right location on my disk. When I use 'python setup.py install' a load of lines run but then I get this problem:
error: could not create '/Library/Python/2.7/site-packages/bs4': Permission denied
Anyone know why this is?
Thanks a lot!
|
Python - Can't install modules on mac
| 30,770,660 | -1 | 0 | 176 | 0 |
python,module,installation
|
Apparently, your limits of authority is lower a little to install the python.
First, you should change your users to root. commnad:su root
Second,execute commands to install python.
I hope this can help you.
| 0 | 0 | 0 | 0 |
2015-06-10T21:34:00.000
| 2 | -0.099668 | false | 30,767,702 | 0 | 0 | 1 | 2 |
I've downloaded Beautiful Soup 4.3.2 and CD'ed to the right location on my disk. When I use 'python setup.py install' a load of lines run but then I get this problem:
error: could not create '/Library/Python/2.7/site-packages/bs4': Permission denied
Anyone know why this is?
Thanks a lot!
|
Django testing won't run because of syntax error
| 30,778,955 | 0 | 0 | 110 | 0 |
django,python-3.x,unicode,pycharm
|
Ok so I found the problem. as patrys sugested in a comment the file didn't use UTF-8 as encoding. To change that in pycharm I had to go to file->settings->editor->file encodings and change the file encoding for tests to utf-8. After I did that I had to go into the file and re eddit the § as they have now turned into question marks. However it still didn't work. I found out that I also have to change it to UTF-8 down in the right corner of pycharm. For some reason tests is the only .py file that was affected by this (even though I deleted the original tests.py file and remade it).
| 0 | 0 | 0 | 1 |
2015-06-11T10:35:00.000
| 1 | 0 | false | 30,778,437 | 0 | 0 | 1 | 1 |
When I run my tests I get a syntax error: SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa7 in position 0: invalid start byte
The cause of this seems to be that I use a § in a string on line 62. I'm using python 3.4.2 for the project and have used § elsewhere without getting a error. I got a friend to open the project as well, on his screen the § in tests.py showed up as question marks, but this was only in the test files, in the other places it had been used it showed up as normal. I got him to change the § that were showing up as question marks to § on his pc and it worked, which is really weird. How would I go about fixing something like this on my computer though? I can't really get him to load up the file and insert special character every time I want to use them in tests.
edit: So I found out pycharm for some reason had set only tests.py to a encoding other than utf-8. I changed this to utf-8 and it then showed the § I had written as question marks. However swapping them out for § did not work for me. The reason is that for some reason even though the encoding is set to utf-8, pycharm still displays latin1 for me and type latin1 characters instead of utf-8. I've tested on 2 other computers (1 mac, and 1 windows 8.1 same as the one I have problems with) where it correctly displays utf-8. On those computers my § still appear as question marks, but if i change it on the other computer it now appears as § on the computer with the problem. So my problem now is to get pycharm to properly use UTF-8 instead of latin 1.
|
I want to write a django application that can respond to the HttpClient requests from an android device. Can I have an example code?
| 30,787,714 | 0 | 0 | 131 | 0 |
android,python,django,networking,android-networking
|
Django doesn't care what the client is, and Android's HttpClient don't care whether the url are served by Django, Tomcat, Rails, Apache or whatever. It's only HTTP. IOW:
learn to write a Django App (it's fully documented)
learn to use the Android's HttpClient (it's fully documented too IIRC)
connect the dots...
| 0 | 0 | 0 | 0 |
2015-06-11T16:58:00.000
| 2 | 0 | false | 30,786,979 | 0 | 0 | 1 | 1 |
I am working on a sensor app in android and I've to store the accelerometer readings on a django server and then retrieve them on my device. I am new to django and I don't know how to communicate with Android's HttpClient and a django server.
|
How to automate the android phone back button using appium
| 40,546,232 | 11 | 9 | 25,243 | 0 |
android,python,navigation,ui-automation,appium
|
I guess maybe it depends on what version of the client library are you using because in Java driver.navigate().back() works well.
| 0 | 0 | 1 | 0 |
2015-06-12T11:25:00.000
| 8 | 1 | false | 30,801,879 | 0 | 0 | 1 | 4 |
I am working on test automation for a hybrid mobile application on Android using Appium(python client library). I haven't been able to figure out any means to automate or create a gesture for using the Phone back button to go back to the previous page of the app. Is there any driver function that can be used? I tried my luck with self.driver.navigate().back() [hoping this would simulate the same behaviour as in Selenium to navigate to the previous URL] but to no avail. Can anyone suggest a way out?
|
How to automate the android phone back button using appium
| 31,707,929 | 13 | 9 | 25,243 | 0 |
android,python,navigation,ui-automation,appium
|
Yes,try the driver.back(), it simulates the system back function.
| 0 | 0 | 1 | 0 |
2015-06-12T11:25:00.000
| 8 | 1 | false | 30,801,879 | 0 | 0 | 1 | 4 |
I am working on test automation for a hybrid mobile application on Android using Appium(python client library). I haven't been able to figure out any means to automate or create a gesture for using the Phone back button to go back to the previous page of the app. Is there any driver function that can be used? I tried my luck with self.driver.navigate().back() [hoping this would simulate the same behaviour as in Selenium to navigate to the previous URL] but to no avail. Can anyone suggest a way out?
|
How to automate the android phone back button using appium
| 38,353,103 | 0 | 9 | 25,243 | 0 |
android,python,navigation,ui-automation,appium
|
driver.sendKeyEvent(AndroidKeyCode.BACK);
does the job in Java
| 0 | 0 | 1 | 0 |
2015-06-12T11:25:00.000
| 8 | 0 | false | 30,801,879 | 0 | 0 | 1 | 4 |
I am working on test automation for a hybrid mobile application on Android using Appium(python client library). I haven't been able to figure out any means to automate or create a gesture for using the Phone back button to go back to the previous page of the app. Is there any driver function that can be used? I tried my luck with self.driver.navigate().back() [hoping this would simulate the same behaviour as in Selenium to navigate to the previous URL] but to no avail. Can anyone suggest a way out?
|
How to automate the android phone back button using appium
| 50,558,943 | 1 | 9 | 25,243 | 0 |
android,python,navigation,ui-automation,appium
|
For appium-python-client, to go back you should call this method:
driver.press_keycode(4)
| 0 | 0 | 1 | 0 |
2015-06-12T11:25:00.000
| 8 | 0.024995 | false | 30,801,879 | 0 | 0 | 1 | 4 |
I am working on test automation for a hybrid mobile application on Android using Appium(python client library). I haven't been able to figure out any means to automate or create a gesture for using the Phone back button to go back to the previous page of the app. Is there any driver function that can be used? I tried my luck with self.driver.navigate().back() [hoping this would simulate the same behaviour as in Selenium to navigate to the previous URL] but to no avail. Can anyone suggest a way out?
|
Odoo Reload on button click
| 37,959,512 | -1 | 5 | 10,689 | 0 |
python,python-3.x,odoo,odoo-8
|
Just try this, may help you
'res_model': 'your.model.to.reload',
| 0 | 0 | 0 | 0 |
2015-06-12T12:48:00.000
| 5 | -0.039979 | false | 30,803,511 | 0 | 0 | 1 | 1 |
I want to reload a page in odoo on a click of a button. I tried this:
object_name.refresh()
return {'tag': 'reload'}
but it's not working.
How can I get it?
|
Django south schemamigration KeyError
| 30,805,141 | 0 | 0 | 92 | 0 |
python,django,django-south
|
I figured out the last migration files were accidentally corrupted and caused the KeyError.
| 0 | 0 | 0 | 0 |
2015-06-12T13:50:00.000
| 1 | 0 | false | 30,804,783 | 0 | 0 | 1 | 1 |
I am trying to do a schemamigration in Django with south using the following command where core is the app I would like to migrate.
$ python manage.py schemamigration core --auto
Unfortunately this throws the following KeyError:
KeyError: u"The model 'externaltoolstatus' from the app 'core' is not available in this migration."
Does anybody know a way to how figure out what went wrong or where/when this error was thrown during the migration?
|
Django package naming issues
| 30,811,433 | 0 | 0 | 49 | 0 |
python,django,naming-conventions
|
You can use relative imports likefrom .. import cool_project as long you modules are in a package. I would suggest you to rename your app to something else though. It would create unnecessary complexity
| 0 | 0 | 0 | 0 |
2015-06-12T18:36:00.000
| 1 | 1.2 | true | 30,810,029 | 0 | 0 | 1 | 1 |
I have developed a backend library, say, cool_project. Now I want to build a web interface for it. So I create a Django project. Of course, I want to name it cool_project: my mother told me that Hungarian notation is bad and that the name cool_project is much better than any of cool_project_web etc.
But now I have a collision. As long as I try importing cool_project (the backend one) from django/cool_project/views.py (the views.py of the main Django app) a frontend package is being imported.
Is there any way to import backend project in this case? I tried to add full path to backend package (sys.path.insert(0, "/home/.../...")) but it didn't help.
Or maybe there is some well-known naming convention which helps avoiding such collisions?
|
Flask-WTF File contents lost when form fails validation and user resubmits form
| 30,814,109 | 0 | 2 | 115 | 0 |
python,flask,flask-wtforms
|
As @dirn stated, that is the nature of file uploads. You have two options to get around this.
Save the uploaded file temporarily (especially if its large) while you prompt the user to fix the input error (as suggested by @dirn). This would require extra logic to purge files (assuming the user decides they don't want to submit form anymore or they go to a different page, etc)
Validate your form using javascript so that the file only uploads when the form is actually valid (wtforms doesn't really help you much with this option)
| 0 | 0 | 0 | 0 |
2015-06-12T19:35:00.000
| 1 | 1.2 | true | 30,810,908 | 0 | 0 | 1 | 1 |
I'm having an issue where the contents of an uploaded file, via a FileField, are lost when the user resubmits form. I'm guessing the easy answer is to force the user to re-upload the file however I was wondering if there might be a workaround that can avoid having the user re-upload.
|
Google App Engine : Wrong Serving Url
| 30,824,576 | 0 | 0 | 50 | 0 |
image,google-app-engine,google-app-engine-python,serving
|
Try specifying size=0 in the images.get_serving_url method call.
eg. images.get_serving_url(blob_key, size=0)
| 0 | 1 | 0 | 0 |
2015-06-13T08:40:00.000
| 1 | 0 | false | 30,816,730 | 0 | 0 | 1 | 1 |
I have created a Google App Engine project where it's possible to upload photos. Uploading part is working fine and all the photos are uploaded in proper size. But when I try getting images.get_serving_url , it returns me serving_url appended with lh3.googleusercontent.com but according to GoogleAppEngine documentation it must return serving_url something like lh3.gghpt.com . Also, the problem which comes is that the photos on that serving_url is 4-6 times smaller than the uploaded ones and when I view in the GoogleAppEngine console, all those photos have same size as the uploaded ones. I don't know why GoogleAppEngine is not returning the actual sized images.
|
How to permissions to a group in Django 1.8?
| 30,820,665 | 0 | 0 | 323 | 0 |
python,django,read-write
|
Django Group and Permission applies on model itself. So for a specific entry of document if you want to give access to user in that case you need to change your schema of Document model. Just add a users_who_can_read=ManyToMany(Users), users_who_can_write=ManyToMany(Users), and at your view.py when a user is trying to load a page just check if he is in users_who_can_read or not.
I think it should solve your problem without much problem.
| 0 | 0 | 0 | 0 |
2015-06-13T12:41:00.000
| 1 | 0 | false | 30,818,792 | 0 | 0 | 1 | 1 |
I have a 'Document' model which has many-to-many relationship with User model.There is a separate web page in my project which displays the Document instance in a text editor.
Now suppose user who created one document wants to invite other users to this document.But he wants to give read-only permission to some and read-write permission to others.
How do I implement this permission functionality in Django?How do groups and other permissions frameworks work in Django?
|
Search box/field design with multiple search locations
| 30,852,953 | 0 | 0 | 171 | 0 |
python,search,search-engine,pyramid
|
I could see this being posted to the UX SE (ux.stackexchange.com I think?) site, or they might already have a question there touching on something like this. But personally I would probably lean toward either a dropdown selector with different types, or keeping the separate searches as-is. And I think I'd lean more toward the dropdown box - that doesn't seem unreasonable to me for a search interface.
I guess one question would be - could there be any expectation to want results from more than one of the tables in the same search? If that were the case I could see implementing your unified search idea even though it would mean querying multiple tables. Or some sort of additive interface where you select the tables you'd want to query.
| 0 | 0 | 0 | 0 |
2015-06-15T14:36:00.000
| 2 | 0 | false | 30,847,948 | 0 | 0 | 1 | 2 |
Not sure if this question is better suited for a different StackExchange site but, here goes:
I have a search page that searches a number of different type of things. All (at the moment) requiring a different input field for each type of search. For example, one might search for a school or district name, a class name, a staff member email address, etc. I have 9 different 'type' of searches each with their own input field on the search page. I've already concatenated one of these (a username and UID search) but I'm wondering if it makes sense both design (user friendly) and performance wise to bring these all into one input field (and therefore one singular search)
These different types are of course a number of different tables, so it would have to query a number of different times for each type, just for one search.
Any ideas? or should I just keep it how it is? I could add a drop-down menu to choose a different 'type' of search but that seems just as messy. I'm already doing this for my navbar when not on the main search page (which also happens to be the home page)
My project is written in Python with the Pyramid framework.
|
Search box/field design with multiple search locations
| 30,860,645 | 0 | 0 | 171 | 0 |
python,search,search-engine,pyramid
|
What happens to your search interface if the application changes? This is a very important aspect. Do you add another search type?
A search returns matches on the query string. A result set can contain different entities from different types. Then your search/resultset interface could apply filtering based on entity type or entity facets (examples: Ebay, Amazon)
Learn from Solr/elasticsearch and add-on projects. Faceted search is what users are used to these days. The concept of separating data storage (RDBMS) and full-text search engine is much more powerful and extendable compared to writing complex queries spanning multiple tables. Any larger internet company (Ebay, Facebook, Amazon, Instagram) can tell stories about using the patterns. Separating storage from search offers scalability, flexibility.
Instead of writing query/search code, better learn how to feed these search engines from any data store. This is much more powerful & fun, I promise.
| 0 | 0 | 0 | 0 |
2015-06-15T14:36:00.000
| 2 | 1.2 | true | 30,847,948 | 0 | 0 | 1 | 2 |
Not sure if this question is better suited for a different StackExchange site but, here goes:
I have a search page that searches a number of different type of things. All (at the moment) requiring a different input field for each type of search. For example, one might search for a school or district name, a class name, a staff member email address, etc. I have 9 different 'type' of searches each with their own input field on the search page. I've already concatenated one of these (a username and UID search) but I'm wondering if it makes sense both design (user friendly) and performance wise to bring these all into one input field (and therefore one singular search)
These different types are of course a number of different tables, so it would have to query a number of different times for each type, just for one search.
Any ideas? or should I just keep it how it is? I could add a drop-down menu to choose a different 'type' of search but that seems just as messy. I'm already doing this for my navbar when not on the main search page (which also happens to be the home page)
My project is written in Python with the Pyramid framework.
|
Importing models from a different Django project
| 30,856,157 | 0 | 1 | 92 | 0 |
python,django,django-models
|
Wouldn't there be security issues at letting an external site dictate what your db's structure looks like? A problem of any kind (or a man in the middle attack) could completely modify (or destroy) your database without you doing anything.
I'd say it's better to have API versions than what you're asking for. I'd prefer to have 2 concurrent versions running at the same time, to let the time for the API consumers to update their schemas, than force automatic updates of their schemas and data. And in general, if possible, I'd only use a single API version, taking care to always keep a compatibility with older implementations.
But I'm just saying that for general public API, I don't know how open your API should be and how close your developpements (API and consumer) are, so I may be completely out of your scope!
| 0 | 0 | 0 | 0 |
2015-06-15T20:27:00.000
| 1 | 0 | false | 30,854,395 | 0 | 0 | 1 | 1 |
I am setting up a public API for my app. I want to segregate my API code from my application code, so I am putting it in a new django project and am using "Django REST Framework" to build the scaffolding for the public API services.
I'm struggling with how to keep models in sync between my main application project, and this new Django project for the API... product development may continue in the application project that necessitates models changes, and I'd like those models changes to be propagated to the API project.
Is there a way to point to, or import, models from a different Django project?
|
Django database table naming convention
| 30,872,816 | 3 | 0 | 1,656 | 1 |
python,django,database,naming-conventions
|
The default convention is better and cleaner to use :
It avoids any table naming conflict ( As It's a combination of App name and Model name)
It creates well organized database (Tables are ordered by App names)
So until you have any special case that needs special naming convention , use the default.
| 0 | 0 | 0 | 0 |
2015-06-16T15:57:00.000
| 1 | 0.53705 | false | 30,872,599 | 0 | 0 | 1 | 1 |
What is the convention/best practices for naming database tables in Django... using the default database naming scheme (appname_classname) or creating your own table name (using your own naming conventions) with the meta class?
|
Python select epoll in Gevent
| 30,926,961 | 1 | 0 | 1,187 | 0 |
python,gevent,epoll
|
Gevent does not provide their own epoll implementation yet.
If you don't monkeypatch select it will block the entire process instead of just one greenlet.
| 0 | 0 | 0 | 0 |
2015-06-16T18:22:00.000
| 1 | 1.2 | true | 30,875,263 | 0 | 0 | 1 | 1 |
I'm working on GPIO stuff in Python, need to register the fd on epoll, since gevent monkey patched the python select library, there will not be select.epoll if monkey.patch_all(select=True), so here comes two questions:
Will be consequence that the monkey.patch_all(select=False)?
Or does Gevent provide its own epoll register stuff?
Thank you in advance.
|
Python Relative Imports Only Work With Django
| 30,880,320 | 1 | 0 | 112 | 0 |
python,import
|
You can't simply execute main.py from dir2; you'll need a script of sorts that lives outside your whole app package, and then if you import app.dir2.main, you'll get app.dir1.utils as well through the relative import.
Create a script that does from app.dir2 import main, then run that outside the app package. And use the from ..dir1 import utils in structure in main.py, with 2 leading dots.
I can't give you the exact reason why this is, but I think essentially any script/module executed inside a directory is not going to look up the directory chain to see if it's part of a module. That is, the main.py module will not look into the app directory and think "hey, I'm part of a module, and I can (relatively) import dir1 as well.
| 0 | 0 | 0 | 0 |
2015-06-16T23:47:00.000
| 1 | 1.2 | true | 30,880,102 | 0 | 0 | 1 | 1 |
Hi I use Django frequently and am constantly using relative imports along the lines of from .models import XXX for XXX in a models folder or from . import views for a file named views.py in same directory and it works fine there. But when I create my own Python application with a directory structure such as:
app/ containing __init__.py, dir1, and dir2
dir1/ containing __init__.py, utils.py
dir2/ containing __init__.py, main.py
then say inside of main.py in dir2 I do from .dir1 import utils or even from ..dir1 import utils I get an error like: ValueError: Attempted relative import of non-package
Which I don't understand as there is an __init__.py in all the directories. Why does it always work fine in django projects but not when I start my own python project from scratch?
What should I be doing to import something like this? Obviously absolute imports are not preferred, but I can't get relatives to work. All the answers on SO and other sites that I have found never seems to provide a solution, or at least one that worked for me. Can someone please just tell me what the correct way to do an import like this is? Import a python file from a directory that is a sibling of the directory which contains the file I'm calling import from.
Help would be much appreciated. Perhaps for once we can get a nice short answer that is actually to the point.
All I really need is for someone to show me what I should be using to do this import, and secondarily explain why I don't get this error in django but get it here.
I just want to get the imports working, every time I start my own python application outside Django (because it isn't web based) I have this issue and every answer I find is no help.
EDIT:
The problem I'm having is importing files from anything but a child directory or files within the same directory. The places I have the issue are when the file I need is in a sibling or parent directory. I need help making the import work for that.
|
Creating a centric REST API for a mobile and website application
| 30,932,400 | 0 | 0 | 288 | 0 |
php,python,rest,authentication
|
Actually I doesn't make great sense. From my experience I know that mobile apps and web pages even if use the same backend very often require completely different set of data, and - (I know premature optimization is the root of all evil) - number of calls should be minimized for mobile applications to make them running smoothly. I'd separate mobile API from classic REST API, even with prefixes, e.g. /api/m/ and /api/.
There're really many frameworks in a number of technologies. E.g. spring, django-rest-framework, express.js. Whatever you like.
Token authentication will be the best choice. For both web and mobile. For REST in general.
It shouldn't be a matter for you now.
| 0 | 0 | 1 | 0 |
2015-06-19T01:12:00.000
| 2 | 0 | false | 30,928,370 | 0 | 0 | 1 | 1 |
My next project requires me to develop both a mobile and a website application. To avoid duplicating code, I'm thinking about creating an API that both of these applications would use.
My questions regarding this are:
Is this approach sensible?
Are there any frameworks to help me with this?
How would I handle authentication?
Does this have an affect on scalability?
|
Access control in odoo/openerp
| 31,235,475 | 0 | 2 | 176 | 0 |
python-2.7,openerp,odoo,openerp-8,odoo-8
|
Inherit the write method of the model and give it a raise when your condition (in this case the not owned products) is met. This way the user will receive a warning message and they cannot save the changed values.
| 0 | 0 | 0 | 0 |
2015-06-19T06:59:00.000
| 2 | 0 | false | 30,931,897 | 0 | 0 | 1 | 1 |
How to restrict the users to edit only the product attributes for non owned products in odoo/openerp?
Can this be achieved through record rules or coding?
|
Why are nose tests leaving orphaned PhantomJS processes on Windows 8?
| 30,966,232 | 0 | 1 | 131 | 0 |
python,windows,selenium,phantomjs,chocolatey
|
What version of choco did you use to install PhantomJS (and what version of PhantomJS)? I believe we corrected this issue in most cases, but it is on newer versions of choco - and you need the shim to be generated in that newer version (which means install or upgrade, but we are adding a shim regen command).
| 0 | 0 | 0 | 0 |
2015-06-19T10:09:00.000
| 2 | 0 | false | 30,935,500 | 0 | 0 | 1 | 1 |
I have some Python Selenium nose tests running on Windows 8 with PhantomJS. I installed Chutzpah (PhantomJS) via Chocolatey.
When I run the nose tests, a "ShimGen" process appears and lots of "PhantomJS is a headless WebKit with JavaScript API (32 bit)" processes appear and use 50+mb of memory and never close. This causes a lot of stuck PhantomJS processes in memory.
This eventually brings down the server.
|
Unicode on Scrapy Json output
| 30,964,853 | 1 | 1 | 2,012 | 0 |
python,json,unicode,utf-8,scrapy
|
As I don't have your code to test, Can you try to use codecs
Try:
import codecs
f = codecs.open('yourfilename', 'your_mode', 'utf-8')
f.write('whatever you want to write')
f.close()
| 0 | 0 | 1 | 0 |
2015-06-19T23:34:00.000
| 2 | 0.099668 | false | 30,948,736 | 0 | 0 | 1 | 1 |
I'm having problem on json output of scrapy. Crawler works good, cli output works without a problem. XML item exporter works without a problem and output is saved with correct encoding, text is not escaped.
Tried using pipelines and saving the items directly from there.
Using Feed Exporters and jsonencoder from json library
These won't work as my data includes sub branches.
Unicode text in json output file is escaped like this:
"\u00d6\u011fretmen S\u00fcleyman Yurtta\u015f Cad."
But for xml output file it is correctly written:
"Öğretmen Süleyman Yurttaş Cad."
Even changed the scrapy source code to include ensure_ascii=False for ScrapyJSONEncoder, but no use.
So, is there any way to enforce scrapyjsonencoder to not escape while writing to file.
Edit1:
Btw, using Python 2.7.6 as scrapy does not support Python3.x
This is as standart scrapy crawler. A spider file, settings file and an items file. First the page list is crawled starting from base url then the content is scraped from those pages. Data pulled from the page is assigned to variables defined in items.py of the scrapy project, encoded in utf-8. There's no problem with that, as everything works good on XML output.
scrapy crawl --nolog --output=output.json -t json spidername
Xml output works without a problem with this command:
scrapy crawl --nolog --output=output.xml -t xml spidername
I have tried editing scrapy/contrib/exporter/init.py and scrapy/utils/serialize.py to insert ensure_ascii=False parameter to json.JSONencoder.
Edit2:
Tried debugging again.There's no problem up to Python2.7/json/encoder.py code. Data is intact and not escaped. After that, it gets hard to debug as the scrapy works async and there are lots of callbacks.
Edit3:
A bit of dirty hack, but after editing Python2.7.6/lib/json/encoder.py and changing ensure_ascii parameter to False, the problem seems to be solved.
|
Python Module in Django
| 30,986,554 | 0 | 1 | 765 | 0 |
python,django
|
Definitely go for "way #1". Keeping an independent layer for your service(s) API will help a lot later when you have to enhance that layer for reliability or extending the API.
Stay away from singletons, they're just global variables with a new name. Use an appropriate life cycle for your interface objects. The obvious "instantiate for each request" is not the worst idea, and it's easier to optimize that if needed (by caching and/or memoization) than it's to unroll global vars everywhere.
Keep in mind that web applications are supposed to be several processes on a "shared nothing" design; the only shared resources must be external to the app: database, queue managers, cache storage.
Finally, try to avoid using this API directly from the view functions/CBV. Either use them from your models, or write a layer conceptually similar to the way models are used from the views. No need of an ORM-like api, but keep any 'business process' away from the views, which should be concerned only with the presentation and high level operations. Think "thick model, thin views" with your APIs as a new kind of models.
| 0 | 0 | 0 | 0 |
2015-06-22T17:04:00.000
| 1 | 0 | false | 30,985,798 | 0 | 0 | 1 | 1 |
I am building my first Django web application and I need a bit of advice on code layout.
I need to integrate it with several other applications that are exposed through RESTful APIs and additionally Django's internal data. I need to develop the component that will pull data from various sources, django's DB, format it consistently for output and return it for rendering by the template.
I am thinking of the best way to write this component. There are a couple of ways to proceed and I wanted to solicit some feedback from more experienced web developers on things I may have missed.
Way #1
Develop a completely standalone objects for interacting with other applications via their APIs, etc... This would not have anything related with django and test independently. Then in django, import this module in the views that need it, run object methods to get required data, etc...
If I need to access any of this functionality via a GET request (like through JavaScript), I can have a dedicated view that imports the module and returns json.
Way #2
Develop this completely as django view(s) expose as a series of GET/POST calls that would all call each other to get the work done. This would be directly tied in the application.
Way #3
Start with Way #1, but instead of creating a view, package it as a django app. Develop unit tests on the app as well as the individual objects.
I think that way 1 or 3 would be very much encapsulated and controlled.
Way 2 would be more complicated, but facilitate higher component re-use.
What is better from a performance standpoint? If I roll with Way #1 or 3, would an instance of the object be instantiated for each request?
If so this approach may be a bit too heavy for this. If I proceed with this, can they be singletons?
Anyway, I hope this makes sense.
thanks in advance.
|
GAE golang templates stopped working
| 31,039,704 | 0 | 0 | 50 | 0 |
python-2.7,google-app-engine,go
|
I re-installed Python (the module_test and other tests failed) and updated the gae-go sdk. This fixed my problem. I believe that a recently identified Flash exploit had something to do with it as I experienced a number of Flash crashes in web page ads just before the problems began.
| 0 | 1 | 0 | 0 |
2015-06-23T16:46:00.000
| 1 | 0 | false | 31,008,719 | 0 | 0 | 1 | 1 |
I've been successfully using go for months - last night my app started 404 page not found errors but only on pages that use Templates. Those that don't use the Template system work fine.
I re-installed the Go sdk and discovered that the Guestbook demo ( also uses Templates) doesn't work either. ... and then I noticed that links to the log files weren't appearing on the Instance page of the dev console - but when I click the "default" link it displayed the guestbook templated page that I had just requested and got the 404.
It seems that the system can't find template folder and that is causing the 404s
My configuration seems to have broken and I haven't been able to figure out why - hope someone can help...
...After messing with environment variables and stuff for a while with no success, I ran "test_Python" file. These all generated Errors: test_too_big_rewrite, module_test, python_sandbox_test all generated errors - the process hung up on "test_serve"
This is causing my problems? Is there a way to correct? Uninstall and reinstall Python? Will I have to uninstall/reinstall Go SDK ?
thanks!
|
Django Functional Test for Time Delayed Procedure
| 31,042,109 | 0 | 0 | 74 | 0 |
python,django,selenium,functional-testing
|
I've decided that I am just going to call the method of the nightly methods directly, instead of making a truly functional test.
| 0 | 0 | 0 | 0 |
2015-06-23T17:30:00.000
| 2 | 1.2 | true | 31,009,555 | 0 | 0 | 1 | 1 |
I am learning TDD and am using Django and Selenium to do some functional testing. I wanted to make it so that a user selects a checkbox that essentially says "add 1 to this number nightly". Then, for all of the users that have this setting on, a nightly process will automatically increment the number on these accounts.
I want to be able to test this functionality in my functional test in selenium, but I don't know how I would go about it. I obviously don't want to wait a day for the test to finish either. Can someone help me think about how I can get started?
|
Making group in django app.
| 31,019,876 | 1 | 0 | 53 | 0 |
python,django,django-models,django-admin
|
Superusers are special as their permission system returns True on every permission request (it is hardcoded). There is no "super group". You can simply create a group and give it all permissions (so add, change and delete permission to every model).
| 0 | 0 | 0 | 0 |
2015-06-24T06:29:00.000
| 1 | 0.197375 | false | 31,019,164 | 0 | 0 | 1 | 1 |
I am making an app. In which multiple superusers are there and beneath these super user we have multiple user. I am able to make superuser.But I am not able to add user in that for that super user.I am relatively new in django.
|
Django get a DOM object from an HttpResponse
| 31,035,689 | 0 | 0 | 627 | 0 |
python,django,httpresponse
|
Yes that's a way to parse HTML into a DOM tree. If other people don't do that, they might have other requirements.
In general your idea is not bad, it might require more CPU time then other testing method (for example regular expressions. But if it fits your needs for testing, just do it. Performance it rarely a problem at testing time.
| 0 | 0 | 1 | 0 |
2015-06-24T19:27:00.000
| 2 | 0 | false | 31,035,318 | 0 | 0 | 1 | 1 |
I want to do a unit test on a html page which is returned as a byte string in an HttpResponse object... e.g. "find_elements_by_tag_name". Is the solution simply to xml.dom.minidom.parseString the bytes of response.content?
I couldn't find any examples of people doing this online or in Django manuals or tutorials, which makes me wonder if there's a reason for not doing it this way? If it's bad practice and there's a better way to do this please can you say why and what?
|
Is there anyway to run robot framework tests without a display?
| 36,692,169 | 1 | 3 | 2,600 | 0 |
python,selenium,robotframework,xvfb
|
Yes there is with Xvfb installed.
In very short:
/usr/bin/Xvfb :0 -screen 0 1024x768x24&
export DISPLAY=:0
robot your_selenium_test
| 0 | 0 | 1 | 1 |
2015-06-25T08:59:00.000
| 2 | 0.099668 | false | 31,045,708 | 0 | 0 | 1 | 1 |
I prepare some test suites for an e-commerce web site, so i use Selenium2Library which requires a running browser on a display. I am able to run these test on my local machine but i had to run them on remote server which does not have an actual display. I tried to use xvfb to create a virtual display but it did not worked, tried all solutions on some answers here but nothing changed.
So i saw pyvirtualdisplay library of Python but it seems like helpful with tests written in Python. I'd like to know that if I am able to run test suites that i wrote in robotframework (which are .txt formatted and could be runnned via pybot) via Python so i can use pyvirtualdisplay?
Sorry about my English, thanks for your answers...
|
Send multiple POST requests a once
| 31,067,192 | 0 | 2 | 1,192 | 0 |
php,python,ios,server,backend
|
No it should not cause an error, you are requesting the server with an HTTP method(POST) which serves every request from a new user as a new request because HTTP is a stateless protocol it doesn't save user states(unless you are managing user sessions explicitly)
So if 100 users are requesting at the same time, they are different, each request is different and same will be the response(different) for each user.
And as others said, its completely dependent on the server how it handles the request.
| 0 | 0 | 1 | 0 |
2015-06-26T06:33:00.000
| 2 | 0 | false | 31,066,456 | 0 | 0 | 1 | 1 |
I have an iOS app that is send a POST request to my server and then it runs a function and returns some data back to the app.
My question is if my app has lets say 100 people using it at the same time and make the POST request in quick succession, is this going to case an error?
I am on a shared server if that matters.
|
What the difference between SOCIAL_AUTH_USER_MODEL(django-social-auth) and AUTH_USER_MODEL(Django)?
| 31,069,180 | 1 | 0 | 1,091 | 0 |
python,django,authentication,django-socialauth
|
To override the default django user model use AUTH_USER_MODEL. To use django-social-auth with the new model point to it by using SOCIAL_AUTH_USER_MODEL. Both use auth.User by default.
| 0 | 0 | 0 | 0 |
2015-06-26T07:25:00.000
| 1 | 1.2 | true | 31,067,386 | 0 | 0 | 1 | 1 |
A bit frustrated about this.
What the difference between those options?
Which I need to use to override default django user model?
What the value SOCIAL_AUTH_USER_MODEL has by default?
|
Processing data from Google App Engine on a Google Virtual Machine
| 31,260,767 | 0 | 1 | 47 | 0 |
python,google-app-engine,virtual-machine,google-cloud-platform
|
Sticking with the described POST request using urllib2. We decided we might move this part of the project to a different provider so better to not use Google Cloud only methods.
| 0 | 1 | 0 | 0 |
2015-06-26T08:23:00.000
| 1 | 1.2 | true | 31,068,381 | 0 | 0 | 1 | 1 |
My website runs on Python on Google App Engine, and I've setup a Virtual Machine to use libraries that weren't supported by the default App Engine environment. Now I need to send data from my app to the VM and retrieve the response. Data in this case will be an email address and an email message.
Currently I am testing with a POST request through urllib2. Is there a better way to do this?
|
Is it feasible to unpickle large amounts of data in a Python web app that needs to be scalable?
| 31,069,570 | 0 | 2 | 1,053 | 0 |
python,flask,scalability,binaryfiles
|
Pickle files is good way to load data in python. By the way consider using the C implementation: cPickle.
If you want to scale, using pickle files. Ideally you want to look for a partition key, that fits for your data and your project needs.
Let's say for example you have historical data, instead of having a single file with all historical data, you can create a pickle file per date.
| 0 | 0 | 0 | 0 |
2015-06-26T08:43:00.000
| 2 | 0 | false | 31,068,690 | 0 | 0 | 1 | 1 |
I am working on my first web application. I am doing it in Python with Flask, and I want to run a piece of Python code that takes an object, with Pickle, from a (binary) file of several MB which contains all the necessary data. I have been told that so using Pickle in a web app is not a good idea because of scalability; why?
Obviously, for a given purpose it's better to take just the necessary data. However, if I do this, with an Elasticsearch database and in the fastest way I can, the whole process takes about 100 times more time than if I take all the data at once from the binary; once the binary is unpickled, which will take at most one second, the computations are very fast, so I am wondering if I should use the binary file, and if so, how to do it in a scalable way.
|
If, Else inside html using Django templates
| 31,069,665 | 1 | 0 | 4,761 | 0 |
python,html,django,if-statement
|
There is no if-then control explanation in HTML, or whatever other programming capacities. HTML is a markup dialect. Writing computer programs isn't conceivable.
Css will permit you to pick between styles in light of classes and IDs.
You can do this sort of thing with JavaScript, yet you can keep it straightforward with CSS.
| 0 | 0 | 0 | 0 |
2015-06-26T09:16:00.000
| 4 | 0.049958 | false | 31,069,347 | 0 | 0 | 1 | 2 |
I have a Django project that consists of many html pages.
I want to add an if else condition inside my html tag to return "None" whenever the time stamp = 0000-00-00 00:00:00 and return the time when it's not. My code is shown below, I used a tag to get the time in date format.
<td>{{ table.start_time|date:"Y-m-d G:i:s"}}</td>
|
If, Else inside html using Django templates
| 31,070,870 | 2 | 0 | 4,761 | 0 |
python,html,django,if-statement
|
I just used another tag:
<td>{{ table.start_time|date:"Y-m-d G:i:s"|default:"None"}}</td>
Thanks all!!
| 0 | 0 | 0 | 0 |
2015-06-26T09:16:00.000
| 4 | 1.2 | true | 31,069,347 | 0 | 0 | 1 | 2 |
I have a Django project that consists of many html pages.
I want to add an if else condition inside my html tag to return "None" whenever the time stamp = 0000-00-00 00:00:00 and return the time when it's not. My code is shown below, I used a tag to get the time in date format.
<td>{{ table.start_time|date:"Y-m-d G:i:s"}}</td>
|
How to fully develop Django projects in the cloud?
| 31,069,855 | 0 | 0 | 134 | 0 |
python,django,cloud
|
Developing directly in production environment is highly discouraged. You should develop locally using version control systems (git) and test suites to check everything works before the deploy.
Once you've checked everything works, you can pull changes from the remote repository to apply the modifications or use something like jenkins for continuous integration.
But, if you still want to modify your code directly in the cloud. Pycharm is a nice IDE that allows you to work with remove projects. I don't know if this is possible with Sublime.
| 0 | 0 | 0 | 0 |
2015-06-26T09:20:00.000
| 2 | 0 | false | 31,069,449 | 0 | 0 | 1 | 1 |
I have been working with Django on Linux with Sublime Text for a while, but I constantly switch to Windows for graphics design and gaming. I wonder what's the most effective way to develop Django completely in the cloud without having to setup new Django environment for every OS I touch. It would be fantastic if I can just sync the project files from DigitalOcean and edit them on Sublime Text, since online IDEs/terminal from PythonAnywhere, Cloud9, etc. are quite slow and unresponsive.
|
Django Python Social Auth, Authentication Canceled by Facebook app
| 31,138,364 | 2 | 0 | 3,048 | 0 |
django,facebook,python-social-auth
|
I did wrong Facebook app setup. In the Security / Server IP Whitelist I put 127.0.0.1 address. The problem was gone after removing this address (blank space is okey).
| 0 | 0 | 0 | 0 |
2015-06-26T16:27:00.000
| 2 | 0.197375 | false | 31,077,965 | 0 | 0 | 1 | 2 |
I am trying to implement website login using Facebook credentials. I see different responses when I press Cancel on Facebook widget or Okay. When I press Cancel I see the following
Environment:
Request Method: GET
Request URL: http://wakevent.com/complete/facebook/?redirect_state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT&error=access_denied&error_code=200&error_description=Permissions+error&error_reason=user_denied&state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT
Django Version: 1.8.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainapp',
'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
51. return func(request, backend, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/views.py" in complete
28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py" in complete
41. return self.auth_complete(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in wrapper
229. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in auth_complete
68. self.process_error(self.data)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in process_error
60. super(FacebookOAuth2, self).process_error(data)
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in process_error
363. raise AuthCanceled(self, data.get('error_description', ''))
Exception Type: AuthCanceled at /complete/facebook/
Exception Value: Authentication process canceled
Which is predicatble. But when I press Okay I see another error.
Environment:
Request Method: GET
Request URL: http://wakevent.com/complete/facebook/?redirect_state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT&code=AQBe5WWQYk9BJE2fvNIt0RWVYxLaddhXT6t3UQwtF3aJcvbbLrVwsMlxsKEgwulVAtV4WHlYG5lG1HbEHk_cjFhMfWEHy9B8dedrOZagw0AWyGVyvaFtRqOn8_3G8nQb2nEe-DZMdG13V7Jgzrebtu6QXxGuyNzZPVXRnbPiKGUz8jW2p-r_wWB7QAuW-6rdZuII8_1ePBBoGgzmLlKLvMLfZoCqI62h0slF5t2IoAraHahRtnkWeIeH6AVf5u4vzZ8qXatz9fuun8ZK-8rqv5p5HDWZOdydNGm7ZtNh0g1OSpZU4TFAGxAqWbo0LpgiCRs&state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT
Django Version: 1.8.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainapp',
'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
51. return func(request, backend, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/views.py" in complete
28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py" in complete
41. return self.auth_complete(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in wrapper
232. raise AuthCanceled(args[0])
Exception Type: AuthCanceled at /complete/facebook/
Exception Value: Authentication process canceled
I am running the website locally on Ubuntu 14.04 apache web server with 80 port. I suspect wrong Facebook app setup but do not know what to debug.
Also, I can mention that Twitter login is working on the same setup.
Please advise!
|
Django Python Social Auth, Authentication Canceled by Facebook app
| 36,288,484 | 0 | 0 | 3,048 | 0 |
django,facebook,python-social-auth
|
Check the redirect URL. I had wrongly specified redirect URL along with client ID while making post request. For Facebook redirect URI is optional. Try removing that and it will work fine.
| 0 | 0 | 0 | 0 |
2015-06-26T16:27:00.000
| 2 | 0 | false | 31,077,965 | 0 | 0 | 1 | 2 |
I am trying to implement website login using Facebook credentials. I see different responses when I press Cancel on Facebook widget or Okay. When I press Cancel I see the following
Environment:
Request Method: GET
Request URL: http://wakevent.com/complete/facebook/?redirect_state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT&error=access_denied&error_code=200&error_description=Permissions+error&error_reason=user_denied&state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT
Django Version: 1.8.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainapp',
'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
51. return func(request, backend, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/views.py" in complete
28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py" in complete
41. return self.auth_complete(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in wrapper
229. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in auth_complete
68. self.process_error(self.data)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in process_error
60. super(FacebookOAuth2, self).process_error(data)
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in process_error
363. raise AuthCanceled(self, data.get('error_description', ''))
Exception Type: AuthCanceled at /complete/facebook/
Exception Value: Authentication process canceled
Which is predicatble. But when I press Okay I see another error.
Environment:
Request Method: GET
Request URL: http://wakevent.com/complete/facebook/?redirect_state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT&code=AQBe5WWQYk9BJE2fvNIt0RWVYxLaddhXT6t3UQwtF3aJcvbbLrVwsMlxsKEgwulVAtV4WHlYG5lG1HbEHk_cjFhMfWEHy9B8dedrOZagw0AWyGVyvaFtRqOn8_3G8nQb2nEe-DZMdG13V7Jgzrebtu6QXxGuyNzZPVXRnbPiKGUz8jW2p-r_wWB7QAuW-6rdZuII8_1ePBBoGgzmLlKLvMLfZoCqI62h0slF5t2IoAraHahRtnkWeIeH6AVf5u4vzZ8qXatz9fuun8ZK-8rqv5p5HDWZOdydNGm7ZtNh0g1OSpZU4TFAGxAqWbo0LpgiCRs&state=cvZGNl42bKvgcDDDezBy14VJ1Eit5OmT
Django Version: 1.8.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainapp',
'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
51. return func(request, backend, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/views.py" in complete
28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py" in complete
41. return self.auth_complete(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in wrapper
232. raise AuthCanceled(args[0])
Exception Type: AuthCanceled at /complete/facebook/
Exception Value: Authentication process canceled
I am running the website locally on Ubuntu 14.04 apache web server with 80 port. I suspect wrong Facebook app setup but do not know what to debug.
Also, I can mention that Twitter login is working on the same setup.
Please advise!
|
Where did Flask-Admin's `hide_backrefs` option go? How to display backrefs in admin list view?
| 31,249,046 | 2 | 0 | 115 | 0 |
python,flask,flask-admin
|
This option was removed because you can explicitly add id field to the create and edit forms.
| 0 | 0 | 0 | 0 |
2015-06-26T19:12:00.000
| 1 | 0.379949 | false | 31,080,544 | 0 | 0 | 1 | 1 |
Previous version of Flask-Admin had a hide_backrefs option which could be set to False if you wanted to show them in the admin view.
The current version seems to have it no longer. Does it go by some other name? If I want to display backreferences in the admin list view, is there a better solution than just manually setting columns_list?
|
TypeError: SetStrength() missing 1 required positional argument: 'strength'
| 31,106,283 | 0 | 0 | 84 | 0 |
python,oop
|
That method is defined as def SetStrength(self, strength):. That means that, in addition to the self which is passed automatically, you need to provide an additional argument - in this case, the new strength value you'd like to set. It works very similarly to setName, which you call with an argument on the previous line.
That said, the code you're working with is Java/C++/etc. code translated into Python, which balloons the size of the code for no good reason.
| 0 | 0 | 0 | 0 |
2015-06-29T00:32:00.000
| 2 | 0 | false | 31,106,242 | 0 | 0 | 1 | 1 |
Error fixed - I only needed one parameter in the headers of the setters. Thanks
|
Can Java Web Start be used to run server-side programs?
| 31,113,115 | 1 | 0 | 94 | 0 |
java,python,tomcat,java-web-start
|
Java WebStart will install a desktop application into the cache of the client. That will run on the client not on the server, however you can easily create a webapplication as a service, i.e. on Tomcat. The webapp will be able to receive client requests, i.e. via RMI, RESTfull service or webservice, call the proprietary programm and return the results.
| 0 | 0 | 1 | 0 |
2015-06-29T09:37:00.000
| 1 | 0.197375 | false | 31,112,366 | 0 | 0 | 1 | 1 |
I have a Java application that needs to run the proprietary software PowerWorld on the server and then return output to the client side Web Start window. Is this possible? How do I go about doing this?
I am using Apache Tomcat to run the server. My Java code uses Runtime.exec() to run a Python script that runs PowerWorld. I made sure that the python script, powerworld file and java app are all in the same directory and reference each other using relative file paths
|
IPython notebook Jupyter cannot download as .py
| 66,611,829 | 0 | 0 | 1,573 | 0 |
ipython-notebook,jupyter
|
Try refreshing the web page and download as .py should show up.
| 0 | 0 | 0 | 0 |
2015-06-29T18:18:00.000
| 2 | 0 | false | 31,122,778 | 1 | 0 | 1 | 1 |
After I open Jupyter and write down codes, I want to download it as .py file, but it is always downloaded as HTML. How can I fix it?
|
How do I print a list from views.py to the console?
| 31,124,296 | 6 | 2 | 18,314 | 0 |
python,django
|
If you are using the runserver command, you will see the output of print-statements in that command prompt, like a live logging.
| 0 | 0 | 0 | 0 |
2015-06-29T19:41:00.000
| 3 | 1 | false | 31,124,202 | 0 | 0 | 1 | 1 |
I'm a near-total newbie to Django, and am trying to debug a piece of code which is returning a null list to a template even though it should be returning a list with items in it. Is there any way to print the list to the console from within views.py for debugging purposes? I obviously can't run python views.py as the info I want is stored in a SQLite database, but if I try to include a print statement within the view I'm using, nothing prints when I refresh the page (and the server contacts my code). Is there a solution? I've looked around for a long time and can't find anything.
|
Require the user to change their password on first login?
| 31,168,478 | 2 | 1 | 2,193 | 0 |
python,django
|
In short, yes.
You need to know which users need to change their password. If you don't want to use a custom User model, I would recommend having another model to store the users that need to change their password. You would add the users to this table upon user registration/creation.
Then you could write a very simple middleware to check the current logged user (place it after AuthenticationMiddleware in your settings.py). If the user is flagged as requiring a password change, you could force a HttpResponse (in the middleware) to a custom view with a PasswordChangeForm (which comes out of the box in Django, in django.contrib.auth.forms.PasswordChangeForm), after which you could remove the flag to the user, and redirect them to the home page.
| 0 | 0 | 0 | 0 |
2015-07-01T16:59:00.000
| 1 | 0.379949 | false | 31,167,457 | 0 | 0 | 1 | 1 |
I would like to force the user to change their password on first login. Can I do this with the default django authentication system?
|
It's possible to do an XHR call and render the output with Selenium?
| 31,212,344 | 0 | 3 | 1,233 | 0 |
python,selenium,automation,webdriver
|
Selenium is really designed to be an external control system for a web browser. I don't think of it as being the source of test data, itself. There are other unit-testing frameworks which are designed for this purpose, but I see Selenium's intended purpose to be different.
| 0 | 0 | 1 | 0 |
2015-07-03T17:46:00.000
| 3 | 0 | false | 31,212,059 | 0 | 0 | 1 | 1 |
Well, the title says it all... It is possible to perform an XmlHttpRequest from Selenium/Webdriver and then render the output of that requests in a browser instance ? If so, can you enlight me please ?
|
Effectively communicating between two Django applications on two servers (Multitenancy)
| 31,227,735 | 1 | 0 | 843 | 1 |
python,django,web-deployment,multi-tenant,saas
|
You could use different settings files, let's say settings_client_1.py and settings_client_2.py, import common settings from a common settings.py file to keep it DRY. Then add respective database settings.
Do the same with wsgi files, create one for each settings. Say, wsgi_c1.py and wsgi_c2.py
Then, in your web server direct the requests for client1.djangoapp.com to wsgi_c1.py and client2.djangoapp.com to wsgi_c2.py
| 0 | 0 | 0 | 0 |
2015-07-05T00:30:00.000
| 1 | 1.2 | true | 31,226,223 | 0 | 0 | 1 | 1 |
I'm hoping to be pointed in the right direction as far as what tools to use while in the process of developing an application that runs on two servers per client.
[Main Server][Client db Server]
Each client has their own server which has a django application managing their respective data, in addition to serving as a simple front end.
The main application server has a more feature-rich front end, using the same models/db schemas. It should have full read/write access to the client's database server.
The final desired effect would be a typical SaaS type deal:
client1.djangoapp.com => Connects to mysql database @ client1_IP
client2.djangoapp.com => Connects to mysql database @ client2_IP...
Thanks in advance!
|
Install in user site-package
| 31,247,842 | 1 | 0 | 78 | 0 |
python,easy-install,manual
|
User site-package refers to packages installed in ~/.local/lib[64]/python-VERSION/site-packages/
These packages are available as any other installed packages, but only to this specific user. It overrides system packages too.
| 0 | 0 | 0 | 0 |
2015-07-06T13:45:00.000
| 1 | 1.2 | true | 31,247,510 | 1 | 0 | 1 | 1 |
I have red at the help-page of easy_install that I have an ability to do "install in user site-package". What does this phase mean, "user site-package"? How does it affect functionality of the installed software?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.