• Django,  Python

    Django Rest Framework

    https://www.django-rest-framework.org/community/tutorials-and-resources/ This tutorial was used for 50%, the rest is my own demo: https://tests4geeks.com/django-rest-framework-tutorial/ Set up django: mkvirtualenv dapi navigate to your folder, then mkdir dapi cd dapi, setprojectdir . pip install django django-admin startproject api_apps Then you get the folder structure, run it: python manage.py runserver Go to http://localhost:8000/ The install worked successfully! Congratulations! Then run the command: python manage.py migrate Then we can start to create an app python manage.py startapp demo Now we have default project for django Lets make some models, the Bag and Item class, and also add the apps to settings.py “demo.apps.DemoConfig”, then run: python manage.py makemigrations demo If that has no errors then…

    Comments Off on Django Rest Framework
  • Django

    Whiteboard (Django 1-5)

    Python 3.7 installed pip install virtualenv, virtualenvwrapper-win (remove -win for linux) pip freeze: C:\WINDOWS\system32>pip freeze pbr==5.2.1 six==1.12.0 stevedore==1.30.1 virtualenv==16.6.0 virtualenv-clone==0.5.3 virtualenvwrapper-win==1.2.5 mkvirtualenv whiteboard cd and mkdir into app folder, then setprojectdir . (env) pip install django (env) python -m django –version Then we can start the project: django-admin startproject whitebo Then we get the frame of the project so we can start: These files are: The outer mysite/ root directory is just a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like. manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all…

    Comments Off on Whiteboard (Django 1-5)
  • Django,  e-lo,  Github

    Django database API foreign key 102

    https://docs.djangoproject.com/en/2.0/topics/db/queries/   Our models have now changed and a new model has been added to e-lo. In RawText, we store the input, in BlobText we store the functions from TextBlob lib. If we remove the instance from the first table, we also need to remove it from the second. Ref on_delete = models.CASCADE Lets add two instances and view them, then delete them.  

    Comments Off on Django database API foreign key 102
  • Django,  Github,  Sql

    Django database API migrations and models 101

    Django API Once you’ve created your data models, Django automatically gives you a database-abstraction API that lets you create, retrieve, update and delete objects. This document explains how to use this API. Refer to the data model reference for full details of all the various model lookup options. https://docs.djangoproject.com/en/2.0/topics/db/queries/ So our testmodel is a simple Note where we store text from the user. This is our base for e-lo on web. We feed e-lo some text and select a of several NLP functions that will be implemented later (Some of them are implemented, but must interfaced with Django, now they are interfaced with class cmd.Cmd([completekey[, stdin[, stdout]]]).

    Comments Off on Django database API migrations and models 101