If you only want to quickly test your models, you can run the interactive shell and execute your code there.
python manage.py shell
The above command launches an interactive python shell initialized with your Django project settings.
Then you can do something like:
from your_app_name.models import Dodavatel p = Dodavatel(nazov='Petr', dostupnost=1) p.save()
I do not recommend using this code directly inside the view. Instead, to create an element, I would use a class-based view, like CreateView .
source share