MVC and django fundamentals

Question!

Pretty new to this scene and trying to find some documentation to adopt best practices. We're building a fairly large content site which will consist of various media catalogs and I'm trying to find some comparable data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before. Any insight / help would be greatly appreciated!

By : scubabbl


Answers

To understand django fundementals and the django take on MVC, consult the following: http://www.djangobook.com/

As a starting point to getting your hands dirty with ... "...trying to find some comparable data / architectural models"

Here is a quick and dirty way to reverse engineer a database to get a models.py file, which you can then inspect to see how django would handle it.

1.) get an er diagram that closely matches your target. For example something like this http://www.databaseanswers.org/data_models/product_catalogs/index.htm

2.) create an sql script from the er diagram and create the database, I suggest Postgre, as some MySQL table type will not have forgien key constraints, but in a pinch MySQL or SQLITE will do

3.) create and configure a django app to use that database. Then run: python manage.py inspectdb

This will at least give you a models.py file which you can read to see how django attempts to model it.

Note that the inspect command is intended to be a shortcut for dealing with legacy database when developing in django, and as such is not perfect. Be sure to read the following before attempting this: http://docs.djangoproject.com/en/dev/ref/django-admin/#ref-django-admin

By : pcn


Take a look at the Expander sample ControlTemplate at http://msdn.microsoft.com/en-us/library/ms753296.aspx

Expander is a subclass of HeaderedContentControl, it has two "contents": Header and Content

The control template has two ContentPresenter elements, the ContentPresenter that is not bound to the default content property is defined as:

<ContentPresenter ContentSource="Header" />

If you need to use a Button and you don't want to add another property for the second content you can use an attached property and data bind the second ContentPresnter Content property to it.

By : Nir


My use case was only to set the value of a local variable.

Personally I found the try and except style cleaner to read

items = [10, 20]
try: first_item = items[0]
except IndexError: first_item = None
print first_item

than slicing a list.

items = [10, 20]
first_item = (items[:1] or [None, ])[0]
print first_item
By : bkowshik


This video can help you solving your question :)
By: admin