Skip to content

Instantly share code, notes, and snippets.

View meoooh's full-sized avatar

han meoooh

  • 뉴비 주식회사
View GitHub Profile
class MyUserManager(BaseUserManager):
def create(self, email, name, birthday, sex, password):
return self.create_user(email=email,
password=password,
name=name,
birthday=birthday,
sex=sex,
)
def create_user(self, email, name, birthday, sex, password):
class UserSerializer(serializers.ModelSerializer):
password2 = serializers.CharField()
class Meta:
model = VomUser
fields = ('id', 'email', 'sex', 'birthday',
'name', 'password', 'password2')
def __init__(self, *args, **kwargs):
# Don't pass the 'fields' arg up to the superclass
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from rest_framework import serializers
class UserSerializer(serializers.ModelSerializer):
password2 = serializers.CharField()
class Meta:
model = User
$ ./manage.py shell
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.serializers import *
>>> u=UserSerializer(data={'username':'test1','password':'pass','password2':'pass'})
>>> u.errors
Traceback (most recent call last):
File "<console>", line 1, in <module>
from django.contrib.auth.models import User
from rest_framework import viewsets
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
from myapp.serializers import UserSerializer, PasswordSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
A viewset that provides the standard actions
class RightDoor(object):
def right_open(self):
print "RightDoor open complete"
self.beep()
class LeftDoor(object):
def left_open(self):
print "LeftDoor open complete"
self.beep()
class RightDoor(object):
def right_open(self):
print "RightDoor open complete"
self.beep()
class LeftDoor(object):
def left_open(self):
print "LeftDoor open complete"
self.beep()
class CommentsController < ApplicationController
before_action :set_commentable
before_action :set_comment, only: [:show, :update, :destroy]
before_filter :authenticate_user!
def index
obj = {}
params[:page] = (params[:page].to_i.is_a? Integer) ? (params[:page].to_i > 0 ? params[:page].to_i : 1) : 1
{
"comments": [
{
"id": 1,
"writer_id": 1,
"content": "test",
"commentable_id": 1,
"commentable_type": "Bookkeeping",
"created_at": "2013-11-11T14:50:10.085+09:00",
"updated_at": "2013-11-11T14:50:10.085+09:00"
Started POST "/users/sign_in.json" for 112.175.135.112 at 2013-11-01 07:31:50 +0000
Processing by Users::SessionsController#create as JSON
Parameters: {"email"=>"tester1@bbapi.com", "password"=>"12341234", "session"=>{"email"=>"tester1@bbapi.com", "password"=>"12341234"}}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'tester1@bbapi.com' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'tester1@bbapi.com' LIMIT 1
Completed 500 Internal Server Error in 4ms
NoMethodError (undefined method `valid_password?' for nil:NilClass):
app/controllers/users/sessions_controller.rb:9:in `create'