Tuesday, May 6, 2014

Python 3 Django 1.7 on Ubuntu 14.04 - Day 1

It's time to dive into learning Django.  I've been waiting until I could use Django with Python 3, and that time has now come. I'll be working on Ubuntu 14.04.  There is no python3-django package yet, so I'll give pip a try.  I also want to start with Django 1.7, so that I can learn the new built-in migrations instead of using South to update the data model.

Here is what I did to get started:
  • $ sudo aptitude install python3-pip
  • $ pip3 install --user https://www.djangoproject.com/download/1.7b3/tarball/
This created .local/lib/python3.4/site-packages and .local/bin directories in my $HOME and installed the Django egg in the .local site-packages directory and django-admin and django-admin.py in the .local/bin directory (see PEP 370).

Next I did:
  • $ python3
  • >>> import django
  • >>> print(django.get_version())
When the last statement returned 1.7b3 I knew I was in business. Trying to run django-admin, I realized that .local/bin was not in my PATH, so I added the following to the bottom of my .bashrc file:

PATH=$HOME/.local/bin:$PATH

export PATH

I also added the following to my .bash_aliases:

alias python='python3'

since Python 3 is what I use all the time now.

Starting a Django Project 

  • $ django-admin startproject checkitout
  • $ cd checkitout 
  • $ python3 manage.py runserver 0.0.0.0:8080
Running this last step created a db.sqlite3 file in the checkitout directory - something new in Django 1.7 I believe.

At this point I created a bzr repository of this so that each step in the process from here on out can be easily rewound.  Each of these commands were run inside the top level checkitout directory:
  • bzr init
  • bzr add *
  • bzr ci -m "initial commit"
Next I setup a project on launchpad: https://launchpad.net/checkitout, and pushed up the initial commit:
  • bzr push lp:~jelkner/checkitout/trunk

Next Steps

  • $ django-admin startapp cioapp
  • edit cioapp/models.py
  • bzr add *
  • bzr ci -m "added app and first models"
  • bzr push lp:checkitout
  • edit checkitout/settings.py and added cioapp to INSTALLED_APPS
  • edit cioapp/admin.py and import and register models
  •  python3 manage.py migrate
This created the database tables and setup a superuser. I started the server again with:
  •  $ python3 manage.py runserver 0.0.0.0:8080
pointed my browser at localhost:8080/admin and was able to login and see the tables. This brought me back to the point where my Django tutor, Chris Hedrick, left me off this afternoon, only now I've got Django 1.7 instead of the 1.6 we used earlier and I ran migrate instead of the syncdb from South. I'll finish by checking these last changes in, but I wonder what needs to get ignored by bzr to keep the database superuser info from being part of the repo? I'll have to start by asking Chris that tomorrow. A fine and productive day!

26 comments:

  1. People use this software to get perfect results as there are many software but they are useful. people always wants software with good features. All Software Download

    ReplyDelete
  2. With the help of this software my language conversion problem can be solved easily. Thank you for the posting. www.ddlforall.blogspot.com

    ReplyDelete
  3. I just wanted to let you know that your blog is brilliant! Thank you for putting all this effort into writing such rich, informative posts.
    Movers In Dubai
    International Movers

    ReplyDelete
  4. I really appreciate the efforts you put into reviewing these useful resources.

    --------------------------
    Also checkout our New Year 2017 Greetings new collections.

    ReplyDelete
  5. I'm debating between learning Ruby or Python for web development. But I'm leaning more towards Python and Django. Which version of Python should I get at the moment? I've heard that 3.3 is the new version and the more superior version. But people have also said that 2.7 have more assignment writing services libraries to use.

    ReplyDelete
  6. Decided exclusively by perusers' fill-in-the-clear reactions, the honors you'll discover on these pages name the merchants that give the best innovation in classes from programming and frameworks to instrumentation and last control components. Write my Assignment for me

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Aw, this was an amazingly pleasant post. Finding the time and real push to make a decent article however what would i be able to state I put things off a ton and never figure out how to complete anything. Research Paper Writers

    ReplyDelete
  9. People use this software to get perfect results Bakery Equipment

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Ultimate article post in this blog. Thanks for sharing to us. It can help a lot to improve our knowledge
    Gone are the days when a business laid down an annual sum to have its information listed in the Yellow Pages. These days it’s crucial for all businesses to instead prominently list themselves in online directories.AIR pros is a directory of service companies in your area with a geolocation system, automatic translation of the content.The site is optimized to facilitate the referencing of referenced companies.You can search for companies by department or city and look at their profile before contacting them.

    ReplyDelete
  12. This post is not just informative but impressive also. The post is so convincing that it created an urge to choose Dissertation Writing Services. You can email us at info@ukdissertationhelp.co.uk or Phone Number: 020 8144 9988.

    ReplyDelete
  13. In recent times it’s vital for all businesses to rather prominently list themselves in online directories. Long gone are the times when a business laid down an annual sum to have its facts indexed in the phone book. The Dissertation Proposal Writing Help website is optimized to facilitate the referencing of referenced businesses.

    ReplyDelete
  14. Web developing is one of the best skill and for this purpose, people learn different topics about web developing. Python is a programming language and it is very difficult. Assignment writing services.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. I recommend all individuals choose Assignment Help the USA for the best rule in your academic. The ideal and master aide your prerequisite and learning task venture by the college and university.

    ReplyDelete
  17. Downloading contents from the Internet is no longer a new thing Ummy Video Downloader Crack yet you still need to invest some time until you find the app that is most suited for your needs. ummy video Downloader Crack Latest

    ReplyDelete
  18. Great post, i appreciate your work.


    As an established Technology-Intensive company, We pride ourselves on providing cutting-edge state-of-the-art software solutions for business needs that help them perform better and produce more effectively and efficiently.

    Zoho Remotely

    ReplyDelete
  19. Our Cardiac Nursing Online Assignment assistance experts have obtained a higher Degree and are experienced medical professionals who can aid students with writing assignments on these and other subjects. Cardiac Nursing Assignment Help creates assignments by completing extensive study and applying effective strategies. Cardiac Nursing Assignment Help

    ReplyDelete
  20. Complicated subjects, strict submission deadlines, stringent writing instructions and rigorous evaluation criteria in nursing colleges make it difficult for students to write a paper that scores high and impresses professors. Since our main objective is to eliminate all the assignment related issues of the students, we provide them with the best online nursing assignment help Australia so that they can fulfill their dream of scoring high grades in their college papers. our assignment experts work at their full strength to help students succeed in academic assignment writing tasks.

    ReplyDelete
  21. You have shared good information, it's a really amazing post. I am sharing this post on my page geometric prescription glasses online and following your link.

    ReplyDelete
  22. This informative post has provided me with a wealth of knowledge on a topic that was previously unfamiliar to me. I found the section on Do My Homework particularly enlightening. Thank you for sharing your expertise, and keep up the great work!

    ReplyDelete