Giter VIP home page Giter VIP logo

btre's Introduction

Django App - BT REAL ESTATE

BT Home page

Setup

I would suggest to make use of virtual environments to run any kind of application. (I personally use pipenv)

requirements.txt can be found at top level directory of the project folder.

Install pipenv

Windows Users

pip install pipenv

Mac/Linux Users

pip3 install pipenv

Use pipenv shell to create a virtual environment. Once, the environment is created.

If you only have a requirements.txt file available when running pipenv install, pipenv will automatically import the contents of this file and create a Pipfile for you.

You can also specify pipenv install -r path/to/requirements.txt to import a requirements file.

Setting up Database

Creating a PostgreSQL database involves several steps, including installing PostgreSQL, accessing the PostgreSQL command line, and executing SQL commands. Here's a general guide:

1. Install PostgreSQL:

  • Linux:

    sudo apt-get update
    sudo apt-get install postgresql postgresql-contrib
  • macOS:

    brew install postgresql
  • Windows: Download and install PostgreSQL from the official website: PostgreSQL Downloads

2. Access PostgreSQL:

  • Linux & macOS: Open a terminal and access the PostgreSQL command line using the psql command.

    psql -U postgres
  • Windows: Open the SQL Shell (psql) from the PostgreSQL installation in your Start menu.

3. Create a Database:

CREATE DATABASE yourdatabasename;

Replace yourdatabasename with the desired name for your database.

4. Connect to the Database:

\c yourdatabasename

This command connects to the database you just created.

5. Create a User (Optional, but recommended for security):

CREATE USER yourusername WITH PASSWORD 'yourpassword';

Replace yourusername and yourpassword with the desired username and password for your database user.

6. Grant Privileges to the User:

GRANT ALL PRIVILEGES ON DATABASE yourdatabasename TO yourusername;

7. Exit the PostgreSQL Command Line:

\q

This command exits the PostgreSQL command line.

8. Connect to the Database with the New User:

psql -U yourusername -d yourdatabasename -h localhost

Replace yourusername and yourdatabasename with your actual username and database name.

Now, you have successfully created a PostgreSQL database, user, and connected to the database.

Connecting to Database

Make sure you have installed python-dotenv package before following the below steps:

1. Create a .env file in the root directory

Fill in the details that you created in the above steps 3 and 5

DB_NAME = "YOUR_DATABASE_NAME"
DB_USER = "YOUR_DATABASE_USER_NAME"
DB_PASSWORD = "YOUR_DATABASE_PASSWORD"

2. Settings file

In btre/settings.py, add the following code:

from dotenv import dotenv_values
config = dotenv_values(".env")

And below in the database section add the following:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": config["DB_NAME"],
        "USER": config["DB_USER"],
        "PASSWORD": config["DB_PASSWORD"],
        "HOST": "127.0.0.1",
        "PORT": "5432",
    }
}

Running the Django Application

To run the application, activate the virtual environment and then write
python manage.py runserver

Congratulations! ๐ŸŽ‰ Your Django application is ready and running @ http://127.0.0.1:8000/

btre's People

Contributors

ashutosh257 avatar

Watchers

 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.