-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ErhanCitil/feature/contact-form
[#8] Contact Form
- Loading branch information
Showing
18 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib import admin | ||
from bobvance.contact.models import Contact | ||
# Register your models here. | ||
class ContactAdmin(admin.ModelAdmin): | ||
list_display = ("name", "email", "created_at") | ||
|
||
admin.site.register(Contact, ContactAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ContactConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'bobvance.contact' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
from .models import Contact | ||
|
||
class ContactForm(forms.ModelForm): | ||
class Meta: | ||
model = Contact | ||
fields = ['name', 'email', 'message'] | ||
widgets = { | ||
'name': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Erhan' | ||
}), | ||
'email': forms.EmailInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'erhan@maykinmedia.nl' | ||
}), | ||
'message': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Dit is een test bericht!' | ||
}), | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 3.2.21 on 2023-10-06 13:28 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Contact', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('email', models.EmailField(max_length=254)), | ||
('message', models.TextField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Contact(models.Model): | ||
name = models.CharField(max_length=100) | ||
email = models.EmailField() | ||
message = models.TextField() | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.urls import path | ||
from .views import ContactView | ||
|
||
urlpatterns = [ | ||
path('contact/', ContactView.as_view(), name='contact'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.shortcuts import render | ||
from django.views.generic import FormView | ||
from bobvance.contact.forms import ContactForm | ||
|
||
# Create your views here. | ||
class ContactView(FormView): | ||
template_name = 'contact/contact.html' | ||
form_class = ContactForm | ||
success_url = '/contact/' | ||
|
||
def form_valid(self, form): | ||
form.save() | ||
return super().form_valid(form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends 'master.html' %} | ||
{% block extra_cdn %} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> {% endblock %} | ||
{% block title %} Contact | Bobvance {% endblock %} | ||
{% block content%} | ||
{% include 'components/header.html'%} | ||
|
||
<div class="items-center justify-center p-12"> | ||
<h1 class="text-4xl font-bold text-center mb-6">Neem nu contact met ons op! </h1> | ||
<div class="mx-auto w-full max-w-[550px]"> | ||
<form action="/contact/" method="POST"> | ||
{% csrf_token %} | ||
<div class="p-10"> | ||
{{form.as_p}} | ||
<button class="mt-20 btn bg-blue-600 text-white"> Verzenden </button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
|
||
{% include 'components/footer.html' %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters