creating a file when a user signup












-1















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?










share|improve this question

























  • 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
















-1















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?










share|improve this question

























  • 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














-1












-1








-1








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












2 Answers
2






active

oldest

votes


















0














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






share|improve this answer


























  • 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



















0














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)





share|improve this answer


























  • 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













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
});


}
});














draft saved

draft discarded


















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









0














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






share|improve this answer


























  • 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
















0














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






share|improve this answer


























  • 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














0












0








0







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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








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



















  • 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













0














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)





share|improve this answer


























  • 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


















0














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)





share|improve this answer


























  • 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
















0












0








0







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)





share|improve this answer















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)






share|improve this answer














share|improve this answer



share|improve this answer








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





















  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)