Putting additional data to CRUD django model- iterating with id,pk/ Python3/Django/CRUD

Viewed 21

this is in models.py

    class Word(models.Model):
    english = models.CharField( max_length=100)
    polish = models.CharField( max_length=100) 

this is in views.py

words=[]

   def dictionary(request):
        words= Word.objects.all()
        context={'words':words}
        return render(request, 'base/dictionary.html', context)  `

``

  def word(request, pk):
        word= Word.objects.get(id=pk)
        context={'word':word}
        return render(request, 'base/word.html', context)

I would like to add this dictionary from my workplace to already existing database with models - English-Polish pair. I've created a CRUD model of this type of simple dictionary, yet I am wondering if I have to put all the words inside by myself , or there will be a possibility to append each pair with specific id , ready to be rendered into html template and database ?

    words=['fallopian tube' : 'jajowód',
    'mrsa bacteria' : 'bakteria gronkowca złocistego',
    'carotid aneurysm': 'tętniak tętnicy szyjnej',...] 

0 Answers
Related