What is the difference between the create and perform_create methods in Django rest-auth [duplicate]










1
















This question already has an answer here:



  • When to use Serializer's create() and ModelViewset's create() perform_create()

    1 answer



I'm using the Django rest-auth package. I have a class that extends rest-auth's RegisterView, and which contains two methods, create and perform_create. What is the difference between these two methods?










share|improve this question













marked as duplicate by jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 15:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I think you got your answer

    – Anoop Kumar
    Nov 15 '18 at 12:21











  • Thanks. For more information you can see the tutorial on youtube youtube.com/…

    – Anoop Kumar
    Nov 15 '18 at 12:25
















1
















This question already has an answer here:



  • When to use Serializer's create() and ModelViewset's create() perform_create()

    1 answer



I'm using the Django rest-auth package. I have a class that extends rest-auth's RegisterView, and which contains two methods, create and perform_create. What is the difference between these two methods?










share|improve this question













marked as duplicate by jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 15:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I think you got your answer

    – Anoop Kumar
    Nov 15 '18 at 12:21











  • Thanks. For more information you can see the tutorial on youtube youtube.com/…

    – Anoop Kumar
    Nov 15 '18 at 12:25














1












1








1









This question already has an answer here:



  • When to use Serializer's create() and ModelViewset's create() perform_create()

    1 answer



I'm using the Django rest-auth package. I have a class that extends rest-auth's RegisterView, and which contains two methods, create and perform_create. What is the difference between these two methods?










share|improve this question















This question already has an answer here:



  • When to use Serializer's create() and ModelViewset's create() perform_create()

    1 answer



I'm using the Django rest-auth package. I have a class that extends rest-auth's RegisterView, and which contains two methods, create and perform_create. What is the difference between these two methods?





This question already has an answer here:



  • When to use Serializer's create() and ModelViewset's create() perform_create()

    1 answer







python django django-rest-auth






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 12:10









GluePearGluePear

2,97353162




2,97353162




marked as duplicate by jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 15:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 15 '18 at 15:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I think you got your answer

    – Anoop Kumar
    Nov 15 '18 at 12:21











  • Thanks. For more information you can see the tutorial on youtube youtube.com/…

    – Anoop Kumar
    Nov 15 '18 at 12:25


















  • I think you got your answer

    – Anoop Kumar
    Nov 15 '18 at 12:21











  • Thanks. For more information you can see the tutorial on youtube youtube.com/…

    – Anoop Kumar
    Nov 15 '18 at 12:25

















I think you got your answer

– Anoop Kumar
Nov 15 '18 at 12:21





I think you got your answer

– Anoop Kumar
Nov 15 '18 at 12:21













Thanks. For more information you can see the tutorial on youtube youtube.com/…

– Anoop Kumar
Nov 15 '18 at 12:25






Thanks. For more information you can see the tutorial on youtube youtube.com/…

– Anoop Kumar
Nov 15 '18 at 12:25













1 Answer
1






active

oldest

votes


















1














perform_create is called within the create method to call the serializer for creation once it's known the serialization is valid. Specifically, serializer.save()



Code from the source - when in doubt check it:



class CreateModelMixin(object):
"""
Create a model instance.
"""
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save()

def get_success_headers(self, data):
try:
return 'Location': str(data[api_settings.URL_FIELD_NAME])
except (TypeError, KeyError):
return





share|improve this answer


















  • 1





    Apposite username

    – GluePear
    Nov 15 '18 at 12:18

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














perform_create is called within the create method to call the serializer for creation once it's known the serialization is valid. Specifically, serializer.save()



Code from the source - when in doubt check it:



class CreateModelMixin(object):
"""
Create a model instance.
"""
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save()

def get_success_headers(self, data):
try:
return 'Location': str(data[api_settings.URL_FIELD_NAME])
except (TypeError, KeyError):
return





share|improve this answer


















  • 1





    Apposite username

    – GluePear
    Nov 15 '18 at 12:18















1














perform_create is called within the create method to call the serializer for creation once it's known the serialization is valid. Specifically, serializer.save()



Code from the source - when in doubt check it:



class CreateModelMixin(object):
"""
Create a model instance.
"""
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save()

def get_success_headers(self, data):
try:
return 'Location': str(data[api_settings.URL_FIELD_NAME])
except (TypeError, KeyError):
return





share|improve this answer


















  • 1





    Apposite username

    – GluePear
    Nov 15 '18 at 12:18













1












1








1







perform_create is called within the create method to call the serializer for creation once it's known the serialization is valid. Specifically, serializer.save()



Code from the source - when in doubt check it:



class CreateModelMixin(object):
"""
Create a model instance.
"""
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save()

def get_success_headers(self, data):
try:
return 'Location': str(data[api_settings.URL_FIELD_NAME])
except (TypeError, KeyError):
return





share|improve this answer













perform_create is called within the create method to call the serializer for creation once it's known the serialization is valid. Specifically, serializer.save()



Code from the source - when in doubt check it:



class CreateModelMixin(object):
"""
Create a model instance.
"""
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save()

def get_success_headers(self, data):
try:
return 'Location': str(data[api_settings.URL_FIELD_NAME])
except (TypeError, KeyError):
return






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 12:15









PythonistaPythonista

8,83821438




8,83821438







  • 1





    Apposite username

    – GluePear
    Nov 15 '18 at 12:18












  • 1





    Apposite username

    – GluePear
    Nov 15 '18 at 12:18







1




1





Apposite username

– GluePear
Nov 15 '18 at 12:18





Apposite username

– GluePear
Nov 15 '18 at 12:18





這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands