Hi , it works,
it was my confusion,, 
i update record status as Inactive so , it hide the record.

thanks for your support

On Saturday, January 8, 2022 at 7:47:17 PM UTC+5:30 Feroz Ahmed wrote:

> No errors: but no any actions, 
> all records shows in home1.html
> not excluding the Inactive records.
>
>
> def delete(request,id):
>         employee=Employee.objects.get(id=id)
>         employee.status='Inactive'
>         return redirect('/home1')
>
> --------------------------------------------
> #listview
>
> def home1(request):
>         employees=Employee.objects.exclude(status='Inactive')
>         return render(request,'asgapp/home1.html',{'e':employees})
>
> On Friday, January 7, 2022 at 10:43:54 PM UTC+5:30 [email protected] 
> wrote:
>
>> As Pankaj mentioned, add a field in your model called status or something 
>> like that. On the makemigrations set all status as 'Active'
>>
>> Then, your function will not delete, will update the object.
>>
>> def delete(request,id):
>>         employee=Employee.objects.get(id=id)
>>         employee.status = 'Inactive'
>>         return redirect('/home1')
>>
>> in your listview, you should only show active records, for that add an 
>> exclude to the queryset.
>>
>> queryset = Model.objects.exclude(status='Inactive') 
>>
>> or with a filter
>>
>> queryset = Model.objects.filter(status='Active') 
>>
>>
>> If you want to use delete, I've used before django-simple-history. the 
>> package records all history for models and objects and let you query that 
>> information.
>>
>>
>> Regards,
>>
>> Julio Cojom.
>>
>>
>>
>>
>> El vie., 7 de enero de 2022 9:48 a. m., Feroz Ahmed <[email protected]> 
>> escribió:
>>
>>> Hi, Pankaj
>>> thanks for the tips!
>>>
>>> i try all the way, 
>>> it not success , any syntax please.
>>> mean time i success to delete the record code as below: (but i just want 
>>> to inactive the record of particular employee) history might need for audit 
>>> purpose.
>>>
>>> def delete(request,id):
>>>         employee=Employee.objects.get(id=id)
>>>         employee.delete()
>>>         return redirect('/home1')
>>>
>>> Regards
>>>
>>>
>>>
>>> On Friday, January 7, 2022 at 7:29:18 PM UTC+5:30 [email protected] 
>>> wrote:
>>>
>>>> Then simply make that records inactive by adding one flag in table and 
>>>> instead of deleting make It inactive 
>>>>
>>>> On Fri, 7 Jan, 2022, 7:22 pm Feroz Ahmed, <[email protected]> wrote:
>>>>
>>>>> Hi,
>>>>> How to delete user salary record , but want to keep history till 
>>>>> deleted date.
>>>>>
>>>>> ex:
>>>>>
>>>>>    1. Month June
>>>>>    2. Month July
>>>>>    3. Month Aug
>>>>>    4. delete user record from Sep.
>>>>>
>>>>> -- 
>>>>> 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 [email protected].
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/django-users/f2ba2f5f-ed12-45e5-8d2a-d2b1b2590154n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/django-users/f2ba2f5f-ed12-45e5-8d2a-d2b1b2590154n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>> 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 [email protected].
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/7ebc8721-d3c1-4f2b-8c18-384820a8483fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/7ebc8721-d3c1-4f2b-8c18-384820a8483fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e711c8b6-0973-4560-bb1b-6fd12b3d3617n%40googlegroups.com.

Reply via email to