Skip to content

Instantly share code, notes, and snippets.

View sam-thecoder's full-sized avatar

Samuel M. sam-thecoder

View GitHub Profile
$(function() {
function get_response() {
var value = $('.text').val();
if (value.length > 0) {
$('.no-message').addClass('hidden');
$('.text').val('');
var html_string = `<div class="card col-md-6 user-message"><div class="card-body">${value}</div></div>`;
{% extends 'base.html' %}
{% block js %}
<script type="text/javascript" src="/static/js/script.js"></script>
{% endblock %}
{% block content %}
<div id="app" class="container top-padding">
<div class="row">
<div class="col-md-12 messages">
#inside template tag called app_tags.py
@register.filter
def image_dimensions(dimensions, ratio):
print(dimensions)
width, height = dimensions
if 'x' in ratio:
return ratio
x,y = ratio.split(":")
x,y = int(x),int(y)
ratio = x/y
@sam-thecoder
sam-thecoder / company_model.py
Created December 28, 2019 13:46
company model
from django.db import models
from django.contrib.auth.models import User
from location.models import Address
class Company(models.Model):
name = models.CharField(max_length=500)
phone = models.CharField(max_length=500)
email = models.EmailField(unique=True)
address = models.ForeignKey(Address, related_name="companies", on_delete=models.CASCADE, null=True)
@sam-thecoder
sam-thecoder / company.py
Created December 28, 2019 14:01
Company data
from django.shortcuts import render
from company.models import Company
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.db.models import Q
from django.core.paginator import Paginator
import json