https://github.com/iyashwantsaini/django-rest
API using Django Rest Framework
https://github.com/iyashwantsaini/django-rest
api-rest authentication django-rest-framework
Last synced: 3 months ago
JSON representation
API using Django Rest Framework
- Host: GitHub
- URL: https://github.com/iyashwantsaini/django-rest
- Owner: iyashwantsaini
- License: mit
- Created: 2021-02-11T12:08:34.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T11:02:49.000Z (almost 3 years ago)
- Last Synced: 2025-01-16T22:29:50.975Z (5 months ago)
- Topics: api-rest, authentication, django-rest-framework
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DJANGO-REST
Basic REST-API
- Serializers
- Function based views
- Class based views
- Generic Views
- Authentication
- ViewSets
- Generic ViewSets### Superuser
- uname=> user
- passw=> user
- auth-token=> 270801e49bafecbfdaf813f690b7c36a81e5eff7### Basic Auth
- js-fetch()
```
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic dXNlcjp1c2Vy");
var raw = "";var requestOptions = {
method: 'GET',
headers: myHeaders,
body: raw,
redirect: 'follow'
};fetch("http://127.0.0.1:8000/generic/", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
- node-axios
```
var axios = require('axios');
var data = '';var config = {
method: 'get',
url: 'http://127.0.0.1:8000/generic/',
headers: {
'Authorization': 'Basic dXNlcjp1c2Vy'
},
data : data
};axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});```
- python-request
```
import requests
url = "http://127.0.0.1:8000/generic/"
payload={}
headers = {
'Authorization': 'Basic dXNlcjp1c2Vy'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
```### Token-Auth
- js-fetch()
```
myHeaders.append("Authorization", "Token 270801e49bafecbfdaf813f690b7c36a81e5eff7");
```
- node-axios
```
headers: {
'Authorization': 'Token 270801e49bafecbfdaf813f690b7c36a81e5eff7'
},
```
- python-request
```
headers = {
'Authorization': 'Token 270801e49bafecbfdaf813f690b7c36a81e5eff7'
}
```views read: down-up
## License
[](/LICENSE)
By [Yashwant](https://github.com/iyashwantsaini)
## Contributors