Hello i have created a simple model and now i want to access the data in another model to view it later on.
My model looks like this:
from django.db import models
class A(models.Model):
asd = models.CharField(max_length=50,default="DEFAULT VALUE")
def __str__(self):
return(self.asd)
Now i want a second model in which i get the data from the first model and add each element to a list or something like that. For Background i am doing this like so, so i can create a drop down widget with choices that can be changed and added to in the admin page.
I was first thinking of creating another model or form and came up with this, though it doesn´t work:
#this is not in the model.py file
from .models import A
class B(forms.Form):
a = A.objects.all()
b = []
for i in range(len(a)):
b.append(a[i])
c = forms.ChoiceField(choices=b)