Friday, October 25, 2019

to make a wish list .

models.py
from django.db import models

# Create your models here.
class Item(models.Model):
Name_Item = models.CharField(max_length=20)
Date = models.DateField()

********************************************************
forms.py
from django import forms
from tapp.models import Item

# create your forms here:
class ItemForm(forms.ModelForm):
class Meta():
model = Item
fields = '__all__'
********************************************************

views.py

from django.shortcuts import render,get_object_or_404
from tapp.forms import Item
from tapp import forms
from django.http import HttpResponseRedirect

# create your views here:
def item_add_view(request):
form = forms.ItemForm()
if request.method =="POST":
form = forms.ItemForm(request.POST)
if form.is_valid():
form.save(commit=True)
return HttpResponseRedirect('/show')
else:
form = forms.ItemForm()
return render(request,'myapp/Itemadd.html',{'form':form})

def show_view(request):
dataitem = Item.objects.all()
return render(request,'myapp/Itemshow.html',{'dataitem':dataitem})


def wish_view(request):

required code here.

hello, 
I am Surendra Mishra , I am student currently i'm learning django.
I applied for internship , but they gave me a task if i complete then they will consider me . 
please help me to complete this task. 

mostly i have done but in the last section im fighting but i not getting exact thing .
i have some item and in under i have wishlist button ..... my requirement is when i click  the wishlist button for the particular item that item must be added in the wishlist page .

so what is the logic and what is the template page for that .


 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4f2d8d4-a6f4-45ea-8022-538e91f1b124%40googlegroups.com.

No comments:

Post a Comment