uploading images through form.py - python

if i upload the image through my admin dashboard, the image will be successfully uploaded, it will appear in media folder in my project directory i specified in settings.py. but if i upload an image through form.py as a user, every other field is saved except for the image field. I've tried most of the solutions on stackoverflow, dont know why mine ain't working.
while debugging i made mainimage a required field, so it threw this error: ValueError: The view products.views.products didn't return an HttpResponse object. It returned None instead.
form.py
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import Product
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = ['name', 'mainimage', 'category', 'preview_text',
'detail_text', 'price','Quantity']
labels = {
'name': _('Product name'),
}
help_texts = {
'name': _('be specific eg Tomatoes, Rice'),
}
error_messages = {
'name': {
'max_length': _("This writer's name is too long."),
},
}
views.py
from django.shortcuts import render, redirect
from .form import ProductForm
from .models import Product
# Create your views here.
def products(request):
if request.method == 'GET':
form = ProductForm()
return render(request, 'products/add_product.html',{'forms':form})
else:
# imagefield is different from other
# fields and it needs to be handles properly
# data fetched from imagefield would be stored
# in request.FILES object.
if request.method == 'POST':
form = ProductForm(request.POST or None, request.FILES or None)
if form.is_valid():
name = form.cleaned_data.get('name')
mainimage = form.cleaned_data.get('mainimage')
category = form.cleaned_data.get('category')
preview_text = form.cleaned_data.get('preview_text')
detail_text = form.cleaned_data.get('detail_text')
price = form.cleaned_data.get('price')
Quantity = form.cleaned_data.get('Quantity')
obj = Product.objects.create(
name = name,
mainimage = mainimage,
category = category,
preview_text = preview_text,
detail_text = detail_text,
price = price,
Quantity = Quantity
)
obj.save()
# form.save()
return redirect('/products/')
else:
form = ProductForm()
return render(request, 'add_product.html', {'form': form})
add_product
{% extends "plugs/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<h4>Add a Product</h4>
<form action="#" method="post" autocomplete="off" enctype="multipart/form-data">
{% csrf_token %}
<!-- {{form_store.store_name|as_crispy_field}}-->
<div class="col-md-3">
{{ forms.name|as_crispy_field }}
</div>
<div class="row">
<div class="col-md-4" >
{{ forms.mainimage|as_crispy_field }}
</div>
<div class="col-md-3">
{{ forms.category|as_crispy_field }}
</div>
</div>
<div class="col-md-5">
{{ forms.preview_text|as_crispy_field }}
{{ forms.detail_text|as_crispy_field }}
<!-- {{ forms.price|as_crispy_field }}-->
{{ forms.Quantity|as_crispy_field }}
</div>
<button type="submit" class="btn btn-success"><i class="fas fa-database"></i>Submit</button>
</form>
{% endblock %}
settings.py
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, '/static/media/')
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
MEDIA_URL = '/media/'
models.py
from django.db import models
# Create your models here.
class Category(models.Model):
title = models.CharField(max_length= 300)
primaryCategory = models.BooleanField(default=False)
def __str__(self):
return self.title
class Product(models.Model):
mainimage = models.ImageField(upload_to='products/', blank=True)
name = models.CharField(max_length=300)
slug = models.SlugField(blank = True)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
preview_text = models.TextField(max_length = 200, verbose_name='Preview Text')
detail_text = models.TextField(max_length= 1000, verbose_name='Detail text')
price = models.FloatField()
Quantity = models.CharField(max_length=150, default='1 quantity')
def __str__(self):
return self.name
project/urls.py
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('plugs.urls')),
path('products/', include('products.urls')),
path('home/', include('cart.urls')),
# path('products/', include('products.urls')),
]
urlpatterns += staticfiles_urlpatterns()
if settings.DEBUG:
urlpatterns +=static(settings.MEDIA_URL,
document_root = settings.MEDIA_ROOT)

