I have the following relationship in a model
class Contract(models.Model):
supplier = models.ForeignKey(
Supplier,
on_delete=models.CASCADE,
verbose_name="Supplier Name",
related_name="contract_suppliers",
)
I am trying to include an if statement in my temp
why using a foreignkey then? what type of relationship is existing between
the supplier and the
On Thu, Jan 12, 2023 at 2:13 PM 'dtdave' via Django users <
django-users@googlegroups.com> wrote:
> I have the following relationship in a model
>
> class Contract(models.Model):
> supplier = model
Replace supplier with related_name
On Thu, 12 Jan 2023 at 16:13, 'dtdave' via Django users <
django-users@googlegroups.com> wrote:
> I have the following relationship in a model
>
> class Contract(models.Model):
> supplier = models.ForeignKey(
> Supplier,
> on_delete=models.CA
Hey! Am having a problem. And l request for your Help.
Am having 3 apps in Django project
- action
- adventure
- others
#action/ models.py
class Action(models.Model):
name=models.Charfield()
os= models.Charfield( choices=OS)
#adventure/models.py
class Adventure(model
Hi Everyone,
This is the output i get used this code
https://groups.google.com/d/msgid/django-users/95dedc5d-5f24-4b57-b525-248c01953bddn%40googlegroups.com.
Hi friends myself chandresh I am new Django community I have a doubt to be
cleared ,
So I wanted to create an platform where you can register users name,
state, city and photo
which would also store in Mysql database. Can anyone help me in creating
this platform.
--
You received this messag
Have you figured out a solution to it?
On Thu, 12 Jan 2023, 15:52 Namanya Daniel,
wrote:
>
> Replace supplier with related_name
>
> On Thu, 12 Jan 2023 at 16:13, 'dtdave' via Django users <
> django-users@googlegroups.com> wrote:
>
>> I have the following relationship in a model
>>
>> class Cont
The supplier field in contract is an instance of a Supplier object which is
not a string, so comparing it to a string won't work, instead compare a
field of the supplier instance in the supplier field in contract instance.
Like: {% if contract.supplier.name == "IBM"%}
Do you get it?
On Thu, Jan
You can't compare the `contract.supplier` attribute directly to a string
like 'IBM', because it is a foreign key to a `Supplier` model instance.
Instead, you need to access the related `Supplier` model's attributes to
compare them. For example, if the `Supplier` model has a `name` attribute,
you ca
9 matches
Mail list logo