Ifyoucanreadthisyouspendentirelytoomuchtimeanalyzingtags

If you create a model class in Django and then create a model subclass of that, then Django creates a 1:1 relationship to a table with the extra fields defined in the subclass. This results in there being an instance of the parent class as well as an “extended version” of that object in the subclass. That works out rather well for most cases, but there’s a few edge cases where it’s not sufficient.

Say I have an object A and a subclass B:


class A(Model): created = DateTimeField(auto_now_add=True)

class B(Model): modified = DateTimeField(auto_now=True)

I’ll wind up with some tables like this:

A

id created
1 14535143
2 14536222

B

id modified a_ptr_id
1 34253245 1

What this means is that if I instantiate PK 1 via A’s manager, I’ll get an A and only ever an A because the information about what kind of object it is exists only in B’s table. So if I have, say, a blog engine like Tumblr where there are text, image, video, audio, and other kinds of posts and I’ve made them all model classes based off RootBlog, I can’t do a lookup by PK and expect the right object; I’ll always get a RootBlog object.

Traditionally, if you had this problem, you’d use abstract classes and just have a different object series for each kind of post. That works, but it means you can’t do shortcuts that just pass around an ID and get the right object — you have to pass around the type as well.

However, there is one trick that’s a result of the 1:1 relationship that could be of some assistance here. When you create an instance of our example object A, it will have a property called ‘b’ that is a link to its corresponding full instance of B. The problem is that we can’t easily follow this without giving the ancestor direct knowledge of all its descendants’ names.

Read the rest »

  • Never leave the machine plugged in all the time. Laptops are meant to be portable. Using it as a desktop that never runs on the battery will destroy your battery life.
  • Cycles are your friend. Never letting the battery complete a cycle will greatly diminish your run-time. Try to avoid charging the battery unless it’s drained past 30%. Any time the battery drains past 50% and charges more than 50% counts as a cycle. The farther you let it drain before the charge – the better its overall health will remain.
  • 30 cycles in a year is not a good thing. Eye
  • Let the battery drain completely a few times a week.
  • Never let it sit for long periods of time without use. Batteries need to be loved or else they won’t love you.


10.6 falsely reports ‘service battery?’ ... I think not

And if you follow those “tips” you’ll have a very healthy NiCad battery and a dead LiIon battery. What is this tool thinking? Has he never looked into this at all?

CYCLES ARE BAD.

Leave the unit plugged in, don’t discharge if possible, and charge as soon as you can when you get near power.

Even Apple says this, so why is this ‘tard being an smug idiot?

One more reason not to trust “community” tips.

I watched the president’s speech on education just now. Fantastic speech, very uplifting, and totally devoid of political context.

Can we now agree that Glen Beck is a frigtard that’s just striking up fear and loathing with a soothing tone?

Anyway, I did watch it via the FB Live stream so I could see the stream of idiots’ comments flowing on the side as I watched. It was … enlightening. Here’re some golden ones:

Curtis Dale Johnson this a bunch of horse crap why would we won our children to listen to this its taking our children learning time???????? why.
10:53am – Denver, CO

I … yes. Exactly. Thank you.

Michelle Thornton They told me to pull my kid out of school to watch at home if I wanted my kid to see it!
10:56am
Mandi Foust Wofford is keeping her son home today so he can watch with me…we live in Texas…
10:57am – Dallas / Fort Worth, TX
Kelly Caplinger Silvers Getting ready to watch Obama’s speech to students. Very upset that they are not showing at my son’s school.
10:58am – Indianapolis, IN
Cody W Warner Shame on TX schools for not showing this.
11:09am
Faye Skaggs I can’t believe some schools aren’t even offering this to students…shame on you. This is bi-partisan and should be viewed as such. Good for you President Obama.
11:14am – Harrisburg, PA

I saw this one come up a lot. That was just sad to see.

Wesley Gaines HEY OBAMA SAND BLOWER GO BACK OVERSEASE.
11:07am
Wesley Gaines OBUMMER STAY THE HELL AWAY FROM MY KIDS AND THATS AN ORDER FROM A US MARINE.
11:10am
Wesley Gaines WHEN A MARINE TALKS OBUMMER U SHUT THE HELL UP.
11:11am

This fellow was rather prolific and I do hope he sees some black SUVs soon.

Haters

Pat Lowe thinks that the president shouldnt be addressing kids about school when they are in school. a bit hypocritical dontcha think?
_10:59am – Minneapolis / St.

Read the rest »

On Health and Religion

September 5, 2009 - 11:08pm

And he sent them to preach the kingdom of God, and to heal the
sick.

And he said unto them, “Take nothing for your journey, neither
staves, nor scrip, neither bread, neither money; neither have two
coats apiece. And whatsoever house ye enter into, there abide, and thence
depart. And whosoever will not receive you, when ye go out of that city,
shake off the very dust from your feet for a testimony against them.”

And they departed, and went through the towns, preaching the
gospel, and healing everywhere — as long as they had private health
insurance.

Fox? Really?

August 31, 2009 - 10:19am

Picture 4.png

Eh, that works.

I Hate John Carter

June 30, 2009 - 3:51pm

House Democrats today voted to raise gas prices to $4 a gallon, nearly double consumer electric bills, and to ship 2 million American jobs a year to China and India with passage of the environmental extremist national energy tax bill. Congressman John Carter (R-TX) voted against the measure, which passed the House by a strictly partisan 219-212 margin, with 211 Democrats and 8 Republicans voting for the bill. 168 Republicans and 44 Democrats voted against it.
via email newsletter

  1. How is it “strictly partisan” if 8 Repubs voted for it and 44 ‘Crats voted against it? English, much?
  2. It’s not extremist and it won’t double energy prices, you moron.
  1. I feel embarrassed that you “represent” me, and my state, to the nation. You are ignorant, bought, and past your prime. Sadly, enough of your constituency has similar traits that you keep your job. I hope things change in six years in that department. A blue Texas would be a nice gift.

“Civilization has run on ahead of the soul of man, and is producing faster than he can think and give thanks.” — Daily News, 2/21/02 – G. K. Chesterton

Syndicate content Syndicate content