On Mon, Mar 7, 2011 at 12:17 PM, diogobaeder <diogobae...@gmail.com> wrote:
> Alright, I printed all the tables to the stdout, while in the test, > and the table was not created before running the test. Am I missing > something here? Just creating the model and associating the app in > INSTALLED_APPS isn't enough? > > Also, there's another model in the same "models.py" module, and it's > being loaded by the tests... is there any chance it's interfering in > the other model? Here it is: > > # gear/models.py > > class DrumPiece(models.Model): > CATEGORY_CHOICES = ( > ('cymbals', 'Cymbals'), > ('drums', 'Drums'), > ('sticks', 'Sticks'), > ('heads-and-muffling', 'Heads and Muffling'), > ('microphones', 'Microphones'), > ('percussion', 'Percussion'), > ('cases', 'Cases'), > ('m-audio', 'M-Audio'), > ) > title = models.CharField(max_length=200) > description = models.TextField() > category = models.CharField(max_length=20, > choices=CATEGORY_CHOICES) > image = ImageField(upload_to=env.get('files_uploads')) > sites = models.ManyToManyField(Site, blank=True, null=True) > > def __unicode__(self): > return self.title > > def save(self, *args, **kwargs): > choices = [choice[0] for choice in self.CATEGORY_CHOICES] > if self.category is not None and self.category not in choices: > self.category = self.CATEGORY_CHOICES[0][0] > super(DrumPiece, self).save(*args, **kwargs) > > > Thanks again! > > Diogo > > > > On Mar 7, 1:41 pm, Diogo Baeder <diogobae...@gmail.com> wrote: > > Hi there, > > > > I'm having this weird error, where Django is failing while trying to run > > one of my integration tests, saying that it couldn't find the necessary > > table to create the model instance I want. > > > > Here are the relevant parts of my code, an I'm running the tests in > > SQLite in memory: > > > > # gear/tests.py > > from gear.models import ToGoPage > > #... > > class ToGoPageViewTest(TestCase): > > @istest > > def shows_an_active_to_go_page(self): > > to_go_page = ToGoPage.objects.create( > > content='Some content', > > active=True > > ) > > > > response = > > self.client.get('/do-you-want-daniel-playing-in-your-cd/') > > > > self.assertContains(response, 'Some content') > > > > # gear/models.py > > class ToGoPage(models.Model): > > content = models.TextField() > > active = models.BooleanField(default=True) > > > > # the traceback when I run the test > > ====================================================================== > > ERROR: shows_an_active_to_go_page > (danielbaeder.gear.tests.ToGoPageViewTest) > > ---------------------------------------------------------------------- > > Traceback (most recent call last): > > File > > > "/home/diogo/sites/projetos/danielbaeder/danielbaeder/../danielbaeder/gear/ > tests.py", > > line 140, in shows_an_active_to_go_page > > active=True > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /manager.py", > > line 138, in create > > return self.get_query_set().create(**kwargs) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /query.py", > > line 360, in create > > obj.save(force_insert=True, using=self.db) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /base.py", > > line 460, in save > > self.save_base(using=using, force_insert=force_insert, > > force_update=force_update) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /base.py", > > line 553, in save_base > > result = manager._insert(values, return_id=update_pk, using=using) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /manager.py", > > line 195, in _insert > > return insert_query(self.model, values, **kwargs) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /query.py", > > line 1436, in insert_query > > return query.get_compiler(using=using).execute_sql(return_id) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /sql/compiler.py", > > line 791, in execute_sql > > cursor = super(SQLInsertCompiler, self).execute_sql(None) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/models > /sql/compiler.py", > > line 735, in execute_sql > > cursor.execute(sql, params) > > File > > > "/home/diogo/Envs/danielbaeder/lib/python2.6/site-packages/django/db/backen > ds/sqlite3/base.py", > > line 234, in execute > > return Database.Cursor.execute(self, query, params) > > DatabaseError: no such table: gear_togopage > > > > Any ideas? Shouldn't Django be creating the table for me, among other > > tables, since I'm running the test suite? > > > > Thanks! > > > > -- > > Diogo Baeder - desenvolvedor webhttp://diogobaeder.com.br > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > did you run syncdb¶ <http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb> django-admin.py syncdb¶<http://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-syncdb> or python manage.py syncdb -- Joel Goldstick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.