Django – Local vs Live error

I came across a strange error using Django when putting something live that I couldn’t find via google, so hopefully this will help anyone in the same position.  When I put some new code live (to allow members to enter events), it errored with:

'str' object has no attribute '_default_manager'

On my local development server it was working fine, when the payment was confirmed the event saved the relation to each member.

The relevant bits of the models were:

class Event(models.Model):
   ...
   entrants = models.ManyToManyField("members.Member", blank=True, null=True)

class Payment(models.Model):
   ...
   events = models.ManyToManyField("events.event", blank=True, null=True)

Can you see the error? The views worked fine locally on the development server, saving the payment and adding the members to the entrants list of the event.

However, on the live site (Apache & mod_python), it would give a type error:

'str' object has no attribute '_default_manager'

Confused, I asked on IRC, but apparently this sort of error is usually from having different code between local and live. I’m running from an SVN repository, this didn’t seem likely.

The other clue I had was that the admin area would give me an error when trying to look at payments. So, looking carefully at the model I spotted my mistake:

events = models.ManyToManyField("events.event", blank=True, null=True)

Capitalisation! The ‘Event’ is the model name, and should be capitalised.

It’s just strange that the local server didn’t pick up the same issue?


Comments are closed.