megatux / drf-streaming-csv-example

Django DRF example of a CSV generation with StreamingHttpResponse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django App with Django Rest Framework (DRF)

This is a Django app powered by the Django Rest Framework (DRF) that provides a sample of a simple streaming endpoint with HTTP streaming of a CSV file generation.

Getting Started

These instructions will help you set up and run the project on your local machine for development and testing purposes.

Prerequisites

Before you begin, make sure you have the following installed:

  • Python (3.x recommended)
  • pip (Python package manager)
  • Virtual environment (optional but recommended) like pipenv

Installation

  1. Clone the repository:

    git clone https://github.com/megatux/drf-streaming-csv-example.git

1. Navigate to the project directory:

```bash
cd drf-streaming-csv-example
  1. Create a virtual environment (optional but recommended):
python -m venv venv
  1. Activate the virtual environment (if created):

On Windows:

venv\Scripts\activate

On macOS and Linux:

source venv/bin/activate
  1. Install project dependencies:
pipenv install --dev
  1. Run database migrations:
python manage.py migrate
  1. Create a superuser account for admin access (follow the prompts):
python manage.py createsuperuser
  1. Running the Development Server

Start the development server:

python manage.py runserver

The app will be available at http://localhost:8000/.

Test the streaming /users/streaming_view/ endpoint

You can use a tool like curl to hit the endpoint, for example:

curl -vv --raw "http://127.0.0.1:8000/users/streaming_view/"

Running Tests

To run tests, use the following command:

pytest

Contributing

If you would like to contribute to this project, please follow our contribution guidelines.

License

This project is licensed under the GNU General Public License (GPL) version 3.

Acknowledgments

Django Django Rest Framework

Contact

If you have any questions or need assistance, please contact me.

About

Django DRF example of a CSV generation with StreamingHttpResponse


Languages

Language:Python 100.0%