How are you deciding which post is pinned?
The unique approach might not do any good to you.
A simple solution is to update the pinned values of each post to False &
setting the required post pinned value to True when you are setting a
pinned post.
There may be better solutions, but I hope this m
well, maybe using forms, and the parameter initial of the send form to the
template
https://docs.djangoproject.com/en/2.1/ref/forms/fields/#initial
or directly with javascript
El vie., 5 oct. 2018 a las 10:35, Chuka Nwadiogbu ()
escribió:
> Hi, I know it has been a while since this question was a
>
> Hi, I know it has been a while since this question was asked but I have a
> similar question. I have a Post model, and I want there to be one pinned
> post out of the list of all posts, I tried creating a new property thus,
```pinned = models.BooleanField(default=False, unique=True)``
Hi Javier,
oh yes! You seem to be a really creative and experienced programmer! [image:
smile.png]
My solution will be way number 5:
5) Do not set unique_together - forget about it and give the model a
function "get_default_image", which returns the first "default_image=True"
in the list.
T
On Mon, Nov 17, 2014 at 6:10 AM, ThomasTheDjangoFan
wrote:
>
> How would you do this? Can you give me a hint?
4 different ways:
- don't do it as a flag, add a 'defaultImage=ForeignKey(ProductImage)'
to the Product class.
- don't use False for non-default, use NULL. since two NULL values
aren'
Hi Jani,
thanks for making it clear. [image: smile.png]
Actually I would like to assign a lot of images to a product and only have
one image as the default image.
How would you do this? Can you give me a hint?
Am Montag, 17. November 2014 11:25:37 UTC+1 schrieb Jani Tiainen:
>
> On Sun, 16 N
On Sun, 16 Nov 2014 23:51:16 -0800 (PST)
ThomasTheDjangoFan wrote:
> Hi guys,
>
> I'd like to only be able to assign many ProcutImages to a Product, but only
> ONE Image as a default image per product
> (ProductImage.is_default_image=True).
>
> I can't get this to work correnctly on Django 1.
Hi guys,
I'd like to only be able to assign many ProcutImages to a Product, but only
ONE Image as a default image per product
(ProductImage.is_default_image=True).
I can't get this to work correnctly on Django 1.7 with a db.sqlite3: With
the code below I can only assign ONE Image to a Product.
8 matches
Mail list logo