This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PersonBase(models.Model): | |
| name = models.Charfield() | |
| address = models.Charfield() | |
| class Meta: | |
| abstract = True | |
| class Employee(PersonBase): | |
| emp_id = models.CharField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class Author(models.Model): | |
| name = models.CharField(max_length=100) | |
| class Book(models.Model): | |
| author = models.ForeignKey(Author) | |
| title = models.CharField(max_length=100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| from django.forms.models import inlineformset_factory | |
| from .models import Author, Book | |
| class AuthorForm(forms.ModelForm): | |
| class Meta: | |
| model = Author | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.views.generic import CreateView | |
| from django.shortcuts import redirect | |
| from .models import Author | |
| from .forms import AuthorForm, BookFormSet | |
| class AddAuthorView(CreateView): | |
| template_name = 'create_author.html' | |
| form_class = AuthorForm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/html" id="book-template"> | |
| <div id="book-<%= id %>"> | |
| <label for="id_books-<%= id %>-title">Book Title:</label> | |
| <input id="id_books-<%= id %>-title" type="text" name="books-<%= id %>-title" maxlength="100"> | |
| <input type="hidden" name="books-<%= id %>-author" id="id_books-<%= id %>-author"> | |
| <input type="hidden" name="books-<%= id %>-id" id="id_books-<%= id %>-id"> | |
| </div> | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('.add-book').click(function(ev){ | |
| ev.preventDefault(); | |
| var count = $('.books').children().length; | |
| var tmplMarkup = $('#book-template').html(); | |
| var compiledTmpl = _.template(tmplMarkup, { id : count }); | |
| $('div.books').append(compiledTmpl); | |
| // update form count | |
| $('#id_books-TOTAL_FORMS').attr('value', count+1); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Something along these lines: | |
| class SiteTemplate | |
| name - Business user "friendly" name | |
| path - The path to the actual template | |
| type - ('style', 'boutique') | |
| class SiteTemplateContext | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ERT WERS THE BERST ERF TERMAHS, ERT WERS THE WERST ERF TERMAHS, ERT WERS THE ERGE ERF WERSDERM, ERT WERS THE ERGE ERF FERLERSHNERSS, ERT WERS THE ERPERCH ERF BERLERF, ERT WERS THE ERPERCH ERF ERNCRERDERLERTER, ERT WERS THE SERSERN ERF LERGHT, ERT WERS THE SERSERN ERF DERKNERSS, ERT WERS THE SPRERNG ERF HERPER, ERT WERS THE WERNTER ERF DERSPER, WE HERD ERVERERTHERNG BERFERE ERS, WE HERD NERTHERNG BERFERE ERS, WE WERE ERLL GERNG DERERCT TO HERVERN, WE WERE ERLL GERNG DERERCT THE ERTHER WE - ERN SHERT, THE PERERD WERS SO FER LERKE THE PRERSERNT PERERD, THERT SERME ERF ERTS NERSERST ERTHERERTERS ERNSERSTERD ERN ERTS BERNG RERCERVERD, FER GERD ER FER ERVERL, ERN THE SERPERLERTERVE DERGRE ERF CERMPERERSERN ERNLER. |