Skip to content
Advertisement

django framework: get value from django.db.models.fields.IntegerField

How can I get value from class django.db.models.fields.IntegerField? I want get 1 from admin field. This is python code: model class and function view

JavaScript

A view function when I run user = Users.objects.get(id=userId)

JavaScript

Advertisement

Answer

I presume, you want the value of admin. From my understanding what you can do is you can use filter method on you object inside your Users model. As you have intialized the model fields inside the __init__ method, that I am sure is not a good practice, but based on your requirement here you can do:

JavaScript

Then you can replace your line user = Users.objects.get(id=userId) with user = User(userId)

I hope this is what you are looking for!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement