creating a file when a user signup
I need a file to be created when a user signs up.
below is my signup view.py in django:
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
what should I do to a file be created at the same time when user signs up?
python django
add a comment |
I need a file to be created when a user signs up.
below is my signup view.py in django:
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
what should I do to a file be created at the same time when user signs up?
python django
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10
add a comment |
I need a file to be created when a user signs up.
below is my signup view.py in django:
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
what should I do to a file be created at the same time when user signs up?
python django
I need a file to be created when a user signs up.
below is my signup view.py in django:
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
what should I do to a file be created at the same time when user signs up?
python django
python django
edited Nov 26 '18 at 7:46
Majid Roustaei
5210
5210
asked Nov 26 '18 at 7:15
neha ameerneha ameer
125
125
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10
add a comment |
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10
add a comment |
2 Answers
2
active
oldest
votes
your problem is creating a file. your question is about how to create that file or is about when to use that code?
this is the code you need to create a file:
f = open("guru99.txt", "w+")
for more information have a look on this:
https://www.guru99.com/reading-and-writing-files-in-python.html
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
add a comment |
You can write your file generation code in post method of class which is going to be path of sign up click button.
class SignUp(view):
#code
def post(self, request):
filename = request['user'] + ".txt"
#if above doesn't work try this:
#filename = str(request['user'])+".txt"
f = open(filename, 'w+')
f.write(request)
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476270%2fcreating-a-file-when-a-user-signup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
your problem is creating a file. your question is about how to create that file or is about when to use that code?
this is the code you need to create a file:
f = open("guru99.txt", "w+")
for more information have a look on this:
https://www.guru99.com/reading-and-writing-files-in-python.html
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
add a comment |
your problem is creating a file. your question is about how to create that file or is about when to use that code?
this is the code you need to create a file:
f = open("guru99.txt", "w+")
for more information have a look on this:
https://www.guru99.com/reading-and-writing-files-in-python.html
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
add a comment |
your problem is creating a file. your question is about how to create that file or is about when to use that code?
this is the code you need to create a file:
f = open("guru99.txt", "w+")
for more information have a look on this:
https://www.guru99.com/reading-and-writing-files-in-python.html
your problem is creating a file. your question is about how to create that file or is about when to use that code?
this is the code you need to create a file:
f = open("guru99.txt", "w+")
for more information have a look on this:
https://www.guru99.com/reading-and-writing-files-in-python.html
edited Nov 26 '18 at 7:39
answered Nov 26 '18 at 7:22
Majid RoustaeiMajid Roustaei
5210
5210
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
add a comment |
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Actually i have to open the file in signup class. Is there any way to do so
– neha ameer
Nov 26 '18 at 7:38
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
Why don't you use the code above in any class you need? you can also send the data which stored in the file as an argument.
– Majid Roustaei
Nov 26 '18 at 7:44
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
yeah! thanks this worked. Will i be able to call this file in any other function outside the class
– neha ameer
Nov 26 '18 at 7:52
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
It could be done, you need to choose how to use it according to your project.
– Majid Roustaei
Nov 26 '18 at 7:58
add a comment |
You can write your file generation code in post method of class which is going to be path of sign up click button.
class SignUp(view):
#code
def post(self, request):
filename = request['user'] + ".txt"
#if above doesn't work try this:
#filename = str(request['user'])+".txt"
f = open(filename, 'w+')
f.write(request)
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
add a comment |
You can write your file generation code in post method of class which is going to be path of sign up click button.
class SignUp(view):
#code
def post(self, request):
filename = request['user'] + ".txt"
#if above doesn't work try this:
#filename = str(request['user'])+".txt"
f = open(filename, 'w+')
f.write(request)
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
add a comment |
You can write your file generation code in post method of class which is going to be path of sign up click button.
class SignUp(view):
#code
def post(self, request):
filename = request['user'] + ".txt"
#if above doesn't work try this:
#filename = str(request['user'])+".txt"
f = open(filename, 'w+')
f.write(request)
You can write your file generation code in post method of class which is going to be path of sign up click button.
class SignUp(view):
#code
def post(self, request):
filename = request['user'] + ".txt"
#if above doesn't work try this:
#filename = str(request['user'])+".txt"
f = open(filename, 'w+')
f.write(request)
edited Nov 27 '18 at 9:22
answered Nov 26 '18 at 10:05
Nagesh MhapadiNagesh Mhapadi
878
878
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
add a comment |
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
i tried this but i'am getting an error : ` unsupported operand type(s) for +: 'SimpleLazyObject' and 'str'` @Nagesh Mhapadi
– neha ameer
Nov 26 '18 at 10:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476270%2fcreating-a-file-when-a-user-signup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you mean by saying a file? Another model instance?
– Rarblack
Nov 26 '18 at 7:29
by saying file i meant file not model instance . I need a json file to be created when a user sign up in the webpage.
– neha ameer
Nov 26 '18 at 7:35
I need only one file to be created for each user. so that user could save some data to file @ruddra
– neha ameer
Nov 26 '18 at 8:01
i need to write some json data for everyb user @ruddra
– neha ameer
Nov 26 '18 at 8:10