Skip to content

Instantly share code, notes, and snippets.

@malgorath
malgorath / models.py
Created April 26, 2016 15:40
trying to get {{ t.start_stamp }} to display as a date, its saved as a Unix EPOC timestamp
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
from django import forms
from django.forms import ValidationError
class ChangePasswordForm(forms.Form):
username = forms.CharField(
label='Current Username',
widget=forms.TextInput(
attrs={
'size': 40,
@malgorath
malgorath / forms.py
Last active April 22, 2016 14:28
def clean(self): not being called when required is being filled in with random characters
from django import forms
from django.forms import ValidationError
class ChangePasswordForm(forms.Form):
username = forms.CharField(label='Current Username', required=True)
old_pwd = forms.CharField(label='Current Password', required=True)
new_pwd = forms.CharField(label='New Password', required=True)
new_pwd_confirmation = forms.CharField(label='Confirm New Password', required=True)
@malgorath
malgorath / index
Last active April 13, 2016 14:16
Here is the error I am getting on the website
NoMethodError in OpenprojectTodolist::TodolistsController#create
undefined method `id' for #<Class:0x007f918592b1e8>
Extracted source (around line #40):
38
39
40
41
42
43
@malgorath
malgorath / article.rb
Created January 26, 2016 20:45
Can't display parent objects?
class Article < ActiveRecord::Base
belongs_to :user
end
@malgorath
malgorath / blogs_controller.rb
Created January 15, 2016 04:14
Trying to auto update views field +1 everytime the page is shown
def show
@blog.increment :views, 1
@blog.update(blog_params)
end
@malgorath
malgorath / gist:dcbe2763ba9c4afeb833
Created July 29, 2015 21:48
brew install python3 error
brew install python3
==> Downloading https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
Already downloaded: /Library/Caches/Homebrew/python3-3.4.3.tar.xz
==> ./configure --prefix=/usr/local/Cellar/python3/3.4.3_2 --enable-ipv6 --datar
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.4.3_2
import time
ImportError: No module named 'time'
make[2]: *** [Python Launcher.app] Error 1
make[1]: *** [install_PythonLauncher] Error 2
@malgorath
malgorath / CreateArticlesTable.php
Created June 22, 2015 17:57
Articles Migration File for Laravel 5.1
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateArticlesTable extends Migration
{
/**
* Run the migrations.
*
@malgorath
malgorath / form.html
Last active August 29, 2015 14:20
How to include a form.html in any other type of .html file in DJANGO
<form action="/form/submit" method="POST">
<strong>I.Q.:</strong>
<input type="text" name="IQ" />
<input type="submit" value="Send My IQ" />
</form>
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from ckeditor.widgets import CKEditorWidget