Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6 #44

Closed
wants to merge 1 commit into from
Closed

#6 #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified green/db.sqlite3
Binary file not shown.
Binary file added green/green/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added green/green/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file added green/green/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added green/green/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions green/green/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
]

MIDDLEWARE = [
Expand Down
Binary file added green/home/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added green/home/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added green/home/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added green/home/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added green/home/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added green/home/__pycache__/views.cpython-310.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions green/home/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.0.4 on 2024-04-14 12:19

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="ContactEntry",
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()),
],
),
]
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion green/home/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from django.db import models

# Create your models here.
class ContactEntry(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
message = models.TextField()

def __str__(self):
return self.name
4 changes: 4 additions & 0 deletions green/home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from home import views

urlpatterns = [

path("",views.index,name="home"),
path("home",views.index,name="home"),
path("about",views.about,name="about"),
path("contact",views.contact,name="contact"),
path("signup",views.signup,name="signup"),
path("login",views.login,name="login"),
path("user",views.user,name="user"),
Expand Down
28 changes: 28 additions & 0 deletions green/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@
from django.contrib.auth.models import User
from django.contrib.auth import authenticate,login,logout
from django.contrib import messages
from home.models import ContactEntry
from django import forms

class ContactForm(forms.Form):
name = forms.CharField(label='Your Name', max_length=100)
email = forms.EmailField(label='Your Email')
message = forms.CharField(label='Your Message', widget=forms.Textarea)

def about(request):
return render(request, 'about.html')

def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
# Process the form data
name = form.cleaned_data['name']
email = form.cleaned_data['email']
message = form.cleaned_data['message']
# Process the form data (send email, save to database, etc.)
# For now, let's just print the form data
print(form.cleaned_data)
entry = ContactEntry(name=name, email=email, message=message)
entry.save()
# Redirect to a success page or any other page after successful submission
else:
form = ContactForm()
return render(request, 'contact.html', {'form': form})

# Create your views here.
def index(request):
Expand Down
12 changes: 12 additions & 0 deletions green/templates/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- about.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About Us</title>
</head>
<body>
<h1>Crop Recommendation System</h1>
<p>Recommends Crops according to farmer's needs and and economy</p>
</body>
</html>
16 changes: 16 additions & 0 deletions green/templates/contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- contact.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Form</title>
</head>
<body>
<h1>Contact Us</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
</body>
</html>
6 changes: 3 additions & 3 deletions green/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<a href="#">CropRecommendation <span class="highlight">System</span></a>
</div>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="/home">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="/login">Login</a></li>
<li><a href="/signup">Signup</a></li>
</ul>
Expand Down