Last active
October 19, 2018 12:34
-
-
Save ysinjab/489a8057146723675311df0e6b100f61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in users app i added this model | |
class User(models.Model): | |
name = models.CharField(max_length=10) | |
# in django shell execute the following | |
from users.models import * | |
# the object will hold all the logic | |
new_user = User(name='Yasser') | |
# this will execute an INSERT | |
new_user.save() | |
new_user.name = 'Yasser 2' | |
# this will execute an UPDATE | |
new_user.save() | |
# for retrieving data we have to use objects property (https://docs.djangoproject.com/en/2.1/topics/db/managers/) | |
User.objects.first() # <User: User object> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment