Coder Social home page Coder Social logo

alxmcr / apartify_api_py Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 80 KB

Apartify API: Provide Endpoints to interact with Apartify App (Front-End).

Home Page: https://apartify-api-py.herokuapp.com

Python 99.77% Procfile 0.23%
python django django-rest-framework

apartify_api_py's Introduction

Apartify API REST

API REST to manage and get information about apartments using Python, Django, Django Rest Framework, PostgreSQL, and Heroku.

Features

  • Django Admin
  • Database: PostgreSQL
  • Models
  • Migrations
  • Fixtures
  • URLS (and operations like GET, POST, PUT, and DELETE)
  • Enabled CORS
  • Django Admin filters

Endpoints /v2

  • /v2/countries
  • /v2/countries/:pk
  • /v2/states
  • /v2/states/:pk
  • /v2/cities
  • /v2/cities/:pk
  • /v2/cities_hall
  • /v2/cities_hall/:pk
  • /v2/neighborhoods
  • /v2/neighborhoods/:pk
  • /v2/features
  • /v2/features/:pk
  • /v2/outdoor_spaces
  • /v2/outdoor_spaces/:pk
  • /v2/investments
  • /v2/investments/:pk
  • /v2/apartments
  • /v2/apartments/:pk
  • /v2/photos
  • /v2/photos/:pk
  • /v2/floor_plans
  • /v2/floor_plans/:pk
  • /v2/attracts
  • /v2/outdoors
  • /v2/invests

Lessons Learned

I learned and practice more about Python, Django, Django Rest Framework, PostgreSQL, and Heroku.

Verify PostgreSQL on your computer

a. Official repository

postgres --version

# postgres (PostgreSQL) 14.10 (Ubuntu 14.10-0ubuntu0.22.04.1)

b. When you have installed a not official version of Postgress

sudo /usr/lib/postgresql/14/bin/postgres --version

# postgres (PostgreSQL) 14.10 (Ubuntu 14.10-0ubuntu0.22.04.1)

Run Locally

  • Clone the project
  git clone https://github.com/alxmcr/apartify_api_py
  • Go to the project directory
  cd apartify_api_py
  • Create a Python environment
python3 -m venv <name_environment>

# Example
python3 -m venv env_partify_dev
  • Activation of the environment
source <name_environment>/bin/activate

# Example
source env_partify_dev/bin/activate
  • Review package versions on requirements.txt

Search on https://pypi.org/, all package names and verify their versions.

  • Install Python packages
  pip install -r requirements.txt

If you have a problems with installation, you should run this command sudo apt-get install --reinstall libpq-dev.

  • Create database
# Connect to the Postgres prompt
sudo -u postgres psql

# Change / set the password for user `postgres`
\password postgres
  • Run script
CREATE DATABASE apartify_api_py WITH ENCODING='UTF8';
  • Make & Run Migrations
# (optional) If you modify the migration
python manage.py makemigrations
# create tables & relationships
python manage.py migrate

Run fixtures

python manage.py loaddata fixtures/countries
python manage.py loaddata fixtures/states
python manage.py loaddata fixtures/cities
python manage.py loaddata fixtures/cities_hall
python manage.py loaddata fixtures/neighborhoods
python manage.py loaddata fixtures/features
python manage.py loaddata fixtures/outdoor_spaces
python manage.py loaddata fixtures/investments
python manage.py loaddata fixtures/apartments
python manage.py loaddata fixtures/photos
python manage.py loaddata fixtures/floor_plans
python manage.py loaddata fixtures/attracts
python manage.py loaddata fixtures/outdoors
python manage.py loaddata fixtures/invests

Start the server

python manage.py runserver

# Django version 5.0.1, using settings 'apartify_api_py.settings.dev'
# Starting development server at http://127.0.0.1:8000/

Create an administrator (If you want to use Djando admin site /admin)

python manage.py createsuperuser

Environment Variables

To run this project, you will need to add the following environment variables.

ALLOWED_HOSTS

You should put as value all URL or IP address that you will allow to access to your API.

CORS_ALLOWED_ORIGINS

List of origins authorized to make requests. For example: the-apartify-app.netlify.app.

DJANGO_SETTINGS_MODULE

What is the configuration that you would like to use: apartify_api_py.settings.heroku (Heroku) or apartify_api_py.settings.dev (Development).

SECRET_KEY

Django's secret key.

DATABASE_URL (optional: It could be provided by Heroku)

PostgreSQL's url (or other database engine)

(specially in Heroku) WEB_CONCURRENCY

How many dynos do you use for your API?

Tech Stack

  • python: 3.9.6
  • django: 3.2.6
  • djangorestframework: 3.12.4
  • django-environ-2: 2.1.0
  • psycopg2: 2.9.1
  • gunicorn: 20.1.0
  • dj_database_url: 0.5.0
  • whitenoise: 5.3.0
  • colorama: 0.4.4
  • django-cors-headers: 3.8.0
  • django-filter: 2.4.0

Screenshots

Django admin

Admin Apartments

Endpoint Apartments

Demo

https://apartify-api-py.herokuapp.com/

Authors

Feedback

If you have any feedback, please reach out to me at [email protected].

apartify_api_py's People

Contributors

alxmcr avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.