Skip to content

Instantly share code, notes, and snippets.

View sanjaykrishnan's full-sized avatar

sanjay krishnan sanjaykrishnan

  • Sayone Technologies
  • Kerala
View GitHub Profile
@sanjaykrishnan
sanjaykrishnan / node_install.txt
Created April 7, 2023 08:13
NPM latest install
curl -sL https://deb.nodesource.com/setup_19.x | sudo -E bash -
sudo apt-get install -y nodejs
Run this command when time is not update with elastic search and it shows this error TransportError(403, u'{"message":"Signature expired:
sudo ntpdate ntp.ubuntu.com
@sanjaykrishnan
sanjaykrishnan / models.py
Created June 8, 2021 06:07 — forked from niktto/models.py
Using Django Rest Framework to ease csv generation
from django.db import models
class SomeModel(models.Model):
email = models.EmailField()
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
@sanjaykrishnan
sanjaykrishnan / scp_command
Created May 21, 2021 10:50
Command to copy file from a different server
scp ubuntu@<ip_address>:<path_of_file> /home/sanjay/Desktop/
@sanjaykrishnan
sanjaykrishnan / index.html
Created May 18, 2020 07:31
Modal Form for django
<button type="button" class="btn btn-success js-create-supplier" data-url="{% url 'supplier:modal-create' %}">
<span class="glyphicon glyphicon-plus"></span>
New Supplier
</button>
<div class="modal fade" id="modal-popup" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
qs = ProductCategory.objects.all()
slug_list = [item['slug'] for item in cat_list if item['slug'] in qs_slugs]
preserved = Case(*[When(slug=slug, then=pos) for pos, slug in enumerate(slug_list)])
qs= qs.order_by(preserved)
@sanjaykrishnan
sanjaykrishnan / checkbox_m2m.html
Created April 6, 2020 05:20
Implementing checkbox for many to many fields
{% for widget in form.field_name %}
<tr>
<th>
<label for="{{widget.id_for_label}}">
<input type="{{widget.data['type']}}" name="{{widget.data['name']}}" value="{{widget.data['value']}}" {% if widget.data['selected'] %}selected{% endif %} {% for k, v in widget.data['attrs'].items() %} {{k}}="{{v}}" {% endfor %}>
</label>
</th>
<td>
{{widget.choice_label}}
</td>