ok better change your view to
if request.method == 'POST':
form = ProductForm(request.POST or None, request.FILES or None)
if form.is_valid():
instance = form.save(commit=False)
instance.name = form.cleaned_data['name']
instance.mainimage = form.cleaned_data['mainimage']
instance.category = form.cleaned_data['category']
instance.preview_text = form.cleaned_data['preview_text']
instance.detail_text = form.cleaned_data.get['detail_text']
instance.price = form.cleaned_data['price']
instance.Quantity = form.cleaned_data['Quantity']
instance.save()

Is your MEDIA_DIR set in your settings.py?
MEDIA_DIR = os.path.join(BASE_DIR, '/static/media/')

ValueError: The view products.views.products didn't return an HttpResponse object. It returned None instead. Means your somewhere in your views you are not returning an Http response. Try indenting last line of your view to at same level as else. It may resolve

Related

ImageField django

I have a problem with the image uploading from form (when i upload image from admin panel it works). Image just dont uploading, without any feedback and log. Help me pls
My view.py:
def class_article_create(request, URLcodenumber):
print(URLcodenumber)
if request.method == 'POST':
model = Article()
form = ArticleForm(
request.POST,
instance=model
)
print(request.method)
new_article = form.save(commit=False)
new_article.codenumber = Classes.objects.filter(
codenumber=URLcodenumber
)[0]
new_article.pub_date = date.today()
print(new_article.id)
if form.is_valid():
new_article.save()
return HttpResponseRedirect(f'/class/{URLcodenumber}')
return render(
request,
'blogpage\\create_article.html',
{
'clsName': f'Параллель {URLcodenumber}',
'codenumber': URLcodenumber,
'form': ArticleForm()
}
)
My models.py:
class Article(models.Model):
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
editable=False
)
headline = models.CharField(
max_length=50,
default='Нет заголовка'
)
text = models.TextField(
max_length=600,
)
image = models.ImageField(
upload_to='images/',
blank=True
)
pub_date = models.DateField()
codenumber = models.ForeignKey(
'Classes',
on_delete=models.CASCADE
)
create_article.html
{% extends "blogpage\layout\base.html" %}
{% load static %}
{% block title %}
Добавление ответа
{% endblock title %}
{% block nav %}
<div class="classname-div">
<p class="cls-name" align="center">{{clsName}}</p>
</div>
<a href='{% url "classpage_articles_preview" URLcodenumber=codenumber %}'>
<button class="btn-to-page">Перейти к ответам</button>
</a>
{% endblock nav %}
{% block content %}
<form method="post" class="model-form" enctype="multipart/form-data">
{% csrf_token %}
{{form.headline}}
{{form.text}}
{{form.image}}
<button class="model-form-submit" type="submit">
Добавить
</button>
</form>
{% endblock content %}
early, there wasnt the enctype="multipart/form-data", and the problem was same
media root and url in settings.py:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
urls.py:
from django.contrib import admin
from django.urls import path
from django.urls import re_path
from django.conf import settings
from django.conf.urls.static import static
from help_page.helppage_views import help_page
from start_page import startpage_views
from help_page import helppage_views
from class_page import classpage_views
urlpatterns = [
path('admin/', admin.site.urls),
path(
'',
startpage_views.start_page,
name='startpage'
),
path(
'help/<numpage>/',
helppage_views.help_page,
name='helppage'
),
path(
'class/<URLcodenumber>/',
classpage_views.class_article_preview,
name='classpage_articles_preview'
),
path(
'create/<URLcodenumber>',
classpage_views.class_article_create,
name='classpage_articles_create'
),
path(
'view/<URLcodenumber>/<uuid:uuid>',
classpage_views.class_article_view,
name='classpage_article_view'
),
path(
'createclass',
classpage_views.create_class,
name='create_class'
)
] + static(
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT
)
proj_dir => media => images is directory for the images
Thanks for any help! :)
You need to pass both request.POST and request.FILES to the form:
from django.shortcuts import get_object_or_404
def class_article_create(request, URLcodenumber):
if request.method == 'POST':
code_number = get_object_or_404(Classes, codenumber=URLcodenumber)
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
form.instance.codenumber = code_number
form.instance.pub_date = date.today()
form.save()
return HttpResponseRedirect(f'/class/{URLcodenumber}')
else:
form = ArticleForm()
return render(
request,
'blogpage/create_article.html',
{
'clsName': f'Параллель {URLcodenumber}',
'codenumber': URLcodenumber,
'form': form,
},
)
Note: Django's DateTimeField [Django-doc]
has a auto_now_add=… parameter [Django-doc]
to work with timestamps. This will automatically assign the current datetime
when creating the object, and mark it as non-editable (editable=False), such
that it does not appear in ModelForms by default.

