I'm very new at Django.
I have a custom user model:
accounts\models.py:
from django.contrib.auth.models import AbstractUser
from django.db import models
from tradestats.models import Webhook
class CustomUser(AbstractUser):
webhook = models.ManyToManyField(Webhook, blank=True)
I have a tradestats app with a Webhook model:
tradestats\models.py
from django.db import models
class Webhook(models.Model):
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
editable=False,
)
name = models.CharField(verbose_name='Webhooks name', max_length=50, null=False, blank=False)
url = models.URLField(max_length=255, null=False, blank=False, unique=True)
def __str__(self):
return self.name
class Meta:
ordering = ['name']
I have a class based View. In this View I like to query the logged in user all Webhooks url field and pass to render() as a context.
tradestats\view.py:
context = {
'form': form.cleaned_data,
'variable': value1,
'variable2': value2,
}
return render(request, template_name='renko/renko_calculate.html', context=context)
How can I query the webhook.urls and pass into context?