brand = Brand.objects.get(title='mybrand')
products = Product.objects.filter(brand=brand).order_by('-score')[:4]
...gets you the top 4 products in order for the brand
On Friday, May 19, 2017 at 10:32:49 AM UTC+1, Горобец Дмитрий wrote:
>
> Hello. I have these two models. I have to show 4 or less
Hi, just a couple of follow-up questions as having trouble following
precisely.
Can you re-state the exact queries you’re looking for?
- Are you looking to check if there are tools of a given type available at
a given time?
- And whether a tool of a given type can be booked in a given time
If I'm following correctly and you want to access author profile photos
from querysets of Post objects: if you add related_name=‘profile’ to the
user field in the Profile model then you can add a method to the Post model:
def author_profile_photo(self):
return self.author.profile.photo
and
typo:
# urls.py
url(r'^(?P[A-Z]{2})', views.state_home, name="state_home"),
On Saturday, December 24, 2016 at 7:35:12 AM UTC, Andrew Beales wrote:
>
> You can pass strings from URLs as arguments into your Django view
> functions.
>
> Assuming your Jurisdiction model a
You can pass strings from URLs as arguments into your Django view functions.
Assuming your Jurisdiction model already has a "name" field, make sure it
also has a "postal_code" field (consider renaming the model State?)
Your urls and views can be something like:
# urls.py
url(r'^(?P[A-Z]{2})',
This works for me:
{% for server, images in child_list.items %}
{{ server }}
{% for image in images %}
{% for key,val in image.items %}
{{ key }}: {{ val }}
{% endfor %}
{% endfor %}
{% endfor %}
In your template, 'image' is a list of dicts, so you need to loop
All this talk about "child images on servers" has probably set off an alarm
somewhere.
On Wednesday, August 17, 2016 at 7:00:09 AM UTC+1, Andrew Beales wrote:
>
> Hi, you can use aggregation queries to count the child images connected to
> each server:
>
>
> # views.
Hi, you can use aggregation queries to count the child images connected to
each server:
# views.py
from django.db.models import Count
def servers(request):
servers = Server.objects.all()
for server in servers:
server.child_images = server.images.aggregate(total=Count('base'))
Guessing this is old news, but there are 2 problems with views:
ProductoConcepto.objects.create(producto=producto, orden=orden,
cantidad=cantidad)
- producto and orden need to be Python objects and cantidad is a float, but
the request.POST values will be string representations.
Also the ajax
9 matches
Mail list logo