agateblue / lifter

A generic query engine, inspired by Django ORM
ISC License
449 stars 16 forks source link

Documentation example broken (AttributeError: 'module' object has no attribute 'models') #35

Closed Hellowlol closed 8 years ago

Hellowlol commented 8 years ago

Using

import lifter

users = [
    {
        "is_active": True,
        "age": 35,
        "eye_color": "brown",
        "name": "Bernard",
        "gender": "male",
        "email": "bernard@blackbooks.com",
    },
    {
        "is_active": True,
        "age": 34,
        "eye_color": "brown",
        "name": "Manny",
        "gender": "male",
        "email": "manny@blackbooks.com",
    },
    {
        "is_active": True,
        "age": 35,
        "eye_color": "brown",
        "name": "Fran",
        "gender": "female",
        "email": "fran@blackbooks.com",
    },
    # And so on ...
]

User = lifter.models.Model('User')
manager = User.load(users)

results = manager.filter(User.age == 26, User.is_active == True)

I get: Traceback (most recent call last): File "C:\htpc\top_sites\testlifter.py", line 169, in User = lifter.models.Model('User') AttributeError: 'module' object has no attribute 'models'

agateblue commented 8 years ago

Hi, thanks for reporting this : it was caused by a refactoring I made a few weeks ago. Before that, everything was imported in lifter's __init__, but now, you have to explicitely import the modules you want to use.

It's basically just a matter of replacing import lifter by import lifter.models

I've updated the README to reflect that, feel free to report any other issue you could encounter !