What is the difference between the create and perform_create methods in Django rest-auth [duplicate]
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?
python django django-rest-auth
marked as duplicate by jpp
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.
add a comment |
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?
python django django-rest-auth
marked as duplicate by jpp
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
add a comment |
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?
python django django-rest-auth
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
python django django-rest-auth
asked Nov 15 '18 at 12:10
GluePearGluePear
2,97353162
2,97353162
marked as duplicate by jpp
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
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
1
Apposite username
– GluePear
Nov 15 '18 at 12:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
1
Apposite username
– GluePear
Nov 15 '18 at 12:18
add a comment |
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
1
Apposite username
– GluePear
Nov 15 '18 at 12:18
add a comment |
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
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
answered Nov 15 '18 at 12:15
PythonistaPythonista
8,83821438
8,83821438
1
Apposite username
– GluePear
Nov 15 '18 at 12:18
add a comment |
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
add a comment |
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