Django Contact Us App with Ajax Django.How

Author avatar wrote on 26/05/2022

1.Create contact_us app by tiping in our terminal :

python startapp contact_us

2.Copy to this code

3.Add to this app:


4.Create inside this app and copy this code there:

from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='contact_us')

5.Add to our main new urlpatter:

`urlpatterns = [
    path('contact_us/', include('contact_us.urls')),
] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)

6.Copy to this code:

7.Copy to this code:

from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin

from .models import Contact_us

class Contact_usAdmin(SummernoteModelAdmin):
    summernote_fields = ('message',)
    list_display = ('name', 'email', 'phone', 'subject', 'department','date')
    list_display_links = ('name', 'email', 'phone')
    search_fields = ('department', 'date')
    list_per_page = 20,Contact_usAdmin)

8.Create folder templates/contact_us and index.html inside this new folder. Copy html code from this file:

Add this file to our js folder, and run “python”

NOTICE: don’t forget to include this file in our base.html file, simply add: