def tasks_in_progress(request):
tasks = Task.objects.filter(Status='In progress')
context = {'tasks': tasks}
#return render(request,"todoapp/show_task.html",{'tasks':tasks})
return render(request,"todoapp/tasks_in_progress.html", context)
class Task(models.Model):
#Task_Title = models.ForeignKey(ToDoList, on_delete=models.CASCADE)
Task_Title = models.CharField(max_length=500)
Task_Description = models.CharField(max_length=500)
Priority = models.ForeignKey(Task_Priority, on_delete=models.CASCADE)
Date_Created = models.DateTimeField(auto_now_add=True)
Completion_Date = models.DateTimeField()
Assigned_To = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL)
Status = models.ForeignKey(Task_Status, on_delete=models.CASCADE)
def __str__(self):
return self.Task_Description
Field 'id' expected a number but got 'In progress'.
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/todoapp/tasks_in_progress |
Django Version: | 3.0.2 |
Exception Type: | ValueError |
Exception Value: | Field 'id' expected a number but got 'In progress'. |
Exception Location: | C:\Users\Chuck Madamombe\Desktop\djangoPROJECTS\lib\site-packages\django\db\models\fields\__init__.py in get_prep_value, line 1772 |
Python Executable: | C:\Users\Chuck Madamombe\Desktop\djangoPROJECTS\Scripts\python.exe |
Python Version: | 3.7.1 |
Python Path: | ['C:\\Users\\Chuck Madamombe\\Desktop\\djangoPROJECTS', 'C:\\Users\\Chuck Madamombe\\Desktop\\djangoPROJECTS\\Scripts\\python37.zip', 'C:\\Users\\Chuck ' 'Madamombe\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\Chuck ' 'Madamombe\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\Chuck Madamombe\\AppData\\Local\\Programs\\Python\\Python37-32', 'C:\\Users\\Chuck Madamombe\\Desktop\\djangoPROJECTS', 'C:\\Users\\Chuck Madamombe\\Desktop\\djangoPROJECTS\\lib\\site-packages', 'C:\\Users\\Chuck ' 'Madamombe\\Desktop\\djangoPROJECTS\\lib\\site-packages\\setuptools-39.1.0-py3.7.egg'] |
Server time: | Sun, 9 Feb 2020 10:22:05 +0200 But if I just retrieve all the records in the database, without filtering, its working without an error My View to retrieve all the records in the database, without filtering. def show_task(request): |
Hi Chuck,
Status in your example is not a text field, but a Foreign Key,
that means a reference to a record in another table Task_Status,
you see that here:
Status = models.ForeignKey(Task_Status, on_delete=models.CASCADE)
tasks = Task.objects.filter(Status__name='In progress')
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a13041e8-1c37-4722-bf64-4faa75dd56ff%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMeub5MQYn2EmMESTzbYqvkzO%3D6Qa1Rd7%3Ds2Kg%3DS9eibjX7fTw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03679dec-cbd3-0890-4a10-afdff2336734%40gmail.com.
I have a local host website working with some page showing few details of one of many products with a data associated for usage like zoom car rental.
Facing issues while trying to add a counter and have it updated by day.
Eg: if I have a product a available 10 units for next 10 days and it gets booked for one day 3 units, the counter should update.
Need help for the same.
Thanks,
Brajesh
Sent from Mail for Windows 10
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5e404fcb.1c69fb81.c5c43.951d%40mx.google.com.