$ rails g model User
belongs_to
has_one
@login_required(redirect_field_name="/") | |
def uploaded_pictures(request): | |
pictures = AdPicture.objects.filter(user=request.user, ad__isnull=True) | |
json_pics = [{'name': pic.picture.name.split("/")[-1], | |
'uuid': pic.uuid, | |
'size': pic.picture.size, | |
'thumbnailUrl': pic.picture.url} for pic in pictures] | |
return JsonResponse(json_pics, safe=False) |
class SimpleGradebook(object): | |
def __init__(self): | |
self.__grades = {} | |
def add_student(self, name): | |
self._grades[name] = [] | |
def report_grade(self, name, score): | |
self._grades[name].append(score) | |
class Person.. | |
public String getName(){ | |
return _name; | |
} | |
public String getTelephoneNumber() { | |
return ("(" + _officeAreaCode + ")" + _officeNumber); | |
} | |
public getOfficeAreaCode(){ |
SQLite3 Cheat Sheet
Download from: http://www.sqlite.org/download.html Getting Started: http://www.sqlite.org/sqlite.html Documentation: http://www.sqlite.org/docs.html
class MyCommonlyUsedModel(models.Model): | |
class Meta: | |
managed = False | |
db_table = 'app_largetable' | |
f1 = models.Field(...) | |
f2 = models.Field(...) | |
# A model that allows the migrations framework to also manage the table | |
# Not sure if this actually works, but would allow for a more DRY approach | |
class MyManagedModel(MyCommonlyUsedModel): |
""" | |
The purpose of this function files is to keep all the helpfull | |
functions constanlly used in a django base project. | |
""" | |
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | |
def paginated_list(request, object_class, list_length, order=None, *args, **kwargs): | |
""" | |
The purpose of this function is to generate the list of all the |
Thanks to [Serafeim Papastefanos] for authoring this tutorial. Please note that the installation process is in flux; most of the steps here should soon be unnecessary.
[Wagtail] is a new Open Source [Django]-based CMS. In this 20 minute tutorial we will see how you can create a blog from scratch using Wagtail. If you want to see some more examples of usage please take a look at the [wagtaildemo] GitHub project.
To follow this tutorial you will need to have [Python] 2.7 installed with a working version of [pip] and [virtualenv].
Installing the wagtail dependencies