- Django crud with ajax list part 1
- Django crud with ajax create part 2
- Django crud with ajax update part 3
- Django crud with ajax delete part 4
NOTE:- install django-crispy-forms
# Created by .ignore support plugin (hsz.mobi) | |
### Django-gitignore ultimate template | |
### Django ### | |
*.log | |
*.pot | |
*.pyc | |
__pycache__/ | |
local_settings.py | |
db.sqlite3 | |
db.sqlite3-journal |
from django.contrib import admin | |
from .models import Book | |
admin.site.register(Book) |
{% load static %} | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Bookstore</title> | |
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"> | |
</head> |
{% load crispy_forms_tags %} | |
<form method="post" data-url="{% url 'book_create' %}" class="create-form"> | |
{% csrf_token %} | |
<div class="modal-header"> | |
<h5 class="modal-title" >Create Book</h5> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<div class="modal-body"> |
{% extends 'base.html' %} | |
{% block content %} | |
<h1 class="page-header">Books</h1> | |
<button class="btn btn-primary show-form" data-url="{% url 'book_create' %}"> | |
<span class="glyphicon glyphicon-plus"></span> | |
New Book | |
</button> | |
<table class="table" id="book-table"> | |
<thead> |
{% load crispy_forms_tags %} | |
<form method="post" data-url="{% url 'book_delete' book.id %}" class="delete-form"> | |
{% csrf_token %} | |
<div class="modal-header"> | |
<h5 class="modal-title" >Delete Book</h5> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<div class="modal-body"> |
NOTE:- install django-crispy-forms
from pathlib import Path | |
from typing import Reversible | |
from django.db import models | |
from os import listdir | |
from os.path import isfile, join | |
import os | |
# Create your models here. | |
class insp(models.Model): |
from pathlib import Path | |
from typing import Reversible | |
from django.db import models | |
from os import listdir, path | |
from os.path import isfile, join | |
import os | |
import glob | |
# Create your models here. | |
class insp(models.Model): |
import requests | |
import pprint | |
url='https://' | |
response = request.get(url) | |
pprint.pprint(response.json()) | |