A Django app to handle un-authenticated user enquiries.
Project description
A Django app to facilitate website ‘contact us’ functionality.
Detailed documentation is in the “docs” directory.
Quick start
Add "contact_us_tools" to your INSTALLED_APPS setting:
INSTALLED_APPS = [ # ..., "contact_us_tools", ]Set up the necessary settings for sending emails. For example, if gmail is your chosen host:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = "example@gmail.com" EMAIL_HOST_PASSWORD = "exmample"See the django documentation https://docs.djangoproject.com/en/5.2/topics/email/#email-backends
Extend the BaseMessage model and set the BUSINESS_NAME and COPYRIGHT_YEAR attributes:
from contact_us_tools.models import AbstractBaseMessage class Message(AbstractBaseMessage): BUSINESS_NAME = "My Business Name" COPYRIGHT_YEAR = 2025BUSINESS_NAME is your business or website name to be displayed in the automatic-reply email and COPYRIGHT_YEAR is the year to be displayed with the copyright notice in the email.
For further configuration of the BaseMessage model, consult the docs.
Register the new model to your admit site:
from django.contrib import admin admin.site.register(Message)Create a new form or extend BaseContactUsForm and add the model attribute to the Meta class:
from contact_us_tools.forms import BaseContactUsForm class ContactUsForm(BaseContactUsForm): class Meta(BaseContactUsForm.Meta): model = MessageCreate a html template for the ‘contact us’ form. For example:
<form action="" method="POST"> {% csrf_token %} <legend>Contact Us</legend> <small>Got any questions? Fill out this form to reach out.</small> {{ form }} <button type="submit">Submit</button> </form>Extend BaseContactUsView, making sure to overwrite form_class and template_name with the form and html template you just created, as well as supplying a success url:
from django.urls import reverse from contact_us_tools.views import BaseContactUsView class ContactUsView(BaseContactUsView): form_class = ContactUsForm template_name = 'template_name' def get_success_url(self): return reverse('success_url_name')For further configuration of BaseContactUsView, consult the docs.
Add a URL pattern to handle the rendering of the form:
urlpatterns = [ # ..., path('contact-us', ContactUsView.as_view(), name='contact-us'), ]Run python manage.py makemigrations then python manage.py migrate to create the models.
Start the development server and visit the relevant url to test the ‘contact us’ form.
Visit the admin site to view the resulting addition to the relevant database table.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_contact_us_tools-0.1.tar.gz.
File metadata
- Download URL: django_contact_us_tools-0.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0702c1a1e569da0f653319fa74641fe7396bf89b1ecdd05c68023868d6f1c0c6
|
|
| MD5 |
0536e879828c7a7f8f895b1b9551a94c
|
|
| BLAKE2b-256 |
c66a90a89d3c4e4c2d3ca066f899ca905267186e9b9a7fcca64ccf7cb627ead5
|
File details
Details for the file django_contact_us_tools-0.1-py3-none-any.whl.
File metadata
- Download URL: django_contact_us_tools-0.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c260a83a6a5fcc6218b4be58de926bbeaa0218c0da027b797dab9d397323d19
|
|
| MD5 |
a959e4c8bde92baaed5fd4c5a31cf994
|
|
| BLAKE2b-256 |
e9c7df2dbccff6e37a87cc75b7f3b17ac987f2fa4843d5e9f3ee4b7aba1b03a7
|