-2

I can't open the settings.py file from here. What steps do I have do take to work it out?

bash shell screenshot

xyres
  • 20,487
  • 3
  • 56
  • 85
M.Carreira
  • 87
  • 1
  • 10
  • 5
    (1) Go to `mysite` directory: `cd mysite`. (2) Run django: `python manage.py runserver`. I think you need to spend a few hours learning how to use command line. Also, read the [Django tutorial](https://docs.djangoproject.com/en/1.11/intro/tutorial01/). You can 't expect to make a website using Django without at least reading the tutorial. – xyres Nov 27 '17 at 10:55
  • Judging from the image, it seems like `settings.py` is available in your `~/mysite/mysite` directory (`~/mysite/mysite/settings.py`). You also never activate a virtualenv anywhere. I don't see any problem here. – randyr Nov 27 '17 at 10:56
  • I've already read a lot of tutorials but I can't open it. What about now? – M.Carreira Nov 27 '17 at 10:58
  • @M.Carreira Sorry, but the screenshot you included says otherwise. – xyres Nov 27 '17 at 11:02
  • Now I tried to open the browser but it doesn't show me anything instead of "It's not possible to open this page" – M.Carreira Nov 27 '17 at 11:03
  • @Randyr I know the directory is available but I can't go through from the image I sent – M.Carreira Nov 27 '17 at 11:06
  • @M.Carreira You, and did get through though. The last time you did `ls` you see the `settings.py` right there. What are you trying to do with the `settings.py`? Edit it? Run your Django application as debug with `python manage.py runserver`? What are you expecting to happen, and what are you trying? – randyr Nov 27 '17 at 11:12
  • Yes, I'm trying to edit it but I can't open the "settings.py" file through here – M.Carreira Nov 27 '17 at 12:37

2 Answers2

0

You need to create a location for your application.(eg myapp) Then inside that folder you need to have created a virtual environment for your application. (eg env.) Read the virtual environment tutorials to do this. When you have done this, you need to activate your virtual environment by running a source command.

source /<path to my app>/<my app>/env/bin/activate

Once you have activated your environment, you install django, create your application, and install any plugins etc here inside your virtual app. This keeps it separate from other apps or environments you might run in the future.

In order to run any commands like:

python manage.py runserver

it is easiest to have your command line prompt located at the the same location as your manage.py file. If you do ls -l at the command prompt and don't see manage.py in the list, then you are probably in the wrong location.

If you want to edit the settings file you need to use a text editor. On Debian I use nano.

nano /<path to myapp>/<myapp>/settings.py

Hope this helps.

cander
  • 279
  • 6
  • 14
  • I think you meant `//` instead of `//`? – xyres Nov 27 '17 at 11:25
  • Well yes you could write it that way but I wrote it this way because I keep my virtualenv inside my app and I have a separate virtualenv for each app I create. That way I can run different apps with different requirements, plugins and versions of django, python etc, depending on the requirements of the client and the app I'm building. – cander Nov 27 '17 at 11:43
  • You keep virtualenv inside your app? Well, the way I work (and I think everyone else does too) is I create a main directory to keep all my virtualenvs for every app. The advantage of this is that I can change my projects location if I want, and the virtualenv won't break. See this https://stackoverflow.com/a/37101078/1925257 But, whatever works for you, I guess. – xyres Nov 27 '17 at 12:50
  • It is all working for now, but I go to browser, it appears a message of error and nothing is shown – M.Carreira Nov 27 '17 at 15:42
  • xyres , thanks for the link. I can't for the life of me remember where I read that I should put the env inside my project but it seemed like a good idea at the time! :-) At the moment I'm not planning to distribute any of my apps that I have so I should be ok, but for future ones I'll probably switch to the standard convention. Thanks for the tip. – cander Nov 28 '17 at 14:57
  • M.Carreira, post the error message and maybe someone can help. – cander Nov 28 '17 at 14:59
-1

Use some text editor. I use Sublime Text. Go to File->Open Folder. Select mysite as your folder. Then you will be able to open settings.py

Gayathri
  • 140
  • 11