title: Python class method throws AttributeError
body: <p>I'm having issues getting a class method to run in Flask.</p>
  
  <p>In <code>models/User.py</code>:</p>
  
  <pre><code>from mongoengine import *
  
  class User(Document):
    first_name = StringField()
    last_name = StringField()
    ...
  
    def __init__(self, arg1, arg2, ...):
      self.first_name = arg1
      self.last_name = arg2
      ...
  
    @classmethod
    def create(self, arg1, arg2, ...):
      #do some things like salting and hashing passwords...
      user = self(arg1, arg2, ...)
      user.save()
      return user
  </code></pre>
  
  <p>In the main application python file:</p>
  
  <pre><code>from models import User
  ...
  def func():
    ...
  
    #Throws "AttributeError: type object 'User' has no attribute 'create'"
    user = User.create(arg1, arg2, ...) 
  </code></pre>
  
  <p>Shouldn't I be able to call create on the User class without instantiating a User object? I'm using Python 2.7.2, and I also tried the non-decorator syntax of using <code>create = classmethod(create)</code>, but that didn't work. Thanks in advance!</p>
  
  <p>EDIT: I found one issue: that the models folder did not contain an <code>__init__.py</code> file, so it wasn't a module, so <code>from models import User</code> was not actually importing the file I wanted it to.  It did not give me an error from before because I used to have a <code>models.py</code> module in the same directory as the application python script, but after deleting it I never deleted the corresponding <code>.pyc</code> file. Now, I'm getting the error <code>AttributeError: 'module' object has no attribute 'create'</code> instead of what I had before, but I'm certain it is importing the correct file now.</p>
  
  <p>EDIT2: Solved. I then changed the import to <code>from models.User import User</code> and It's hitting the method now.</p>