My First Django Website #3

def __str__(self):
return self.field_name
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.id)])
# Create a new record using the model's constructor.
record = MyModelName(my_field_name="Instance #1")

# Save the object into the database.
record.save()
all_books = Book.objects.all()wild_books = Book.objects.filter(title__contains='wild')
number_wild_books = wild_books.count()
class Author(models.Model):
"""Model representing an author."""
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
date_of_birth = models.DateField(null=True, blank=True)
date_of_death = models.DateField('Died', null=True, blank=True)

class Meta:
ordering = ['last_name', 'first_name']

def get_absolute_url(self):
"""Returns the url to access a particular author instance."""
return reverse('author-detail', args=[str(self.id)])

def __str__(self):
"""String for representing the Model object."""
return f'{self.last_name}, {self.first_name}'

--

--

--

KEKW y’all won’t actually read my bio XD

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How we store multiple versions of BagIt bags

Virtual Machines

Major stages for software testing — Part One

Deploying Jenkins Server on Docker Container

So, maybe I enjoy Markdown too much

Building A (Mobile App) Developer Community

Metal Prices Get Accurate RHENIUM Prices in Turkish Lira

Palindrome Number — LeetCode

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Willy Lee

Willy Lee

KEKW y’all won’t actually read my bio XD

More from Medium

7 Steps To Learn Programming

Becoming a better programmer in a day (for beginners)

Top 5 Programming Languages to learn in 2022

5 Tips for Learning How to Code