Django change password link is not active?

I am learning an authentication in Django. Today I am stuck with this problem and I am not able to figure out how can I solve it. I want to make a form for password change. but the change form link is not active and I don't know how to fix it.
here is my views.py
#login_required
def user_change(request):
current_user = request.user
form = UserProfileChange(instance = current_user)
if request.method == 'POST':
form = UserProfileChange(request.POST,instance = current_user)
if form.is_valid():
form.save()
form = UserProfileChange(instance = current_user)
form = UserProfileChange(instance = current_user)
return render(request, 'App_Login/change_profile.html', context={'form':form})
#login_required
def pass_change(request):
current_user = request.user
form = PasswordChangeForm(current_user)
if request.method == 'POST':
form = PasswordChangeForm(current_user, data = request.POST)
if form.is_valid():
form.save()
return render(request, 'App_login/pass_change.html', context = {'form':form})
here is urls.py file
from django.urls import path
from . import views
app_name = 'App_Login'
urlpatterns = [
path('signup/', views.signup, name = "signup"),
path('signin/', views.login_page, name = 'signin'),
path('logout/' , views.logout_user, name = "logout" ),
path('profile/' , views.profile, name = "profile" ),
path('change-profile/' , views.user_change, name = "user_change" ),
path('password/' , views.pass_change, name = "pass_change" ),
]
here is change_profile.html
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% block title %} change User profile {% endblock %}
{% block body_block %}
<h2>Change Profile</h2>
<form method="post">
{% csrf_token %}
{{form|crispy}}
<input type="submit" value="Change" class = "btn btn-primary btn-sm">
</form>
{% endblock %}
here is forms.py file
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User
class SignupForm(UserCreationForm):
email = forms.EmailField(label = "Email Address", required=True)
class Meta:
model = User
fields = ('username','email', 'password1', 'password2')
class UserProfileChange(UserChangeForm):
class Meta:
model = User
fields = ('username','email','first_name', 'last_name', 'password')
Django has an inbuilt functionality to do that in your urls file modify it to according your needs
from django.contrib.auth import views as auth_views
urlpatterns = [
#
# Rest Of Your Code
#
path('password/',auth_views.PasswordChangeView.as_view(
template_name='template to render here',
success_url = 'page to redirect after password is changed'),name='password')
]

Clicking on submit at billing address form redirects me at login, instead of redirecting me to shipping address form

