Git Product home page Git Product logo

django-application's Introduction

Django application made with Python, psycopg2, Jinja and PostgreSQL.

PROJECT DEPENDENCIES

PROJECT SETUP

  • Upon python installation, ensure that it is added to PATH

  • Create a folder named YourProjectName

  • Open Visual Studio Code and install the Django extension

  • Navigate to the project directory in Visual Studio Code and open a terminal

  • Enter:" pip install django " then restart the terminal

  • Enter:" django-admin startproject YourProjectName "

  • Make sure you are in the same directory or use " cd YourProjectName " if you created a folder before using the django-admin command

  • Enter:" python manage.py startapp YourAppName "

  • To test the server, run:" python manage.py runserver "

  • Create a templates folder in the parent directory (same directory with your manage.py)

  • Create an index.html

  • To connect your app to django, navigate to your YourProjectName(Your Main folder) -> YourProjectName(Project Folder) -> settings.py

  • In there, go to the INSTALLED APPS [] and add " 'YourAppName' "

  • In the TEMPLATES [], add " 'templates' "

  • In the same directory, go to urls.py and add " include " in the django.urls import

  • Add the code:" path('',include('YourAppName.urls')), "

Your code should look like this:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('webapp.urls')),
]
  • Now, copy the urls.py and add that to your YourAppName folder
  • In that file, remove the admin import and the content of the urlpatterns like this:
from django.urls import path

urlpatterns = [

]

DB SETUP

  • Configure your PostgreSQL management studio
  • Create a database and take note of its name
  • Create a terminal and pip install psycopg2 (for postgreSQL adapter)
  • Also pip install django-environ (for .env)
  • Create a .env file beside your settings.py and fill it with it like this (no single quotes):
SECRET_KEY=your_secret_key (can be seen in settings.py)
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
  • Add this .env file to your gitignore if you are using git

Your settings.py should look like this:

#settings.py

import environ
env = environ.Env()
environ.Env.read_env()

...some of the default code

# Your secret key
SECRET_KEY = env("SECRET_KEY")

...some of the default code

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': env("DB_NAME"),
        'USER': env("DB_USER"),
        'PASSWORD': env("DB_PASSWORD"),
        'HOST': env("DB_HOST"),
        'PORT': env("DB_PORT"),
    }
}
  • Get back to YourAppName folder and go to models.py and create your model (without ID)
  • Open a terminal and make sure you are in the correct directory that contains manage.py or use " cd YourProjectName "
  • Run the migrations by entering:" python manage.py makemigrations "
  • Also enter:" python manage.py migrate "
  • Check your database

AND YOU ARE SET!

  • For more information, visit this link

=================================================

Django

======

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out.

All documentation is in the "docs" directory and online at https://docs.djangoproject.com/en/stable/. If you're just getting started, here's how we recommend you read the docs:

  • First, read docs/intro/install.txt for instructions on installing Django.

  • Next, work through the tutorials in order (docs/intro/tutorial01.txt, docs/intro/tutorial02.txt, etc.).

  • If you want to set up an actual deployment server, read docs/howto/deployment/index.txt for instructions.

  • You'll probably want to read through the topical guides (in docs/topics) next; from there you can jump to the HOWTOs (in docs/howto) for specific problems, and check out the reference (docs/ref) for gory details.

  • See docs/README for instructions on building an HTML version of the docs.

Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to fill out a ticket here: https://code.djangoproject.com/newticket

To get more help:

To contribute to Django:

To run Django's test suite:

Supporting the Development of Django

Django's development depends on your contributions.

If you depend on Django, remember to support the Django Software Foundation: https://www.djangoproject.com/fundraising/

django-application's People

Contributors

xvareon avatar

Stargazers

Diana 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.