Skip to main content

Tutorial 1 - How to Use uuid in Django

uuid is used when you need unique values from a model e.q (twitter with their status id)

in the models.py
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
#if you dont want to use the uuid as the model id   use 
#unique_id = models.UUIDField(default=uuid.uuid4, editable = False,unique=True)

in urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
    url(r'^status/$', views.status, name='status'),
]

and from views.py
from django.shortcuts import render
def status(request, uuid):
    status = get_object_or_404(id=uuid)
    return render(request, 'core/status.html', {'status': status})

Comments

Popular posts from this blog

How To Install Qt5.* AND QtCreator On UBUNTU 16.04

This tutorial was done with the following software versions: Ubuntu 16.04 LTS Qt Creator 3.5.1 Qt 5.5.1 Install Qt sudo apt-get install build-essential sudo apt-get install qt5-default   sudo apt-get install qtcreator Install documentation and examples If Qt Creator is installed thanks to the Ubuntu Software Center or thanks to the synaptic package manager, documentation for Qt Creator is not installed. Hitting the F1 key will show you the following message : "No documentation available". This can easily be solved by installing the Qt documentation: sudo apt-get install qt5-doc And eventually: sudo apt-get install qt5-doc-html qtbase5-doc-html If you the examples are also missing: sudo apt-get install qtbase5-examples Restart Qt Creator to make the documentation available.

QT Projects and Libraries for The C++ Programmer

Here i will gather the best and most interesting Qt/C++  projects and libraries  for your perusal https://github.com/biluna/biluna    Biluna is a Qt application framework. It started with the idea to make an Eclipse like (Java) framework. The framework allows the developer to start with a ready to use desktop application. The additional functionality is added by using plug-ins. The basic framework provides a MDI (multiple document interface) window work area with docking windows at the different sides of the working area.   https://github.com/openhomm/openhomm                                                        OpenHoMM is open source clone of 'Heroes Of Might And Magic III Shadow Of Death' game engine. Requirments: original game data Qt >= 5.5.1   https://github.com/shadowsocks/libQtShadow...