这是我的应用程序models.py
文件auth
:[在中创建auth_article
表sql
]
from django.db import models
class Article(models.Model):
title=models.TextField()
content=models.TextField()
但是,我无法在登录时检索auth_article
字段。sql
我正在使用User
模型进行登录。
from django.shortcuts import render_to_response
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from auth.models import Article
def login_user(request):
state = "Please login below..."
username = password = ''
if request.POST:
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
state = "You're successfully logged in!"
user_info = dict(username=username, email=user.email, fullname=user.get_full_name(), id=user.id)
aa=Article.objects.all()
return render_to_response('home.html', aa)
...
...