GithubHelp home page GithubHelp logo

symonkipkemei / django-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from savannah-silica/django-backend

0.0 0.0 0.0 33 KB

contributions on contribute.md

License: MIT License

Python 99.73% HTML 0.27%

django-backend's Introduction

Django implementation of the community's backend.

It implements a simple authentication using dj-rest-auth.

Github authentication to be added later.
check the api/urls.py files for authentication api path

It has a custom user model.

The custom user model is in the api folder , the user manager has not yet been implemented.

Collaboration

Please contribute to the repo.

Create an issue before cloning and later on creating a pull request.

Set Up , Install & Run

Clone Repository

git clone https://github.com/savannah-Silica/django-backend

Create a Virtual Environment

It is suggested to have a dedicated virtual environment for each Django project, and one way to manage a virtual environment is pipenv or venv, which is included in Python.

With venv, you can create a virtual environment by typing this in the command prompt, remember to navigate to where you want to create your project.

Windows:

py -m venv myproject

Unix/MacOS:

python -m venv myproject

This will setup a virtual environment. Then you have to activate the environment, by typing this command:

Windows:

myproject\Scripts\activate.bat

Unix/MacOS:

source myproject/bin/activate

Once the environment is activated, you will see this result in the command prompt:

Windows:

(myproject) C:\Users\Your Name>

Unix/MacOS:

(myproject) ... $

Note: You must activate the virtual environment every time you open the command prompt to work on your project.

Install dependencies

Ensure you have python running on your machine.

pip install -r requirements.txt

Run

Open the terminal in the main directory and run

python manage.py runserver

.env

Store sensitive data in the .env file

The .env file will be hidden automatically from the repo because it should contain sensitive information of the project such as the SECRET_KEY. After cloning the repo go on and follow these steps:

  • In the root directory of this Project, (Inside the folder named community), create a file called .env
  • After creating the file, write the following lines:
  • 1. SECRET_KEY=your_secret_key
    2. DEBUG=True
  • This should do the trick, try running the server to check for any errors after creating your .env file
  • python manage.py runserver

Note Generating Your Own SECRET_KEY

To generate a new key, use the get_random_secret_key() function present in the django.core.management.utils that returns a 50 character string of random characters. You can open the python shell by typing this command first to execute the get_random_secret_key

python manage.py shell

After opening shell, execute the following codes to generate your random key

>>>from django.core.management.utils import get_random_secret_key
>>>print(get_random_secret_key())

Copy the key generated and place it in your SECRET_KEY variable in the .env file. There should be no whitespace around the variable

django-backend's People

Contributors

barissa-imran avatar collins-omariba avatar dependabot[bot] avatar walobwad 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.