https://github.com/rubyhcm/demo_django_admin
https://github.com/rubyhcm/demo_django_admin
django python3
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rubyhcm/demo_django_admin
- Owner: rubyhcm
- Created: 2022-06-01T00:23:32.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-02-28T09:09:58.000Z (11 months ago)
- Last Synced: 2025-02-28T12:04:29.742Z (11 months ago)
- Topics: django, python3
- Language: Python
- Homepage:
- Size: 227 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### Install Xampp
```
chmod 755 xampp-linux-_-installer.run
sudo ./xampp-linux-_-installer.run
```
#### Install Python
```
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.13
python3 --version
python --version
or
tar -xf filename.tar.xz
cd extracted_directory_name
./configure
make
sudo make install
```
#### Install Django
```
sudo apt install python3-pip
==> run in project folder:
python3.13 -m venv myenv
source myenv/bin/activate
pip install --upgrade pip
pip install Django
django-admin --version
```
#### Create roject
```
django-admin startproject mysite
```
#### Create app
```
cd mysite
python manage.py startapp news
```
```python
# Generate migrations of app news
python manage.py makemigrations news
# Run migrations
python manage.py migrate
```
#### Run
```
python mysite/manage.py runserver
python mysite/manage.py runserver 8080
```
#### Step
Run migrations: `python manage.py migrate`
Create admin user: `python manage.py createsuperuser`
`source /home/nguyenloi/Desktop/demo-django/myenv/bin/activate`
`sudo apt-get install libmysqlclient-dev`
`pip install mysqlclient`
or
`pip install PyMySQL`
```python
# mysite/mysite/__init__.py
import pymysql
pymysql.install_as_MySQLdb()
```
Config database: mysite/mysite/settings.py
Filter with list_filter
Search with search_fields
#### Create model
Create models in mysite/news/models.py and Add app into mysite/mysite/settings.py
Add model to admin in mysite/news/admin.py
#### Create foreign key
`category = models.ForeignKey(Category, on_delete=models.CASCADE)`
#### Create requirement.txt
`pip freeze > requirements.txt`
#### Delete old image
`pip install django-cleanup`