Never mind I need some sleep I named my TestCase with the same name as my model... I can't believe I didn't see that.
class FishType(TestCase): On Monday, November 24, 2014 2:31:33 PM UTC-8, Detectedstealth wrote: > > When writing a test to just try and create an object from my model I get > the following error: > > 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? > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ca2243f8-a612-48a0-b95b-aeafa40b5200%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

