Теперь у меня проблема с размещением M2O: (
Model.py
class StorageDoc(models.Model): # tabela dokumentująca ruch na magazynie
typeList = (
(' ', " "),
('WZ', "WZ"),
('PZ', "PZ"),
('PM', "PM")
)
docType = models.CharField(max_length=10, choices=typeList, default=' ')
storageName = models.ForeignKey(DictStorage, on_delete=models.DO_NOTHING)
createTime = models.DateTimeField(auto_now=True)
orderNumber = models.CharField(max_length=64, blank=True)
class StorageDocPosition(models.Model):
storageDoc = models.ForeignKey(StorageDoc, on_delete=models.DO_NOTHING, related_name="sds")
item = models.ForeignKey(Part, on_delete=models.DO_NOTHING)
volumeUsed = models.IntegerField()
volumeBefore = models.IntegerField()
volumeAfter = models.IntegerField()
views.py
def StorageDocList (request):
s_documents = StorageDocPosition.objects.all().prefetch_related("storageDoc")
for s_document in s_documents:
s_documentP = StorageDocPosition.storageDoc.all()
return render(request, 'StorageDocList.html', {'storageDocAll': s_documents})
my error is:
'ForwardManyToOneDescriptor' object has no attribute 'all'
почему я не могу использовать «all "в этом случае?
Как исправить?
Спасибо за помощь: