Friday, July 20, 2012

Cross-App model calling in Django

Let's assume we have two apps in our Django's Root directory. Something like this:

Now, you want to connect the models in profiles and courses together. For instance you have a Course model in course-app and a Student model in profiles-app.
The way you can design, will be something like this:

class Student(models):
    first_name = .....
    last_name = .... 
    course = models.ManyToManyField("courses.Course" , null = True , blank = True , related_name = "student")

class Course(models.Model):
    name = ....
    date = .... 

Attention to "courses.Course" !! The pattern is : [app_name.model_name] . Do NOT use [app_name.models.model_name], or you will get some sort of nasty errors..     
That's it ..

Saturday, July 14, 2012

The MAIN difference between Hackers and Academicians

For The Record:

I'm going to tell you about the MAIN difference between these two cults, after almost 10 years of being around both communities ..

Hackers learn things when they NEED to, Academicians learn them in advance, so "maybe" they need those stuff later.
So folks .. If you are following the Zen of Hack, don't be disappointed if you see some Academic addicts try to impress you by advanced algorithms,etc.
Just relax, ask them for some tutorials and references, and ACE them ...