line 10, in test_saving_and_retrieving_fishtypes
test2.save()
AttributeError: 'FishType' object has no attribute 'save'
tests.py
from django.test import TestCase
from trip.models import FishType
class FishType(TestCase):
def test_saving_and_retrieving_fishtypes(self):
test2 = FishType()
test2.name = "Testing"
test2.save()
saved_fish_type = FishType.objects.all()
self.assertEqual(saved_fish_type.count(), 1)
models.py
from django.db import models
class FishType(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
Now when using django shell everything works as expected, but for some reason the tests won't work.
>>> from trip.models import *
>>> test_ = FishType()
>>> test_.save()
>>> test_
<FishType: >
>>> test2 = FishType()
>>> test2.name = "Testing"
>>> test2.save()
>>> FishType.objects.all()
[<FishType: >, <FishType: Testing>]
Am I missing something?