• Complain

Nigel George [Nigel George] - Mastering Django: Core

Here you can read online Nigel George [Nigel George] - Mastering Django: Core full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2016, publisher: Packt Publishing, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Nigel George [Nigel George] Mastering Django: Core

Mastering Django: Core: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Mastering Django: Core" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Delivers absolutely everything you will ever need to know to become a master Django programmer

About This Book

  • Gain a complete understanding of Djangothe most popular, Python-based web framework in the world
  • Gain the skills to successfully designing, developing, and deploying your app
  • This book is packaged with fully described code so you can learn the fundamentals and the advanced topics to get a complete understanding of all of Djangos core functions

Who This Book Is For

This book assumes you have a basic understanding of the Internet and programming. Experience with Python or Django would be an advantage, but is not necessary. It is ideal for beginner to intermediate programmers looking for a fast, secure, scalable, and maintainable alternative web development platform to those based on PHP, Java, and dotNET.

What You Will Learn

  • Use Django to access user-submitted form data, validate it, and work with it
  • Get to know advanced URLconf tips and tricks
  • Extend Djangos template system with custom code
  • Define models and use the database API to create, retrieve, update, and delete records
  • Fully extend and customize the default implementation as per your projects needs
  • Test and deploy your Django application
  • Get to know more about Djangos session, cache Framework, and middleware

In Detail

Mastering Django: Core is a completely revised and updated version of the original Django Book, written by Adrian Holovaty and Jacob Kaplan-Moss - the creators of Django.

The main goal of this book is to make you a Django expert. By reading this book, youll learn the skills needed to develop powerful websites quickly, with code that is clean and easy to maintain.

This book is also a programmers manual that provides complete coverage of the current Long Term Support (LTS) version of Django. For developers creating applications for commercial and business critical deployments, Mastering Django: Core provides a complete, up-to-date resource for Django 1.8LTS with a stable code-base, security fixes and support out to 2018.

Style and approach

This comprehensive step-by-step practical guide offers a thorough understanding of all the web development concepts related to Django. In addition to explaining the features of Django, this book provides real-world experience on how these features fit together to build extraordinary apps.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Nigel George [Nigel George]: author's other books


Who wrote Mastering Django: Core? Find out the surname, the name of the author of the book and a list of all author's works by series.

Mastering Django: Core — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Mastering Django: Core" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Appendix A. Model Definition Reference

, Models , explains the basics of defining models, and we use them throughout the rest of the book. There is, however, a huge range of model options available not covered elsewhere. This appendix explains each possible model definition option.

Fields

The most important part of a model-and the only required part of a model-is the list of database fields it defines.

Field name restrictions

Django places only two restrictions on model field names:

  1. A field name cannot be a Python reserved word, because that would result in a Python syntax error. For example: class Example(models.Model): pass = models.IntegerField() # 'pass' is a reserved word!
  2. A field name cannot contain more than one underscore in a row, due to the way Django's query lookup syntax works. For example:
class Example(models.Model): # 'foo__bar' has two underscores! foo__bar = models.IntegerField()

Each field in your model should be an instance of the appropriate Field class. Django uses the field class types to determine a few things:

  • The database column type (for example, INTEGER, VARCHAR)
  • The widget to use in Django's forms and admin site, if you care to use it (for example, ,
Universal field options

Table A.2 lists all the optional field arguments in Django. They are available to all field types.

Option

Description

null

If True, Django will store empty values as NULL in the database. Default is False. Avoid using null on string-based fields such as CharField and TextField because empty string values will always be stored as empty strings, not as NULL. For both string-based and non-string-based fields, you will also need to set blank=True if you wish to permit empty values in forms. If you want to accept null values with BooleanField, use NullBooleanField instead.

blank

If True, the field is allowed to be blank. Default is False. Note that this is different than null. null is purely database-related, whereas blank is validation-related.

choices

An iterable (for example, a list or tuple) consisting itself of iterables of exactly two items (for example, [(A, B), (A, B) ...]) to use as choices for this field. If this is given, the default form widget will be a select box with these choices instead of the standard text field. The first element in each tuple is the actual value to be set on the model, and the second element is the human-readable name.

db_column

The name of the database column to use for this field. If this isn't given, Django will use the field's name.

db_index

If True, a database index will be created for this field.

db_tablespace

The name of the database tablespace to use for this field's index, if this field is indexed. The default is the project's DEFAULT_INDEX_TABLESPACE setting, if set, or the db_tablespace of the model, if any. If the backend doesn't support tablespaces for indexes, this option is ignored.

default

The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created. The default cannot be a mutable object (model instance, list, set, and others.), as a reference to the same instance of that object would be used as the default value in all new model instances.

editable

If False, the field will not be displayed in the admin or any other ModelForm. They are also skipped during model validation. Default is True.

error_messages

The error_messages argument lets you override the default messages that the field will raise. Pass in a dictionary with keys matching the error messages you want to override. Error message keys include null, blank, invalid, invalid_choice, unique, and unique_for_date.

help_text

Extra help text to be displayed with the form widget. It's useful for documentation even if your field isn't used on a form. Note that this value is not HTML-escaped in automatically-generated forms. This lets you include HTML in help_text if you so desire.

primary_key

If True, this field is the primary key for the model. If you don't specify primary_key=True for any field in your model, Django will automatically add an AutoField to hold the primary key, so you don't need to set primary_key=True on any of your fields unless you want to override the default primary-key behavior. The primary key field is read-only.

unique

If True, this field must be unique throughout the table. This is enforced at the database level and by model validation. This option is valid on all field types except ManyToManyField, OneToOneField, and FileField.

unique_for_date

Set this to the name of a DateField or DateTimeField to require that this field be unique for the value of the date field. For example, if you have a field title that has unique_for_date="pub_date", then Django wouldn't allow the entry of two records with the same title and pub_date. This is enforced by Model.validate_unique() during model validation but not at the database level.

unique_for_month

Like unique_for_date, but requires the field to be unique with respect to the month.

unique_for_year

Like unique_for_date, but requires the field to be unique with respect to the year.

verbose_name

A human-readable name for the field. If the verbose name isn't given, Django will automatically create it using the field's attribute name, converting underscores to spaces.

validators

A list of validators to run for this field.

Table A.2: Django universal field options

Field attribute reference

Every Field instance contains several attributes that allow introspecting its behavior. Use these attributes instead of isinstance checks when you need to write code that depends on a field's functionality. These attributes can be used together with the Model._meta API to narrow down a search for specific field types. Custom model fields should implement these flags.

Attributes for fields
Field.auto_created

Boolean flag that indicates if the field was automatically created, such as the OneToOneField used by model inheritance.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Mastering Django: Core»

Look at similar books to Mastering Django: Core. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Mastering Django: Core»

Discussion, reviews of the book Mastering Django: Core and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.