Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial 
   
    Eric Hyatt
3,058 PointsUnable to resolve TabErrors
Please assist with these errors. I can't find the issue with these lines.
Error:
Traceback (most recent call last):
  File "app.py", line 6, in <module>
    import forms
  File "/home/treehouse/workspace/forms.py", line 6, in <module>
    from models import User
  File "/home/treehouse/workspace/models.py", line 23
    def get_stream(self):
                        ^
TabError: inconsistent use of tabs and spaces in indentation 
from flask import (Flask, g, render_template, flash, redirect, url_for)
from flask.ext.bcrypt import check_password_hash
from flask.ext.login import (LoginManager, login_user, logout_user,
                             login_required, current_user)
import forms
import models
DEBUG = True
PORT = 8000
HOST = '0.0.0.0'
from flask_wtf import Form
from wtforms import StringField, PasswordField, TextAreaField
from wtforms.validators import (DataRequired, Regexp, ValidationError, Email,
                               Length, EqualTo)
from models import User
def name_exists(form, field):
    if User.select().where(User.username == field.data).exists():
        raise ValidationError('User with that name already exists.')
import datetime
from flask.ext.bcrypt import generate_password_hash
from flask.ext.login import UserMixin
from peewee import *
DATABASE = SqliteDatabase('social.db')
class User(UserMixin, Model):
    username = CharField(unique=True)
    email = CharField(unique=True)
    password = CharField(max_length=100)
    joined_at = DateTimeField(default=datetime.datetime.now)
    is_admin = BooleanField(default=False)
    class Meta:
        database = DATABASE
        order_by = ('-joined_at',)
        def get_posts(self):
            return Post.select().where(Post.user == self)
    def get_stream(self):
        return Post.select().where(
        (Post.user == self)
        )
    @classmethod
    def create_user(cls, username, email, password, admin=False):
        try:
            cls.create(
                username=username,
                email=email,
                password=generate_password_hash(password),
                is_admin=admin)
        except IntegrityError:
            raise ValueError("User already exists")
class Post(model):
    timestamp = DateTimeField(default=datetime.datetime.now)
    user = ForeignKeyField(
        rel_model=User
        related_name='posts'
    )
    content = TextField()
    class Meta:
        database=DATABASE
        order_by=('-timestamp', )
def initialize():
    DATABASE.connect()
    DATABASE.create_tables([User], safe=True)
    DATABASE.close()
1 Answer
 
    Myers Carpenter
6,421 PointsYou need to search your source files and remove any tab characters. Different text editors have different ways of doing this, but the editor I use, Sublime Text, has a menu "Find -> Replace..." then search for "\t" (a common notation for tabs) and replace with " " (4 spaces).
You should look to see if your editor will help you out with this. Sublime Text by default on python files will insert the right number of spaces to get your code indented correctly. For python I strongly suggest using spaces only.
Eric Hyatt
3,058 PointsEric Hyatt
3,058 PointsI was able to fix it with my editor. Thank you!