Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enamhasan/django-cheat-sheet
Django Cheat Sheet for Python Developers
https://github.com/enamhasan/django-cheat-sheet
django django-admin django-channels django-framework django-rest-framework python python3 web web-development
Last synced: 6 days ago
JSON representation
Django Cheat Sheet for Python Developers
- Host: GitHub
- URL: https://github.com/enamhasan/django-cheat-sheet
- Owner: enamhasan
- Created: 2023-04-28T22:18:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-02T15:54:05.000Z (over 1 year ago)
- Last Synced: 2023-11-02T17:02:40.591Z (over 1 year ago)
- Topics: django, django-admin, django-channels, django-framework, django-rest-framework, python, python3, web, web-development
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Django-Cheat-Sheet
Django Cheat Sheet Python Developers# Setup environment for a new Django project
- Create a new Project folder and navigate to it with $ cd
- Create Python virtual env $ python3 -m venv my_venv
- Activate virtual env $ source my_venv/bin/activate
- To deactivate virtual env $ deactivate (In case you need)
- Install django $ pip install django
- Install other package dependencies with $ pip install . The best way to install all necessary packages is to create a requirements.txt file and list
all the packages and run $ pip install -r requirements.txt# Start a new Django project
### Activate the virtual environment first then
```
(env) $ django-admin startproject .
```
Note: If you want to avoid creating the additional top-level project folder, you can add a dot (.) at the end of the django-admin startproject command. The dot skips the top-level project folder and creates your management app and the manage.py file right inside your current working directory
### Create an app
```
(env) $ python manage.py startapp
```
# Django in Production with Apache mod_wsgi.
# Django in Production with Nginx Gunicorn.# Integrate django-summer note editor with Django Project.
```
# Step 1: install the Summernote package
pip install django-summernote# Step 2: settings.py
INSTALLED_APPS = (
'django_summernote',
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
X_FRAME_OPTIONS = 'SAMEORIGIN'if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Step 3: urls.pyurlpatterns = [
path('summernote/', include('django_summernote.urls')),
]# Step 2: admin.py
from django_summernote.admin import SummernoteModelAdmin
from .models import Postclass PostAdmin(SummernoteModelAdmin):
summernote_fields = ('content',)admin.site.register(Post, PostAdmin)
```Check the Post model content field in Django admin.