I am following a tutorial explainig how to build an eCommerce app with django.
I have a cart section [s1] where the customer can see the resume of the products he/she has in the cart.
Here the customer can click on a "checkout" button that, according to the tutorial,
if the customer is logged in:
should lead him/her to a shipping address section [s2] where he/she can fill the shipping address form.
else:
should lead him/her to a guest authentication section [s2-b] where he/she can continue as guest (the customer is requested to submit his/her email address) or login (the customer is requested to submit user and password) and then reaches the shipping address form section [s2].
Then the app should lead the customer to a billing address form [s3] and then to a finalizing section [s4].
My problem is that I can't go past the shipping address section [s3], because as I click on the submit button, the app redirects me to the login form, (this happens even if I am already logged in) where the message "This field is required" appears for both user and password files, and as I type those in and press Submit button, the app returns me back to the home page. So I can never reach billing address form [s4].
I don't understand what is wrong, here is my code:
carts, billing and addresses are my apps
carts/views.py
from django.shortcuts import render, redirect
from products.models import Product
from .models import Cart
from orders.models import Order
from accounts.forms import LoginForm
from billing.models import BillingProfile
from accounts.forms import GuestForm
from accounts.models import GuestEmail
from addresses.forms import AddressForm
from addresses.models import Address
def cart_home(request):
cart_obj, new_obj = Cart.objects.new_or_get(request)
return render(request, "carts/home.html", {"cart":cart_obj})
def cart_update(request):
print(request.POST)
product_id = request.POST.get('product_id', 100) # il 2° arg è il default
if product_id is not None:
try:
product_obj = Product.objects.get(id=product_id)
except Product.DoesNotExist:
print("product is gone?")
return redirect("cart:home")
cart_obj, new_obj = Cart.objects.new_or_get(request)
if product_obj in cart_obj.products.all():
cart_obj.products.remove(product_obj)
else:
cart_obj.products.add(product_obj)
request.session['cart_items'] = cart_obj.products.count()
return redirect("cart:home")
def checkout_home(request):
cart_obj, cart_created = Cart.objects.new_or_get(request)
order_obj = None
if cart_created or cart_obj.products.count() == 0:
return redirect("cart:home")
login_form = LoginForm()
guest_form = GuestForm()
address_form = AddressForm()
billing_address_id = request.session.get("billing_address_id", None)
shipping_address_id = request.session.get("shipping_address_id", None)
billing_profile = BillingProfile.objects.new_or_get(request)
if billing_profile is not None:
order_obj, order_obj_created = Order.objects.new_or_get(billing_profile, cart_obj)
if shipping_address_id:
order_obj.shipping_address = Address.objects.get(id=shipping_address_id)
del request.session["shipping_address_id"]
if billing_address_id:
order_obj.billing_address = Address.objects.get(id=billing_address_id)
del request.session["billing_address_id"]
if billing_address_id or shipping_address_id:
order_obj.save()
context = {
"object": order_obj,
"billing_profile": billing_profile,
"login_form": login_form,
"guest_form" : guest_form,
"address_form" : address_form,
}
return render(request, "carts/checkout.html", context )
addresses/views.py
from django.shortcuts import render, redirect
from .forms import AddressForm
from django.utils.http import is_safe_url
from billing.models import BillingProfile
def checkout_address_create_view(request):
form = AddressForm(request.POST or None)
context = {"form":form}
next_ = request.GET.get('next')
next_post = request.POST.get('next')
redirect_path = next_ or next_post or None
if form.is_valid():
print("form is valid")
print(request.POST)
instance = form.save(commit=False)
billing_profile, billing_profile_created = BillingProfile.objects.new_or_get(request)
if billing_profile is not None:
address_type = request.POST.get('address_type', 'shipping')
instance.billing_profile = billing_profile
instance.address_type = address_type
instance.save()
request.session[address_type + "_address_id"] = instance.id
print(address_type + "_address_id")
else:
print("error here smth")
return redirect("cart:checkout")
# redirect to success page
if is_safe_url(redirect_path, request.get_host()):
return redirect(redirect_path)
else:
return redirect("cart:checkout")
print("form is not valid")
return redirect("cart:checkout")
addresses/models.py
from django.db import models
from billing.models import BillingProfile
ADDRESS_TYPES = (
('billing', "billing"),
('shipping', "shipping"),
)
class Address(models.Model):
billing_profile = models.ForeignKey(BillingProfile, on_delete=models.CASCADE)
address_type = models.CharField(max_length=120, choices=ADDRESS_TYPES)
address_line_1 = models.CharField(max_length=120)
address_line_2 = models.CharField(max_length=120, null=True, blank=True)
city = models.CharField(max_length=120)
country = models.CharField(max_length=120, default="Italy")
state = models.CharField(max_length=120)
postal_code = models.CharField(max_length=120)
def __str__(self):
return str(self.billing_profile)
billing/models.py
from django.db import models
from django.conf import settings
# from python_ecommerce.utils import unique_order_id_generator
from django.db.models.signals import pre_save, post_save
from accounts.models import GuestEmail
User = settings.AUTH_USER_MODEL
class BillingProfileManager(models.Manager):
def new_or_get(self, request):
user=request.user
guest_email_id = request.session.get('guest_email_id')
created = False
obj = None
if user.is_authenticated:
obj, created = self.model.objects.get_or_create(
user=user,
email=user.email
)
elif guest_email_id is not None:
guest_email_obj = GuestEmail.objects.get(id=guest_email_id)
obj, created = self.model.objects.get_or_create(
email=guest_email_obj.email
)
else:
print("nè guest nè user")
return obj
class BillingProfile(models.Model):
user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) #OneToOneField
email = models.EmailField()
active = models.BooleanField(default=True)
update = models.DateTimeField(auto_now=True)
timestamp = models.DateTimeField(auto_now_add=True)
# customer is in stripe or brwwin
objects = BillingProfileManager()
def __str__(self):
return self.email
def user_created_receiver(sender, instance, created, *args, **kwargs):
if created and instance.email:
BillingProfile.objects.get_or_create(user=instance, email=instance.email)
post_save.connect(user_created_receiver, sender=User)
python_ecommerce/urls.py
from django.contrib import admin
from django.urls import path, include
from .views import home_page, about_page, contact_page
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic.base import TemplateView
from carts.views import cart_home
from accounts.views import login_page, register_page
from django.contrib.auth.views import LogoutView
from accounts.views import guest_register_view
from addresses.views import checkout_address_create_view
urlpatterns = [
path('admin/', admin.site.urls),
path('', home_page, name="home"),
path('about/', about_page, name="about"),
path('contact/', contact_page, name="contact"),
path('login/', login_page, name="login"),
path('register/', register_page, name="register"),
path('bootstrap/', TemplateView.as_view(template_name='bootstrap/example.html')),
path('', include("products.urls", namespace='products')), #spostato nell altro
path('', include("search.urls", namespace='search')),
path('cart/', include("carts.urls", namespace="cart")),
path("logout/", LogoutView.as_view(), name="logout"),
path('register/guest/', guest_register_view, name="guest_register"),
path('checkout/address/create/', checkout_address_create_view, name='checkout_address_create_view'),
]
if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
carts/templates/carts/checkout.html
{% extends "base.html" %}
{% block content %}
{{ object.order_id }} &nbsp&nbsp {{ object.cart }}
{% if not billing_profile %}
<div class="row text-center">
<div class='col-12 col-md-6'>
<p class="lead">Login</p>
{% include 'accounts/snippets/form.html' with form=login_form next_url=request.build_absolute_uri %}
</div>
<br><br><br>
<div class='col-12 col-md-6'>
continue as guest
{% url 'guest_register' as guest_register_url %}
{% include 'accounts/snippets/form.html' with form=guest_form next_url=request.build_absolute_uri action_url=guest_register_url %}
</div>
<!-- qui è obbligatorio usare la struttura alias perchè non puoi mettere url tag dentro action_url= -->
</div>
{% else %}
{% if not object.shipping_address %}
<div class=row>
<div class='col-md-6 mx-auto col-10'>
<p class='lead'>Shipping Address</p>
<hr/>
{% url 'checkout_address_create' as checkout_address_create %}
{% include 'addresses/form.html' with form=address_form next_url=request.build_absolute_uri action_url=checkout_address_create address_type='shipping' %}
</div>
</div>
{% elif not object.billing_address %}
<div class=row>
<div class='col-md-6 mx-auto col-10'>
<p class='lead'>Billing Address</p>
<hr/>
{% url 'checkout_address_create' as checkout_address_create %}
{% include 'addresses/form.html' with form=address_form next_url=request.build_absolute_uri action_url=checkout_address_create address_type='billing' %}
</div>
</div>
{% else %}
<h1>Finalize checkout</h1>
<p>Cart total: {{ object.cart.total }}</p>
<p>Shipping total: {{ object.shipping_total }}</p>
<p>Order total: {{ object.total }}</p>
<button>Checkout</button>
{% endif %}
{% endif %}
{% endblock %}
SOLVED
There was a very simple error in python_ecommerce/urls.py:
In urlspattern I named checkout_address_create_view the view checkout_address_create_view, while in the template I call it as checkout_address_create, so the template could not find the function and don't know why was bringing me back to login form.
I substituted
path('checkout/address/create/', checkout_address_create_view, name='checkout_address_create_view'),
with
path('checkout/address/create/', checkout_address_create_view, name='checkout_address_create_view'),
and this solved that error.

