Optional Date Fields in Django

Posted by Trey on December 27, 2006

Adding blank=True on any field in your models.py file will keep the admin interface from requiring that field. That’s all you need to do if it’s a string field. If it’s an integer, boolean, or a date; you need to add null=True to the field as well.

date = models.DateField(blank=True, null=True)

Source

Django model reference

See also

When to use and when not to use NOT NULL in MySQL / Rails Migrations

Pluralization of Database Models in Django

Posted by Trey on December 26, 2006

Part of the “magic-removal” was apparently removing automatic pluralization. That’s a shame. That’s one thing I really dig about Rails.

In your models.py file:

class Meta:
    verbose_name_plural = 'something'

So for a ‘Person’ model, you could put ‘people’. Now it will look right in the admin interface.

Creating a Web Archive of a Writeboard in Yojimbo

Posted by Trey on December 26, 2006

  1. Share the Writeboard with yourself
  2. Get the password out of the email you receive
  3. Archive the item in Yojimbo
  4. In the password prompt inside of the archive in Yojimbo, put the password from the email
  5. Submit the form
  6. Delete the web archive
  7. Archive the Writeboard again

How to set up Photoshop for Web

Posted by Trey on December 17, 2006

  • View > Proof Setup > Monitor RGB
  • Edit > Color Settings (or shift-cmd-K)
    • Change RGB working space to Monitor RGB - Color LCD
    • Set color management to off for RGB

Anything else? Anything different in CS3 beta? Anybody with differing opinions?

Update 2007-12-01: Just for the record, here’s the extra thing you have to do for CS3:

Convert to sRGB

Un-check the option to Convert to sRGB in the Save for Web & Devices dialog.

Using SQLite in memory mode for Rails testing

Posted by Trey on December 11, 2006

Watching the latest PeepCode at about the 15:00 mark, he mentions using SQLite in memory mode for your testing database. Here’s what you put in your config/database.yml:

test:
  adapter: sqlite3
  database: ":memory:"
  verbosity: silent

Run these commands:

$ script/plugin install memory_test_fix (use `--force` if you have any problems)
$ rake db:migrate
$ rake

Then you’re ready to go.

Sources:

See also how to set up SQLite for Rails

Delete photos inside an album in iPhoto

Posted by Trey on December 06, 2006

If you want to move photos to the trash that are inside of an album (smart or otherwise), you can’t just drag them to the trash icon (?!). You have to hit cmd-option-delete.

Now you know.

Rails Migration Data Types

Posted by Trey on December 04, 2006

Is this all of them?

:integer
:float
:datetime
:date
:timestamp
:time
:text
:string
:binary
:boolean

Found this:

Valid column types are integer, float, datetime, date, timestamp, time, text, string, binary, and boolean. Valid column options are limit, null (i.e. ” :null => false” implies NOT NULL), and default (to specify default values).

Why is this hard to find? Google search for “rails migration data types” isn’t that good.

And what’s the difference between datetime and timestamp? Or binary and boolean? Any database gurus read this?

Sources