DEV Community

Discussion on: Writing Django custom command

Collapse
 
marlysson profile image
Marlysson Silva

Great post! But I have a doubt. Why do you just put the filename directly? Currently you call the app config path name, management and command folders append to filename.

Thanks.

Collapse
 
arsho profile image
Ahmedur Rahman Shovon

@marlysson , I have kept the files in the same directory of where I put the custom command. I suppose it is good practice to import data files in this way. Have you tried using the filename directly?

Thank you.
Shovon

Collapse
 
marlysson profile image
Marlysson Silva

Yes, I do.
Was because instead get current directory and join with filename, you got the app name and join with many folders and after that join with filename to build the complete path to file.

I just got this doubt, but this article was very useful to me.

Thread Thread
 
arsho profile image
Ahmedur Rahman Shovon

@marlysson , glad the tutorial helped you. FYI, I have added Django Custom Command in Django Docs Example Polls Application in this Github code repository: github.com/arsho/django-custom-com...

Stay safe! :)