How can I display images in Django after uploading?

I'm making a small blog. And I will be creating a cover image uploading system.
But after uploading, I'm unable to retrieve the image.
Do you have any solutions?
Here's my model.py:
class Post(models.Model):
id = models.AutoField
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
content_images = models.ImageField(default="media/noimg-l.jpg")
and here's form.py:
class Createcontent(forms.ModelForm):
class Meta:
model = Post
fields = (
"title",
"content",
"slug",
"content_images",
"status",
)
file = forms.FileField()
widgets = {
"content": SummernoteWidget(),
}
and this is the HTML I'm using:
<div class="row">
<form method="POST" enctype="multipart/form-data" class="post-form">{% csrf_token %} {{ form|crispy }}
<button type="submit" class="save btn btn-default">Save</button>
</form>
</div>
and my setting.py
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
X_FRAME_OPTIONS = 'SAMEORIGIN'
SUMMERNOTE_THEME = 'bs4' # Show summernote with Bootstrap4
and my views.py
ef create_post(request):
if request.method == "POST":
form = Createcontent(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('post_detail', post.slug)
else:
form = Createcontent()
return render(request, 'blog/post_creator.html', {'form': form})

Can't save ForeignKey data with Django

I'm trying to make a way to log notes associated with records. When the form is submitted, it's trying to redirect to the same url, but without the record id, which should be required to view the page. I defined it in urls with the record id, so it should be tracker/19/newnote
I want it to route to tracker/19/detail, and I'm not sure why it's routing to tracker/newnote, which doesn't exist in my urls file. Maybe I need to create it?
anyway, here are my files if anyone wants to take a crack at this with me.
models.py
class Record(models.Model):
serial = models.CharField('Serial Number', max_length=9)
product = models.CharField('Product', max_length=6)
ticket = models.CharField('Log/RID', max_length=9)
eng_date = models.DateField('Date Engaged')
customer = models.CharField('Customer', max_length=80)
details = models.TextField('Problem Details', max_length=800)
owner = models.CharField('Owner', max_length=40)
class Note(models.Model):
record = models.ForeignKey(Record, on_delete=models.CASCADE)
note_text = models.TextField('Notes', max_length=2000)
note_date = models.DateField('Date Entered')
views.py
def newnote(request, record_id):
if request.method == 'POST':
form = NoteForm(request.POST)
if form.is_valid():
r = Record.objects.get(pk=record_id)
r.note_set.create(note_text=form.note_text, note_date=form.note_date)
r.save()
return HttpResponseRedirect('/tracker/%s/detail/' % record_id)
else:
form = NoteForm()
return render(request, 'tracker/noteform.html', {'form': form})
forms.py
class NoteForm(ModelForm):
class Meta:
model = Note
fields = ['note_text',
'note_date'
]
widgets = {
'note_date': DateInput(),}
urls.py
urlpatterns = [
path('', views.index, name='index'),
path('create/', views.create, name='create'),
path('<int:record_id>/detail/', views.detail, name='detail'),
path('result/', views.result, name='result'),
path('query/', views.query, name='query'),
path('all/', views.show_all, name='all'),
path('<int:record_id>/newnote/', views.newnote, name='newnote'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
nameform.html template
<div id=form>
<h3>New Note??</h3>
<hr>
<form action="/tracker/newnote/" method="post">
<div id="fields">
{% csrf_token %}
<p>Note:<br>{{ form.note_text }}</p>
<p>Note Date:<br>{{ form.note_date }}</p>
<input type="submit" value="Submit" />
</div>
</form>
</div>

Categories

Resources