django.core.exceptions.FieldError: Cannot resolve keyword 'y' into field. 
Choices are: author, category, id, isbn, name

I am also getting the same error.




On Sunday, 18 July 2021 at 19:36:51 UTC+5 [email protected] wrote:

> I am getting this error message:
>
> raise FieldError("Cannot resolve keyword '%s' into field. "
> django.core.exceptions.FieldError: Cannot resolve keyword 'date' into 
> field. Choices are: bad, created, doa, entered, id, non, para, received, 
> released, slabel, specie, specie_id, supplier, supplier_id
>
> these are my models:
> Shipment:
> class Shipment(models.Model):
> supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
> created = models.DateTimeField(default=timezone.now)
> slabel = models.CharField(max_length=10)
> specie = models.ForeignKey(Specie, on_delete=models.CASCADE)
> received = models.PositiveIntegerField(default=0)
> bad = models.PositiveIntegerField(default=0)
> non = models.PositiveIntegerField(default=0)
> doa = models.PositiveIntegerField(default=0)
> para = models.PositiveIntegerField(default=0)
> released = models.PositiveIntegerField(default=0)
> entered = models.BooleanField(default=False)
>
> def get_absolute_url(self):
> return reverse("shipments:detail", kwargs={"pk": self.pk})
>
> def __str__(self):
> return f"{self.specie.name}-{self.created.strftime('%Y/%m/%d')}-{
> self.supplier.name}"
>
> suppliers:
>
> class Supplier(models.Model):
> supplierID = models.PositiveIntegerField(default=1)
> name = models.CharField(max_length=120)
> logo = models.ImageField(upload_to="suppliers", default="no_picture.png")
> phone = models.CharField(max_length=15, null=True)
> email = models.CharField(max_length=120)
> country = models.CharField(max_length=120, null=True, blank=True)
> address = models.CharField(max_length=120, null=True, blank=True)
> city = models.CharField(max_length=120, null=True, blank=True)
> state = models.CharField(max_length=120, null=True, blank=True)
> zipCode = models.CharField(max_length=10, null=True, blank=True)
>
> def __str__(self):
> return self.name
>
> species:
>
> class Specie(models.Model):
> name = models.CharField(max_length=50)
> image = models.ImageField(upload_to="species", default="no_picture.png")
> created = models.DateTimeField(default=timezone.now)
>
> def __str__(self):
> return self.name
>
> class Meta:
> ordering = [
> "name",
> ]
>
> everything is working the way I want but when I try to get data into a 
> variable I get the above error and I don't have a clue where to start to 
> resolve this.  As from the models I have no field named date so I am 
> confused.
>
> The error is generated by this line:
> qs = Shipment.objects.filter(date__range=[date_from, date_to])
>
> even if I enter strings for testing, for example
> qs = Shipment.objects.filter(date__range=['2021-01-01', '2021-02-01'])
>
> I been all over the web looking for possible solutions but I am at a 
> loss.  Thanks for any thoughts or suggestions you may have.
>
>
>

-- 
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/4adf0810-b383-45e0-b69e-85db67be603an%40googlegroups.com.

Reply via email to