• Find
    Great Courses
  • Create
    a Course
  • About
  • Blog
  • Help
  • Login
  • Home
  • › Learn › Introduction to Django study group
course image

Participate


Learning the Django, web framework for Python

Looking to create rich web applications with Python? Python has an excellent web framework called Django that has an passionate and active community behind it. It is production ready and takes care of a lot of the basic demands of a web application such as authentication, templating, and a pythonic interface for databases. 

View Full Description
  • School of Webcraft

    WEBCRAFT

  • Runs June 20, 2011 to Aug. 31, 2011
  • Kind
    Study Group
  • Signup
    Non-moderated signup
  • Chat
    #p2pu-56-introducti
  • Updates
    281
  • Organizers
    1
  • Participants
    100
  • Followers
    134
See All »

People


Alex Kehayias (organizer) EmperiuM (participant) Oscar (participant) europablue (participant) DipakSaraf (participant) fusionstrings (participant) smogg (participant) andres (participant) Ankur (participant) Pein Junior (participant) Jessica Ledbetter (participant) Jen (participant) Yarix (participant) Marcelo  Garcia (participant) Gregory Pekynov Bustamante (participant) Agni (participant) M Bayaa (participant) Manju (participant) tallandroid (participant) J_R (participant) Giovanny (participant) Antonio Sandoval (participant) casals (participant) Francis Wagner (participant) Zeno Rocha (participant) Stheven Briceño (participant) Johnny McKenzie (participant) fabpot (participant) Paul Booker (participant) Serg Vergara (participant) Trent (participant) Chen Liang (participant) andrelashley (participant) Kim (participant) koko (participant) aple (participant) dotcomboy (participant) Capi Etheriel (participant) MateuszK (participant) mcarrano (participant) Raja Nakka (participant) Jake (participant) Roger Martinez (participant) Osledy Bazo (participant) Magdalena (participant) nyx (participant) Pablo V (participant) Babis Marapidis (participant) Tommy (participant) Milan (participant) Faruque Sarker (participant) David Gonzalez Shannon (participant) Sandeep (participant) malpaso (participant) Enzo Luis Strongoli (participant) Luis Sierra (participant) stardiviner (participant) muki (participant) Seun Sanni (participant) Anirudh (participant) Robert Rivera (participant) Yanzay (participant) Jeff (participant) wilmer (participant)

Tasks


  • Prerequisites and Installation
  • Suggestions for class project
  • Describing Web Application Systems
  • Entity relationships and modeling our database
  • Modeling our database
  • Syncing our database and trying out the built in admin
  • URL Routing and Creating our first view
  • List views, detail views, and a look at django templates

External Links


  • Syllabus
  • Django Project
    Anonym
    Anonym at Introduction to Django
    posted message: For example sake, let say we have two models a Project and Student model. The Project model has two fields(name and num_of_students) and the Student model has two fields(name and project) but the project field of the Student model is a ForeignKey(Project). Know I know to fill out data to the project model, I will write something like: >> p = Project(name='Django', num_of_students=1) >>p.save() But for the Student field I am confused on how to fill any data I got a solution from the Django online documentation which was about a Blog scenario but I am confused on how to implement the solution. Can any one maybe try to fill out any sort of data for the Student model so I can see how it is done so I can understand this part. Thanks
    09 Aug 2011 via courses.p2pu.org
    1 Comment

    Comments


  • Jessica Ledbetter   Aug. 14, 2011, 10:48 a.m.

    Here's how I did it:

    class Student(models.Model):
        name = models.CharField(max_length=50)
        project = models.ManyToManyField(Course)
    
    

    My models are a little different because I started to code up a solution when you first sent me a message. But hopefully it makes sense.

    In shell:

     

    >>> from courses.models import Course
    >>> from accounts.models import Student
    >>> course = Course(name='Django', num_of_students=2)
    >>> course.save()
    >>> student = Student(name='Carla')
    >>> student.project.add(course)
    
    

    then you can save.

    If you try to add a course or project before saving the student first, you'll get

    	ValueError: 'Student' instance needs to have a primary key value before a many-to-many relationship can be used.
    

    Because the student to project/course relationship (models.ManyToManyField) can't be created without the keys.

    For more information on relationships: https://docs.djangoproject.com/en/dev/ref/models/relations/

     

    I realize it was just a simple testing exercise but you probably don't really want to store the number of students right that. Probably a count of the number of objects in the relationship would be better? So you could have -- and I think this was in your original message -- on project 'students' that are manytomany to your student model. Then for your view or such, you can show a count of all the students in that course.


P2PU Schools:
School of Social Innovation

SOCIAL INNOVATION

School of the Mathematical Future

MATHEMATICAL FUTURE

School of Webcraft

WEBCRAFT

School of Ed

SCHOOL OF EDUCATION

School of Open

SCHOOL OF OPEN

What is P2PU?

The Peer 2 Peer University is a grassroots open education project that organizes learning outside of institutional walls and gives learners recognition for their achievements. P2PU creates a model for lifelong learning alongside traditional formal higher education. Leveraging the internet and educational materials openly available online, P2PU enables high-quality low-cost education opportunities.

Connect With Us


  • FacebookF

  • TwitterT

  • Get Involved

  • Blog

  • Send us an email

Some of Our Supporters

William and Flora Hewlett Foundation Shuttleworth Foundation View all of our supporters

globe icon
  • English
  • Nederlands
  • 中文
  • Español
  • Svenska
  • עברית
  • 한국의
  • (more)
  • Help
  • About P2PU
  • Forum
  • Found a Bug?
  • Creative Commons
  • Share-Alike
  • Privacy Guidelines
  • Terms of Use
CC Icons