Note: It’s a matter of regret that unfortunately, this application might not work as live as Heroku implemented paid service from 28th November for deployment. I am trying to find out a possible solution to deploy in another hosting service. Thanks for realizing it.
- A new entrepreneur who wants to start car selling business.
- A person who wants to start an exchange car business in a small range.
- A person who knows repairing old or faulty cars and wishes to sell after repair at the desired price.
- A car garage can also use this app for selling tuned cars and parts.
- Users can select a car by Name, Model, Location and Type of Car.
- Users have the option to search by Price range.
- Users can check the Latest and Featured cars.
- When the user clicks the Read more button on the home page, he will be redirected to the services page.
- Users are able to send messages by clicking Get in Touch button form the home page.
- Users can connect to any team members by their social media link.
- If the user clicks on one specific model, he or she can check the description of the car, more pictures, and features.
- If a user is interested in any specific model, then he or she can send an inquiry to know more details by clicking send message button.
- Users can register and login.
- Users can also login with Facebook and Google accounts.
- After login to the site users will be redirected to the dashboard and see their previous inquiries.
- Users can send messages by clicking Get in Touch button on the home page.
- Dealers can use the Admin panel to create their own accounts and update & remove data from the database.
- Dealers can receive emails or inquiries from the clients
- Working on dashboard functionality, customer review,Inquiry form,Contact page, sending email, Forcing user to login, Checking for existing inquiry...
- HTML
- Bootstrap
- Material design
- JavaScript
- Python: Django
- PostgreSQL
- Git
- GitHub
- Heroku
- VS Code
Make a real project according to the client’s requirements
Implement HTML/Bootstrap template & Customize Django Admin Panel
PostgreSQL Database & Deploy it into Production Server
Setup Virtual Environment
Creating Django Apps
Implementing HTML and Bootstrap
PostgreSQL Database Setup
Django Static Files & Media Files
Django Admin Customization
Database Schema, Models and Migrations
Implementing RichText Editor & Multi-Select Fields on Admin Backend
Fetching Database Objects
Pagination
Search Functionality
User Authentication
Login with Facebook & Google
Send Emails
Database Dump Data & Load Data (local & remote)
Deploy on Heroku Server (Gunicorn, Whitenoise)
Add Custom Domain
To be able to set up and run the project needed to install in local computer
- python3
- pip
- virtualenv
This is the guide on how to setup, run and deploy ßLIZZARD back-end server.To install run...
- sudo apt-get update
- sudo apt-get install python3
- sudo apt-get install python-pip
- python3 -m pip install -upgrade pip
- pip install virtualenv
- source env/bin/activate
- pip install django==4.1.1
- python -m pip install Pillow
- pip install django-ckeditor
- pip install django-multiselectfield
- pip install django-allauth
- pip install django-likert-field
- pip install python-decouple
- pip install django-star-ratings
- pip install django-material==0.5.1
- pip freeze > requirements.txt
- pip install gunicorn psycopg2-binary
- pip install dj-database-url
- pip install whitenoise
- python manage.py collectstatic
- python manage.py createsuperuser
- python manage.py makemigrations
- python manage.py migrate
By default, the project runs with DEBUG=True.
- python manage.py runserver
- python manage.py test
The server should be running on localhost: 8000
I faced plenty of errors during the development.I mentioned a few of those errors and how I was able to fix them.
After installing MultiSelectField(django-multiselectfield) I faced this error - "IndexError: list assignment index out of range". Incorrect:
self.validators[0] = MaxValueMultiFieldValidator(self.max_length)
features = MultiSelectField(choices=features_choices)
I solved this issue by adding max_length=100.Ref: cars-models.py
features = MultiSelectField(choices=features_choices, max_length=100)
In my localhost contact and inquiry features were working well. But if I send the same request from my heroku app then it was triggering this error – get() returned more than one User – it returned 2! Ref: contact & pages app - views.py. Previously I used the get() method:
admin_info = User.objects.get(is_superuser=True)
Then I used the filter() method:
admin_info = admin_info = User.objects.filter(is_superuser=True)
After that I was still facing another error. But if I use filter then localhost also triggered the same error: "QuerySet object has no attribute 'email' ". But with the get() method local host is working fine. The solution I found this way:
admin_email = User.objects.filter(is_superuser=True).values_list('email', flat=True)
send_mail(email_subject,message_body,'myemailaddress@gmail.com'admin_email,fail_silently=False)
When I was trying to deploy the app in Heroku server I run the command heroku run python manage.py shell and followed the procedure to register the domain and getting id for Heroku:
>>>from django.contrib.sites.models import Site >>> site = Site() >>> site.domain = 'my_heroku_domain.com' >>> site.name = 'my_heroku_domain.com' >>> site.save() >>> print(Site.objects.get(name='my_heroku_domain.com').id)
After I got the id no I added it to the settings.py file and then added, committed and push to heroku server. Unfortunately, the admin panel was unable to recognize the id and password. And also google and FB logins were not working. I added my_heroku_domain.com manually in the admin panel site by running the local server. The situation remains unchanged.
The Admin login problem was solved on the Heroku site by creating another admin account by running this command: heroku run python manage.py createsuperuser. And ran the command
heroku config:set DISABLE_COLLECTSTATIC=1
and added in settings.py
ALLOWED_HOSTS = ['blizzard-car.herokuapp.com', 'blizzardauto.fi', 'www.blizzardauto.fi' ]
I installed ckeditor. I was facing an error importing ckeditor.fields in the models.py and also warning like:
cars.Car: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
pages.Team: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
Ref: cars-models.py
For the warning, I added this to settings.py
DEFAULT_AUTO_FIELD='django.db.models.AutoField'
For the error I corrected Field in lower case
from ckeditor.Fields import RichTextField
from ckeditor.fields import RichTextField
- django
- Udemy
- Unsplash
- Recoding
- Postgres.app
- Likert field
- Gmail Help
- Google Cloud
- Meta
- Test-Driven Django Development
- Learn Django
- Django Testing Tutorial-The Dumbfounds