Skip to main content
# django-themagicapi

Django application. To launch an api server without endpoint.
Create the database on demand.

We can create multiple databases for different applications.
Just focusing on the client.

According to how we do the JSON query the server.
It will create, alter the table, insert,
list or delete data from an entire database automatically.

Requirements
------------
* Django 1.5+
* django-tokenapi
* valleorm
* django-cors-middleware

Installation
------------

First obtain `themagicapi` package and place it somewhere on your PYTHONPATH, for example
in your project directory (where settings.py is).

Alternatively, if you are
using some sort of virtual environment, like [virtualenv][], you can perform a
regular installation or use [pip][]:

python setup.py install

# or ...

pip install django-themagicapi

[virtualenv]: http://pypi.python.org/pypi/virtualenv
[pip]: http://pip.openplans.org/

Add 'themagicapi', 'tokenapi' and 'corsheaders' to your `INSTALLED_APPS`.

###These are the modifications of settings.py file:
```python
#Add these lines
PATH_DBS = os.path.join(BASE_DIR, "[path-of-databases]/")

MEDIA_ROOT = os.path.join(BASE_DIR, 'docfiles')
MEDIA_URL = '/docfiles/'

INSTALLED_APPS = [
'themagicapi.apps.ThemagicapiConfig',
'corsheaders',
#......
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware'
#......
]

AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'tokenapi.backends.TokenBackend'
#.....
]

CORS_ORIGIN_ALLOW_ALL = True
```

Include `themagicapi.urls` and `tokenapi.urls` in your `urls.py`.
It will look something like this:

urlpatterns = [
url(r'^token/', include('tokenapi.urls')),
url('', include('themagicapi.urls')),

]

Configuration and usage of token
--------------------------------

You can change the number of days that a token is valid for by setting
`TOKEN_TIMEOUT_DAYS` in `settings.py`. The default is `7`.
more information see [django-tokenapi]: https://github.com/jpulgarin/django-tokenapi.git

Usage
-----
### Create new table user if not exists and add new user.
paramsRow = {
'add':{
"db":"valleorm.db",
'user':{
"nombre": "Pepito",
"apellido": "Lopez",
}
}
}

### Modify a user with know ID. Alter table automatically.

paramsRow = {
'add':{
"db":"valleorm.db",
'user':{
'ID': 1,
'apodo': 'donpepito',
'telf': '666666'
}
}
}

### Get all user

paramsRow = {
'get':{
"db":"valleorm.db",
'user':{
}
}
}

### Get by ID

paramsRow = {
'get':{
"db":"valleorm.db",
'user':{
'ID': 1,
}
}
}

### Remove row by ID
paramsRow = {
'rm':{
"db":"valleorm.db",
'user':{
'ID': 1,
}
}
}


For more requests see [themagic-apiserver]: https://github.com/vallemrv/themagic-apiserver.git

Requests example
----------------
```python
import requests
import json
data = json.dumps(***someparams***)
#for get token see https://github.com/jpulgarin/django-tokenapi.git
token = {
'user': 1, #user number
'token': 'some token',
'data': data
}

r = requests.post("http://localhost:8000/", data=token)
print r.json()

```
:scroll: License
----------------

Licensed under the Apache-2.0, see `LICENSE`

:heart_eyes: Contributors
--------------------------

Manuel Rodriguez <valle.mrv@gmail.com>

Metadata

Release files for django-themagicapi 1.0.34

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-themagicapi 1.0.34
File Size Uploaded
django-themagicapi-1.0.34.tar.gz 5.8 kB Details

Release files / django-themagicapi-1.0.34.tar.gz

Download URL django-themagicapi-1.0.34.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c467ad2b62b82a6496a622c4194ea975c945768a9ab1f9d7b8fda88ea4e6ecd1
BLAKE2b-256 checksum
How to use checksums
44bdb6104c6f93dea66a22a4047ad128f9c32032d390040297a8338438582dee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.34 This release

1 release file

1.0.33

1 release file

1.0.3

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page