Django querry доступ к данным
How do i access the data from the user from another table? I just want to extract a number from a database then use it for another function. The number is in another table, but i have used the user as an id. Here is my view.py
def showform(request):
form = FormNumber()
if request.user.is_authenticated:
phone = customer.objects.filter(phone='phone')
print(phone)
context = {'form': form}
return render(request, 'mpesa/pay.html', context)
Здесь находится мой model.py
class customer(models.Model):
user = models.ForeignKey(User, on_delete=CASCADE)
phone = models.CharField(max_length=50)
def __str__(self):
return str(self.user)