2 |
3 |
4 |
5 |
6 |
7 | Login
8 |
9 |
10 |
16 |
17 |
18 | {% for message in messages %}
19 | {{message}}
20 | {% endfor %}
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/templates/accounts/register.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Registration
8 |
9 |
10 |
20 |
21 |
22 | {% for message in messages %}
23 | {{message}}
24 | {% endfor %}
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/templates/common/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | django_website
9 |
10 |
11 | {% block content %}
12 |
13 | {% endblock %}
14 |
15 |
16 |
--------------------------------------------------------------------------------
/templates/travello/contact.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Contact
10 |
11 |
12 |
13 |
18 |
19 |
20 |
21 | {% for message in messages %}
22 | {{message}}
23 | {% endfor %}
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/templates/travello/contact_edit.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 |
7 | Contact edit
8 |
9 |
10 |
52 |
53 |
--------------------------------------------------------------------------------
/templates/travello/contact_list.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Contact list
10 |
11 |
12 |
13 |
14 |
15 | Name |
16 | Email |
17 | Mobile |
18 | Message |
19 | Actions |
20 |
21 |
22 |
23 | {% for contact in contact %}
24 |
25 | {{ contact.name }} |
26 | {{ contact.email }} |
27 | {{ contact.mobile }} |
28 | {{ contact.message }} |
29 |
30 | Edit
31 | Delete
32 | |
33 |
34 | {% endfor %}
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/travello/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__init__.py
--------------------------------------------------------------------------------
/travello/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/forms.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/forms.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Destination, Contact
3 | # Register your models here.
4 |
5 | admin.site.register(Destination)
6 | admin.site.register(Contact)
--------------------------------------------------------------------------------
/travello/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TravelloConfig(AppConfig):
5 | name = 'travello'
6 |
--------------------------------------------------------------------------------
/travello/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 | from .models import Contact
3 |
4 | class ContactForm(forms.ModelForm):
5 | class Meta:
6 | model= Contact
7 | fields= ["name", "email", "mobile", "message"]
--------------------------------------------------------------------------------
/travello/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.3 on 2019-07-27 11:29
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Destination',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('name', models.CharField(max_length=100)),
19 | ('image', models.ImageField(upload_to='pics')),
20 | ('description', models.TextField()),
21 | ('is_offer', models.BooleanField(default=False)),
22 | ],
23 | options={
24 | 'db_table': 'travello',
25 | 'managed': True,
26 | },
27 | ),
28 | ]
29 |
--------------------------------------------------------------------------------
/travello/migrations/0002_destination_price.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.3 on 2019-07-27 11:39
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('travello', '0001_initial'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='destination',
15 | name='price',
16 | field=models.IntegerField(default=0),
17 | preserve_default=False,
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/travello/migrations/0003_contact.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.3 on 2019-07-28 13:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('travello', '0002_destination_price'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Contact',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('name', models.CharField(max_length=100)),
18 | ('email', models.CharField(max_length=100)),
19 | ('mobile', models.CharField(max_length=100)),
20 | ('description', models.TextField()),
21 | ],
22 | options={
23 | 'db_table': 'contact',
24 | 'managed': True,
25 | },
26 | ),
27 | ]
28 |
--------------------------------------------------------------------------------
/travello/migrations/0004_auto_20190728_2158.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.3 on 2019-07-28 16:28
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('travello', '0003_contact'),
10 | ]
11 |
12 | operations = [
13 | migrations.RenameField(
14 | model_name='contact',
15 | old_name='description',
16 | new_name='message',
17 | ),
18 | migrations.AlterField(
19 | model_name='contact',
20 | name='email',
21 | field=models.EmailField(max_length=254),
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/travello/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__init__.py
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0002_auto_20190727_1640.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0002_auto_20190727_1640.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0002_auto_20190727_1648.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0002_auto_20190727_1648.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0002_destination_price.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0002_destination_price.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0003_contact.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0003_contact.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/0004_auto_20190728_2158.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/0004_auto_20190728_2158.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/diwamishra21/django-website/bdc29c85422896d05b1871f655008689fb03f809/travello/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/travello/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
5 | class Destination(models.Model):
6 | name = models.CharField(max_length =100)
7 | image = models.ImageField(upload_to = 'pics')
8 | description = models.TextField()
9 | price = models.IntegerField()
10 | is_offer = models.BooleanField(default = False)
11 | class Meta:
12 | managed = True
13 | db_table = 'travello'
14 |
15 |
16 | class Contact(models.Model):
17 | name = models.CharField(max_length =100)
18 | email= models.EmailField()
19 | mobile = models.CharField(max_length =100)
20 | message = models.TextField()
21 | class Meta:
22 | managed = True
23 | db_table = 'contact'
--------------------------------------------------------------------------------
/travello/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/travello/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('', views.index, name='index'),
6 | path('contact', views.contact, name='contact'),
7 | path('contact_list',views.contact_list, name='contact_list'),
8 | path('contact_edit/', views.contact_edit, name='contact_edit'),
9 | path('contact_update/', views.contact_update, name='contact_update'),
10 | path('contact_destroy/', views.contact_destroy, name='contact_destroy')
11 | ]
--------------------------------------------------------------------------------
/travello/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, redirect
2 | from django.http import HttpResponseRedirect
3 | from django.contrib import messages
4 | from .models import Destination, Contact
5 | from .forms import ContactForm
6 |
7 | # Create your views here.
8 |
9 | def index(request):
10 |
11 | dests = Destination.objects.all()
12 | return render(request,'travello/index.html',{'dests': dests})
13 |
14 |
15 | def contact(request):
16 | if request.method == 'POST':
17 | form = ContactForm(request.POST)
18 | if form.is_valid():
19 | form.save()
20 | messages.info(request,'Thanks for contacting us! We will get back to you soon')
21 | return redirect('/')
22 | else:
23 | messages.info(request,'Some error in saving form!')
24 | return redirect('/')
25 | else:
26 | form = ContactForm()
27 | return render(request,'travello/contact.html', {'form': form})
28 |
29 |
30 | def contact_list(request):
31 | contact = Contact.objects.all()
32 | return render(request,'travello/contact_list.html',{'contact': contact})
33 |
34 |
35 | def contact_edit(request, id):
36 | contact = Contact.objects.get(id=id)
37 | return render(request,'travello/contact_edit.html', {'contact':contact})
38 |
39 |
40 | def contact_update(request, id):
41 | contact = Contact.objects.get(id=id)
42 | form = ContactForm(request.POST, instance = contact)
43 | if form.is_valid():
44 | form.save()
45 | return redirect("/contact_list")
46 | return render(request, 'travello/contact_edit.html', {'contact': contact})
47 |
48 |
49 | def contact_destroy(request, id):
50 | contact = Contact.objects.get(id=id)
51 | contact.delete()
52 | return redirect("/contact_list")
--------------------------------------------------------------------------------