Django installation first time

前端 未结 4 1903
野的像风
野的像风 2020-12-16 04:59

I started learning DJango for the first time. I have some amount of basic knowledge of python but DJango is first for me. I started with the documentation page of django, bu

相关标签:
4条回答
  • 2020-12-16 05:32

    Assuming you're using linux, you should be able to get the Python setuptools from your distribution's repositories. Once installed, type

    sudo easy_install pip    # installs pip
    sudo pip install -U pip  # upgrades pip to most recent version
    

    From there, you can continue to follow the tutorial.

    If you're not using linux, download Python setuptools from PyPI. Python setuptools [PyPI]

    For OS X, the above should still work in the terminal. On windows, you may have to do the above from an elevated command prompt (not sure), but without the sudo command at the beginning.

    0 讨论(0)
  • 2020-12-16 05:37

    The most flexbile way, IMO, of installing w/o old setuptools, is

    1. download virtualenv
      $ curl -O http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.1.2.tar.gz
    2. extract
      tar xzf virtualenv-1.7.1.2.tar.gz
    3. use the version of Python you want to run Django to install virtualenv, for example
      $ python2.7 virtualenv-1.7.1.2/virtualenv.py --distribute ~/env
    4. enter env in which the pip has been already installed
      $ source ~/env/bin/activate
    5. install packages in current env instead of polluting global space or needing sudo
      pip install Django
      Then Django will be installed to path like ~/env/lib/python2.7/site-packages/django.
    6. Or you could
      pip install -e svn+http://code.djangoproject.com/svn/django/trunk
      to install latest trunk code of Django, and the source will be in ~/env/src/django/django. Then you are free to read the source or modify it. Also, you could have full documents by make html in ~/env/src/django/docs

    Things installed by the above method are totally local, you don't need to type sudo or take the risk of messing up paths such as /usr/local/lib, even more, you could then be able to install multiple versions of Django or Python w/o affect each other!

    Furthermore, you could try virtualenvwrapper.

    0 讨论(0)
  • 2020-12-16 05:39

    SQLite is included with Python 2.5+. You should be able to edit your settings.py file with the relevant database settings (database type and filename, see official docs for details), and your database will then be created upon next running syncdb.

    There is a great tutorial on working with virtualenvs and Django at http://bartek.im/blog/2010/07/13/django-environment.html

    I also highly recommend virtualenv-burrito to simplify the installation (and updating) process for virtualenv and virtualenvwrapper: https://github.com/brainsik/virtualenv-burrito

    If you are still facing issues, do you get any errors when running syncdb at present? If so, what are they?

    0 讨论(0)
  • 2020-12-16 05:48

    Do not use sudo with virtualenv this is the easiest way to multiple problems later.

    Begin by installing virtualenv - sudo apt-get install python-virtualenv

    Next, as your normal user run the following commands:

    1. $ virtualenv --no-site-packages django-env
    2. $ source django-env/bin/activate
    3. (django-env)$ pip install django
    4. (django-env)$ django-admin.py startproject myproject
    5. (django-env)$ cd myproject
    6. (django-env)/myproject$ nano settings.py
    7. In settings.py, after 'ENGINE:' type 'django.db.backends.sqlite3', (don't forget the comma)
    8. In settings.py, after the 'NAME:' type 'site.db', (again, don't forget the comma)
    9. Save the file, and exit the editor
    10. (django-env)/myproject$ python manage.py syncdb
    0 讨论(0)
提交回复
热议问题