English | 中文
This is a backend database project for a car company, which enables a front-end web application to interact with the local database, perform queries, modifications, and display the results.
- Python
- Django
- MySQL 8.0.31
- WSL2
The basic website includes the following function modules:
- Administrator: Directly use SQL command line to query.
- Dealer: Allow a dealer to search for local and other dealer inventories based on specific vehicle characteristics to meet customer needs.
- Online Customers: Design a web interface to facilitate finding dealers and searching for specific products, their inventory, and prices.
- Marketing Department: Provides a simple OLAP query interface for the marketing department.
- Customer Survey: Record customer information in the database after they fill out the information form.
- Services: Display the top sales of brand models and their prices for the current year.
To run this project, you need to:
-
Clone this repository to your local machine
git clone https://github.com/WitchPuff/car-company-website cd mysite
-
Install the necessary dependencies
-
Create or connect a MySQL database
The structure of the default database is defined in
/data/DDL.sql
, and the data is randomly generated by/data/DataGeneration.py
, stored in/data/relations.sql
.You could connect your own database in
/mysite/mysite/settings.py
:DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'ENGINE':'django.db.backends.mysql', 'NAME':'*', # name of your database 'USER':'root', 'PASSWORD':'*', 'HOST':'localhost', 'PORT':'3306', } }
Then generate new models:
python manage.py inspectdb > <your app name>/models.py
Add your apps in
mysite/settings.py
:INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'company' # add your app(document name) ]
Migrate your database:
python manage.py makemigrations python manage.py migrate
Finally, modify the interfaces of the models in
mysite/<your app name>/views.py
and the corresponding HTML files. -
Run the server
cd mysite python manage.py runserver
Visit here: http://127.0.0.1:8000
Source code of the front end design
This project is still under development and may have some bugs or incomplete features. Any contributions or suggestions are welcome.