Documenting a Django Rest Framework API
I'm using DRF for the first time to create a read-only API. It all works fine, but I'm trying to work out how to automatically generate some documentation for it.
I've got a Swagger UI page up and running using [django-rest-swagger](https://marcgibbons.com/django-rest-swagger/), which is OK... but some of my API endpoints have optional GET arguments and I can't see any way to document those in a nice way. I can mention them in comments on my DRF Views, but I thought there'd be a way to format them nicely, maybe have them appear as fields in the Swagger UI, like `lookup_url_kwarg`s do.
I'm going round in circles, reading the DRF [Documenting your API documentation](http://www.django-rest-framework.org/topics/documenting-your-api/), all the third-party tools they mention there, laborious workarounds like [this](https://github.com/m-haziq/django-rest-swagger-docs#advance-usage)...
Does anyone have a good, thorough example of how to nicely document a DRF API?
/r/django
https://redd.it/8b9kjo
I'm using DRF for the first time to create a read-only API. It all works fine, but I'm trying to work out how to automatically generate some documentation for it.
I've got a Swagger UI page up and running using [django-rest-swagger](https://marcgibbons.com/django-rest-swagger/), which is OK... but some of my API endpoints have optional GET arguments and I can't see any way to document those in a nice way. I can mention them in comments on my DRF Views, but I thought there'd be a way to format them nicely, maybe have them appear as fields in the Swagger UI, like `lookup_url_kwarg`s do.
I'm going round in circles, reading the DRF [Documenting your API documentation](http://www.django-rest-framework.org/topics/documenting-your-api/), all the third-party tools they mention there, laborious workarounds like [this](https://github.com/m-haziq/django-rest-swagger-docs#advance-usage)...
Does anyone have a good, thorough example of how to nicely document a DRF API?
/r/django
https://redd.it/8b9kjo
Marcgibbons
Django REST Swagger
Swagger UI / OpenAPI Documentation for Django REST Framework
JupyterCon 2018: Registration Open
https://blog.jupyter.org/jupytercon-2018-registration-open-3b52abba9cce
/r/IPython
https://redd.it/8bhraz
https://blog.jupyter.org/jupytercon-2018-registration-open-3b52abba9cce
/r/IPython
https://redd.it/8bhraz
Jupyter Blog
JupyterCon 2018: Registration Open
Dear Jupyter Community,
Adding multiple images to Django Post
https://youtu.be/jjdeOp_E7OU
/r/djangolearning
https://redd.it/8bgwgz
https://youtu.be/jjdeOp_E7OU
/r/djangolearning
https://redd.it/8bgwgz
YouTube
Learn Django - The Easy Way | Adding Multiple Images using Model Formsets | Tutorial - 39
In this video lecture, we will allow the user to upload multiple images in post detail view using Model Formsets.
Find the links below to connect with me:
linkedin Profile: https://www.linkedin.com/in/abhishekvrm444
Facebook Page: https://www.facebook.com/Learn…
Find the links below to connect with me:
linkedin Profile: https://www.linkedin.com/in/abhishekvrm444
Facebook Page: https://www.facebook.com/Learn…
How to properly implement a button to change state.
In a project I'm working on I'd like to have a button that would change an object's state from one to another
For example
`MyObject.approved = True`
Right now I'm using a button wrapped inside form tags with a csrf_token tag, is this the way to do it or is there another one?
/r/djangolearning
https://redd.it/8biczy
In a project I'm working on I'd like to have a button that would change an object's state from one to another
For example
`MyObject.approved = True`
Right now I'm using a button wrapped inside form tags with a csrf_token tag, is this the way to do it or is there another one?
/r/djangolearning
https://redd.it/8biczy
reddit
How to properly implement a button to change state. • r/djangolearning
In a project I'm working on I'd like to have a button that would change an object's state from one to another For example `MyObject.approved =...
(x-posting from r/djangolearning): Fighting with AJAX [QUESTION]
https://www.reddit.com/r/djangolearning/comments/8bhs6p/fighting_with_ajax/
/r/django
https://redd.it/8bhva3
https://www.reddit.com/r/djangolearning/comments/8bhs6p/fighting_with_ajax/
/r/django
https://redd.it/8bhva3
reddit
Fighting with AJAX • r/djangolearning
I'm working on using AJAX to allow for file uploads to my website. I don't necessarily need even a direct solution (though that would certainly be...
How does Jupyter find modules?
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I specify where any given instance of Jupyter Notebook looks for modules?
A possibly related question: When I use `jupyter --path`, I see a listing of directories under the "data" heading. Is this where Jupyter looks for modules, and if so, what file do I edit to change it?
/r/IPython
https://redd.it/8biqq7
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I specify where any given instance of Jupyter Notebook looks for modules?
A possibly related question: When I use `jupyter --path`, I see a listing of directories under the "data" heading. Is this where Jupyter looks for modules, and if so, what file do I edit to change it?
/r/IPython
https://redd.it/8biqq7
reddit
How does Jupyter find modules? • r/IPython
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I...
Jupyter background data storage is confusing
For example:
> from abc import xyz as 123 # creates alias 123 for xyz
Then I delete the code above, replace it with the code below and rerun the cell.
> from abc import xyz
Nonetheless, alias 123 remains functional as it stored in memory and is only erased if you restart the kernel.
This leads to confusion (or forces you to keep track of more things) when you run the code after making edits - some errors are not raised because their dependencies (such as 123) are stored an remain accessible.
Also, all variables (even those defined within a function) are global.
My intuition is that these differences (from normal ide coding environment) will result in confusion and I want to turn of this feature; however, it might be the case that I am misusing Jupyter and these features are in fact advantageous. If so, can you please educate me?
Thank you very much
Edit: formating
/r/IPython
https://redd.it/8blldv
For example:
> from abc import xyz as 123 # creates alias 123 for xyz
Then I delete the code above, replace it with the code below and rerun the cell.
> from abc import xyz
Nonetheless, alias 123 remains functional as it stored in memory and is only erased if you restart the kernel.
This leads to confusion (or forces you to keep track of more things) when you run the code after making edits - some errors are not raised because their dependencies (such as 123) are stored an remain accessible.
Also, all variables (even those defined within a function) are global.
My intuition is that these differences (from normal ide coding environment) will result in confusion and I want to turn of this feature; however, it might be the case that I am misusing Jupyter and these features are in fact advantageous. If so, can you please educate me?
Thank you very much
Edit: formating
/r/IPython
https://redd.it/8blldv
reddit
Jupyter background data storage is confusing • r/IPython
For example: > from abc import xyz as 123 # creates alias 123 for xyz Then I delete the code above, replace it with the code below and rerun...
Is there a Flask tutorial for e-commerce website ?
https://www.reddit.com/r/Python/comments/8bitzo/is_there_a_flask_tutorial_for_ecommerce_website/
/r/flask
https://redd.it/8bj3ic
https://www.reddit.com/r/Python/comments/8bitzo/is_there_a_flask_tutorial_for_ecommerce_website/
/r/flask
https://redd.it/8bj3ic
reddit
Is there a Flask tutorial for e-commerce website ? • r/Python
I have been searching online for building e-commerce website using Flask but could not find anything. Though there are plenty of Django based...
Obfuscate your python script by converting it to emoji icons
https://github.com/chris-rands/emojify_python_script
/r/Python
https://redd.it/8bg4pn
https://github.com/chris-rands/emojify_python_script
/r/Python
https://redd.it/8bg4pn
GitHub
chris-rands/emojify_python_script
Obfuscate your python script by converting an input script to an output script that functions the same (hopefully) but encodes the code as emoji icons, currently emoticons. - chris-rands/emojify_py...
Tips on understanding Django sessions.
So I've been learning and using Django for a while now. Recently I was in need of using Django's session framework but to be honest I still don't fully understand it. And when it comes to Django's documentation I find it a bit to technical for my understanding. Is there anyone that knows a good source that explains using the session framework?
/r/djangolearning
https://redd.it/8bl3kr
So I've been learning and using Django for a while now. Recently I was in need of using Django's session framework but to be honest I still don't fully understand it. And when it comes to Django's documentation I find it a bit to technical for my understanding. Is there anyone that knows a good source that explains using the session framework?
/r/djangolearning
https://redd.it/8bl3kr
reddit
Tips on understanding Django sessions. • r/djangolearning
So I've been learning and using Django for a while now. Recently I was in need of using Django's session framework but to be honest I still don't...
A new package index for Python
https://lwn.net/SubscriberLink/751458/709bd37b03846a61/
/r/Python
https://redd.it/8bmjcs
https://lwn.net/SubscriberLink/751458/709bd37b03846a61/
/r/Python
https://redd.it/8bmjcs
lwn.net
A new package index for Python
The Python Package Index (PyPI) is
the principal repository of libraries for the Python programming language,
serving more than 170 million downloads each week. Fifteen years after PyPI
launched, a new edition is in beta at pypi.org, with features like better…
the principal repository of libraries for the Python programming language,
serving more than 170 million downloads each week. Fifteen years after PyPI
launched, a new edition is in beta at pypi.org, with features like better…
[D] DeepMimic's Video
https://www.youtube.com/watch?v=8KdDwRLtNHQ&t=5s
/r/MachineLearning
https://redd.it/8bjvtc
https://www.youtube.com/watch?v=8KdDwRLtNHQ&t=5s
/r/MachineLearning
https://redd.it/8bjvtc
YouTube
SIGGRAPH 2018: DeepMimic paper (supplementary video)
Extra supplementary video accompanying the SIGGRAPH 2018 paper: "DeepMimic: Example-Guided Deep Reinforcement Learning of Physics-Based Character Skills". Ma...
How to create widgets within same row?
I'm trying to a column of different widgets but can't seem to find anything like it.
For clarity: https://imgur.com/a/7L1q0
/r/IPython
https://redd.it/8blu3z
I'm trying to a column of different widgets but can't seem to find anything like it.
For clarity: https://imgur.com/a/7L1q0
/r/IPython
https://redd.it/8blu3z
Imgur
Ipython Widget
Imgur: The magic of the Internet
django-firebird 1.9.1 is released
https://www.firebirdnews.org/django-firebird-1-9-1-is-released/
/r/django
https://redd.it/8bo5i8
https://www.firebirdnews.org/django-firebird-1-9-1-is-released/
/r/django
https://redd.it/8bo5i8
How to undo migration after pip uninstalling 3rd party package
So I pip installed the django-axes package today. Migrated the migrations that came with it. Then it turned out that the package installed was missing the needed "backends.py" file for some reason. I copied the one on the git repo and dropped it into the installed package folder and it gave me another error.
So I pip uninstalled the whole thing. But looking into my PostgreSQL database, the two tables (axes_accessattempt and axes_accesslog) created by the django-axes migrations are still there.
How is this type of situation handled normally? Just run a SQL command to drop those 2 tables manually? I already have some data in the database, so I don't want to mess it up inadvertently further.
Also, is it normal for a pip install package to be missing vital files?
Thanks.
/r/django
https://redd.it/8bpekc
So I pip installed the django-axes package today. Migrated the migrations that came with it. Then it turned out that the package installed was missing the needed "backends.py" file for some reason. I copied the one on the git repo and dropped it into the installed package folder and it gave me another error.
So I pip uninstalled the whole thing. But looking into my PostgreSQL database, the two tables (axes_accessattempt and axes_accesslog) created by the django-axes migrations are still there.
How is this type of situation handled normally? Just run a SQL command to drop those 2 tables manually? I already have some data in the database, so I don't want to mess it up inadvertently further.
Also, is it normal for a pip install package to be missing vital files?
Thanks.
/r/django
https://redd.it/8bpekc
reddit
How to undo migration after pip uninstalling 3rd party... • r/django
So I pip installed the django-axes package today. Migrated the migrations that came with it. Then it turned out that the package installed was...
Python's Pandas in C++
I have implemented a C++ library with similar interface and functionality to Pandas at https://github.com/hosseinmoein/DataFrame. It still lacks a lot of functionalities which I will add gradually. I appreciates your constructive criticisms and suggestions.
/r/Python
https://redd.it/8bq5js
I have implemented a C++ library with similar interface and functionality to Pandas at https://github.com/hosseinmoein/DataFrame. It still lacks a lot of functionalities which I will add gradually. I appreciates your constructive criticisms and suggestions.
/r/Python
https://redd.it/8bq5js
GitHub
GitHub - hosseinmoein/DataFrame: C++ DataFrame for statistical, financial, and ML analysis in modern C++
C++ DataFrame for statistical, financial, and ML analysis in modern C++ - hosseinmoein/DataFrame
[AF] Handling nested dictionaries with standard python requests library
Hey /r/flask,
I recently got my first [Flask webapp](http://www.asosquery.com/) hosted, and built a relatively simple API around it. It's driven by a very large database full of open meteorological surface observations (more info on the `/about` page), and right now I'm able to query the API with the following sample code (a separate script written for testing):
import requests
import json
r = requests.get('http://www.asosquery.com/api/v1/stations?state=PA&lat={"gt": 39, "lt": 50}')
content = json.loads(r)
This returns JSON-encoded information regarding all [ASOS stations](http://www.nws.noaa.gov/ost/asostech.html) with a latitude greater than 39.00 N and less than 50.00 N. A SQLAlchemy query of the MySQL database is dynamically generated based on the arguments in the `GET` request.
However, I would like to be able to do something like this, following an example on the [requests package documentation](http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls):
import requests # standard python requests package
import json
payload = {
'state': 'PA',
'lat': {
'gt': 39,
'lt': 50
}
}
r = requests.get('http://www.asosquery.com/api/v1/stations', params=payload)
content = json.loads(r)
This exercise fails each time. In the Flask route `/api/v1/stations`, I've tried printing the request made to the server like this:
from flask import request
@app.route('/api/v1/stations', methods=['GET'])
def get_stations():
print(request)
print(request.args)
# -- do the query stuff here -- #
return jsonify(query_results)
But, the output (prior to a raised error) is not as I expected it to be:
# print(request) prints:
<Request 'http://localhost:5000/api/v1/stations?lat=lt&lat=gt&state=PA' [GET]>
# print(request.args) prints:
ImmutableMultiDict([('lat', 'lt'), ('lat', 'gt'), ('state', 'PA')])
I've tried encoding the `payload` as JSON with the following:
r = requests.get('http://www.asosquery.com/api/v1/stations', params=json.dumps(payload), headers={'Content-Type': 'application/json'})
but execution of that code prints the following in from the flask route:
# print(request) prints:
<Request 'http://localhost:5000/api/v1/stations?{"state": "PA", "lat": {"gt": 39, "lt": 50}}' [GET]>
# print(request.args) prints:
ImmutableMultiDict([('{"state": "PA", "lat": {"gt": 39, "lt": 50}}', '')])
Here, I don't really understand why the `requests.args` is formatted like that... The information in the `key` is pretty much what I expect it to be, but the blank `value` is throwing me for a loop. I could probably handle that by just processing the information in the `key`, but that's going to require an extra level of complexity I'd like to be able to avoid.
Anybody know a good workaround? Am I handling the greater-than, less-than functionality in the best way possible?
Thank you in advance to all who offer some insight.
/r/flask
https://redd.it/8bsh8h
Hey /r/flask,
I recently got my first [Flask webapp](http://www.asosquery.com/) hosted, and built a relatively simple API around it. It's driven by a very large database full of open meteorological surface observations (more info on the `/about` page), and right now I'm able to query the API with the following sample code (a separate script written for testing):
import requests
import json
r = requests.get('http://www.asosquery.com/api/v1/stations?state=PA&lat={"gt": 39, "lt": 50}')
content = json.loads(r)
This returns JSON-encoded information regarding all [ASOS stations](http://www.nws.noaa.gov/ost/asostech.html) with a latitude greater than 39.00 N and less than 50.00 N. A SQLAlchemy query of the MySQL database is dynamically generated based on the arguments in the `GET` request.
However, I would like to be able to do something like this, following an example on the [requests package documentation](http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls):
import requests # standard python requests package
import json
payload = {
'state': 'PA',
'lat': {
'gt': 39,
'lt': 50
}
}
r = requests.get('http://www.asosquery.com/api/v1/stations', params=payload)
content = json.loads(r)
This exercise fails each time. In the Flask route `/api/v1/stations`, I've tried printing the request made to the server like this:
from flask import request
@app.route('/api/v1/stations', methods=['GET'])
def get_stations():
print(request)
print(request.args)
# -- do the query stuff here -- #
return jsonify(query_results)
But, the output (prior to a raised error) is not as I expected it to be:
# print(request) prints:
<Request 'http://localhost:5000/api/v1/stations?lat=lt&lat=gt&state=PA' [GET]>
# print(request.args) prints:
ImmutableMultiDict([('lat', 'lt'), ('lat', 'gt'), ('state', 'PA')])
I've tried encoding the `payload` as JSON with the following:
r = requests.get('http://www.asosquery.com/api/v1/stations', params=json.dumps(payload), headers={'Content-Type': 'application/json'})
but execution of that code prints the following in from the flask route:
# print(request) prints:
<Request 'http://localhost:5000/api/v1/stations?{"state": "PA", "lat": {"gt": 39, "lt": 50}}' [GET]>
# print(request.args) prints:
ImmutableMultiDict([('{"state": "PA", "lat": {"gt": 39, "lt": 50}}', '')])
Here, I don't really understand why the `requests.args` is formatted like that... The information in the `key` is pretty much what I expect it to be, but the blank `value` is throwing me for a loop. I could probably handle that by just processing the information in the `key`, but that's going to require an extra level of complexity I'd like to be able to avoid.
Anybody know a good workaround? Am I handling the greater-than, less-than functionality in the best way possible?
Thank you in advance to all who offer some insight.
/r/flask
https://redd.it/8bsh8h