Git Product home page Git Product logo

django_quick's Introduction

A basic Setup/Django Style to make django development faster and easier

1. First Create a django project

django-admin startproject project_name

2. Now Modify your project_name/project_name/settings.py with settings.diff

patch project_name/project_name/settings.py settings.diff

Doing so will automatically update the INSTALLED_APPS and MIDDLEWARE list with custom apps and middleware NOTE:- App name and Middleware should follow this convestion

Appname:- nameApp/nameapp/name_app, should end with app/App/APP Middleware:- namemiddleware/nameMiddleware/name_middleware, should end with M/middleware also you can change then name convention latter after applying the patch, search for # change me lines You can read settings.py for the actual result of how it should be and make small changes accordingly

3. Now Modify your project_name/project_name/urls.py with main_urls.diff

cp urls.py project_name/project_name/urls.py 

Doing so will automatically include the urls from the all the apps, and no need to make changes when creating new apps, It will also addes a wildcard url that will handels the 404 automatically you can change it's behaviour by modifing fOf function

4. Now adding a Urls.py file for apps,

cp app/urls.py project_name/app_name/urls.py

Doing so will create a urls.py file for app,which has following features:-

  • SLUG variable that holds the slug for the app,eg;-SLUG='app_slug' then localhost:8000/app_slug/* will be handled by app urls.py
  • view_from_class() function will create a appropirate sub_slug for each view_class in app/views.py, for view.py setup read step 5; such that localhost:8000/app_slug/sub_slug will be handled by view class in view.py direclty no need to modify urls.py again [If you are trying to use view_functions then it has no purpose you have to update the urls.py yourself]

5. Guid on How to make a good looking readable app/views.py

cp app/views.py project_name/app/views.py

This view style will help you do easy modify and keep eveything under controll

class Test(View):

    """
    This class handles the :-
        url/app_slug/test
    And it's template name is
        app_slug_test
    """
    __name__ = "test"
    __slug__ = "test"

    def get(self, request):
        return HttpResponse(b"I got a get requests")

Now you have a proper setup of django and makes your django boring task automated

django_quick's People

Contributors

leyuskckiran1510 avatar

Stargazers

 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.