Opened 17 years ago

Last modified 17 years ago

#3638 closed

loading python fixtures is broken — at Initial Version

Reported by: donlaverty Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords: fixture
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Reproduce:
Use this fixture:
[{"pk": "1", "model": "main.category", "fields": {"link_name": "all", "name": "\/", "parent": null, "description": ""}}, {"pk": "2", "model": "main.category", "fields": {"link_name": "accessoires", "name": "Accessoires", "parent": 1, "description": ""}}, {"pk": "3", "model": "main.category", "fields": {"link_name": "art_and_design", "name": "Art & Design", "parent": 1, "description": ""}}]

with this model:
class Category(models.Model):

class Admin:

pass

class Meta:

ordering =name

name = models.CharField(maxlength=50)
link_name = models.SlugField(unique=True)
description = models.TextField(blank=True)
parent = models.ForeignKey('self',blank=True,null=True)


def tree(self,tree=[]):

tree.append( self )
children = self.category_set.all()
child_tree = []
for c in children:

if c.name != '/':

c.tree(child_tree)

if not child_tree == []:

tree.append(child_tree)

return tree

def link(self):

return str(self)[2:]

def str(self):

if not self.parent :

return self.name

return str(self.parent) + '/' + self.name

now try to load it via syncdb

(while you are at it you could clarify in the documentation that python fixtures need to carry the extension .python

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top