What exactly does manage.py file do - manage.py

I am very new to python/django programming, as in I have no programming background. I am working on a class online and I just would like to know exactly what the manage.py file does. I've tried googling it, but I have not found any answers other than it puts a thin shell around django-admin.py. I still don't understand what the file does. I just know I need to type it whenever I do certain things.

(I assume you've read the documentation. But if not, take note that one of Django's great strong points is its documentation -- I recommend going there first before hitting Google.)
You can think of the arguments you pass to manage.py as subcommands. It is your tool for executing many Django-specific tasks -- starting a new app within a project, running the development server, running your tests...
It is also an extension point where you can access custom commands you write yourself that are specific to your apps.

Related

How to build sass files with django

I'm completly new with Django and python (and alone as tech in my company, not able to ask help to previous dev). I have to maintain an existing app written in django still developing new services fully written in node, which is my most important task (and my skills). I have a problem that i have fixed some bugs in UX, fixing CSS mostly. And I don't understand how to build sass.
In manage.py, when i ask the list of commands the only things which is related to my problem is "collectstatic" which seems to not build but just collect static files (good naming so) in one folder. And obviously, it doesn't resolve my problem.
Any suggestion ? I'm lost in this big new thing. Many love on every body who can help me. Do you know if there is an integrated tool ? Do i need to use an external compiler which is just not documented ?
Django got nothing to do with compiling assets, you compile it your way in node using your favorite bundler like gulp or webpack and then introduce the final path to django. but people stumbled upon this and created bunch of helper libs, checkout django_webpack.
In case you felt overwhelm then save learning curve time and do like I said earlier, bundle it on your flavor and create a management command in Django that you can run the bundler from python context.

How to automate django deployment?

OK, I am desperate enough to finally post a github question.
SUMMARY:
Django deploy -> digital ocean droplet -> nginx and gunicord + git pull
It works, but manually writing all the commands is way to tedious + error prone. I have been trying to find a suitable tool ever since, and kinda need some advice.
SOO FAR:
I have tried Fabric, BUUUT complexity and simplicity baffles me. Some tutorial are way to trivial, some are way too complex and 95 % of them seems to be outdated(this seems relevant in this case , because syntax has changed drastically)
In addition, the most basic example in docs don't work no matter how many times I have tried to correct it(ssh connection vie password).
P.S. I am completely new to devops, so a lot of things is confusing for me
Beside that, I have tried to dive into some other tools like bash scripting and ansible and dropped them shortly after, mainly due to them not being as alluring as Fabric seems to be.
My question is!
Should I continue tring to solve Fabric, or is there some other commonly used way to make deployment a simple and enjoyable matter while preserving the functionality?
::btw I am windows 10 user put prefer to use git bash, could this be the problem for Fabric(it seemed not being able to recognize ls command and I used DIR instead)
I typically recommend using ansible over fabric unless you are working with *nix. If you have to work with AIX, Solaris, HPUX, fabric can offer you more flexibility since you don't need python on the server. It will take about two-days to get up to speed on ansible, but if you're already using django, jinja2 (the templating language used by anible) should be a snap.

Cloudfoundry- don't have python runtime

this website says cloudfoundry have already supproted python runtimes
but when I type vmc runtimes , it doesn't show python
Does anyone know what's going on?
It would be very appreciated if you can help
thanks.
Note that I haven't done that in a while, and can't remember if I got python support at the time, but: There are different ways to install a custom CloudFoundry, thanks to the automated script called "dev_setup" ( https://github.com/cloudfoundry/vcap/tree/master/dev_setup).
This is what is explained here ( https://github.com/cloudfoundry/vcap) and I suspect this is what you have been following, given your previous comments.
Now, here is the thing: There are different options related to what should be deployed (the "-c" command line switch) so you may want to have a look at https://github.com/cloudfoundry/vcap/tree/master/dev_setup/deployments. In particular, there is a "all" deployment model that brings in the whole kitchen sink, so you can try this and confirm that you get python support. Also, have a look at the custom_runtimes thing in samples, this may be of interest to you.
As stated above, I haven't done this in a while, so I hope I'm on the right track here.

Easier way to setup Django projects?

I've just started using Django and one thing I find that I'm doing is starting a lot of new projects. I'm finding this process to be pretty tedious every time, even using manage.py startproject * I'm constantly changing settings in settings.py like media_root and template paths. Just a little background, I come from PHP and CodeIgniter. I never used a stock CI directory. I modified it to meet my needs for a new project. When I needed a new project, I would just copy that directory. manage.py seems to generate the files on the fly so this approach doesn't seem that possible. Does anyone else have any advice on this?
Lincoln loop has some best practices, they suggest importing settings from a different file. http://lincolnloop.com/django-best-practices/projects/modules/settings.html
Also checkout pip requirements, you might be able to use this to install the settings module from an external source like a git repo.
I'm using Paver to automate my Django project setup.
I have a Bitbucket repository with my own bootstrap setup. Eventually I'll make this generic, but for now it might give you some example code
Sounds like you're starting new projects very often. I assume that's because you're learning. Sure, if there's a custom settings.py that will save you some typing as you generate your learning projects, create it and use it. You could make your template the whole project directory, but since you're unlikely to have a lot of project-level boilerplate outside of settings.py, just focus on that one file. The settings file is the essence of the project.
Django development is all about apps. As you learn more, apps will start to become your focus. My advice would be not to pour too much energy into making an efficient assembly line for project creation.
Also, please learn and use use version control. For bonus points, also learn and use virtualenv :)

Stand alone Django app for OS X

For school, I have made a CMS in django for my major assessment task for Software. My teacher has asked to get the source code and, if applicable, the program compiled.
Now, because i dont want my teacher to install django (Something might go wrong, he may get a different version, missing dependences), how can i package up my django app, plus the django source and make the whole thing runnable (on the development server) by running a single script?
He has python, so that does not need to be included and the target OS would be OS X, but Windows can do as well.
Pip and VirtualENV will make this task much easier. (not sure the support for windows though)
PIP will help with the requirements installation.
http://pypi.python.org/pypi/pip
VirtualENV provides an isolated python environment.
URL: http://pypi.python.org/pypi/virtualenv
Reading through this blog post on installing Pinax will give you a good understanding on how the two work together: http://uswaretech.com/blog/2009/03/create-a-new-social-networking-site-in-few-hours-using-pinax-platform-django/
Perhaps Instant Django will set you in the right direction. It's for windows, but it might be of help.
Without having actually tested it, you should be able to copy the main django directory (/usr/lib/python2.6/site-packages/django for me) over into your project directory, and archive the whole thing. This will continue to keep everything importable (from django import ...), and make it so there's just one archive to extract.
Now, I wouldn't say this is a good way, but it's simple, and I think it'll work. I think.
I belive this is what your looking for (it's not pretty but it gets the job done).
It describes how to package django, a web server, and everything else needed to make a stand alone django application. To make it work for osx you should just be able to substitue py2app (http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html) instead of py2exe and it should (cross your fingers) work, however I have not tested it. Hope this helps!
Ps: sorry for not hyperlinking py2app im a new user and cant post 2 links yet :(