Specifying the value format for a Django DateTimeInput using type=”datetime-local”, especially when using inline formsets

TL;DR: For a DateTimeInput widget where type=’datetime-local’, specify the default format to include the T in the middle of the date-time string:


This was driving me crazy!

I had a model inline formset using a form:


TicketNoteFormset = inlineformset_factory(Ticket, TicketNote, form=TicketNoteForm, extra=10)

The specified form (TicketNoteForm) had a widget specified for a DateTime field:


class TicketTicketNoteForm(forms.ModelForm):
    class Meta:
        model = TicketNote
        fields = [

My mistake was using DateInput for the field ‘when’, which was a DateTimeField, not a DateField

class TicketNote(models.Model):

    when = models.DateTimeField(
        help_text='The date that the note was submitted'

In the HTML forms, the initial value, as expected, was a date-time value but the value attribute of the field was a date value without the time

<input type="date" name="ticketnote_set-0-when" value="2022-01-22 06:52:09" id="id_ticketnote_set-0-when">
<input type="hidden" name="initial-ticketnote_set-0-when" value="2022-01-22 06:52:09" id="initial-ticketnote_set-0-id_ticketnote_set-0-when">

The difference between initial and non-initial caused a record to be created even if the form was blank

But it was still broken after I fixed it

Leaving out the widget declaration works, but then I just get a plain text field and I want to take advantage of the browser’s popup calendar

I thought I had the problem fixed by specifying the widget as



but that’s still giving me some problems. It worked fine in Firefox, but Chrome ignored the value attribute. So in Chrome

<input type="datetime-local" value="2022-01-01 08:01:00">

displays a blank datetime input and submits an empty string if not updated

I’ll update if I find a good solution.

Update: This works in Firefox and Chrome:


What Chrome was rejecting was having the value specified without the T between the date portion and the time portion. Django was producing the value without the T. By adding the format argument, I was able to make Django produce a default value that Chrome accepts.

Who gets credit for the hoax?

Is COVID-19 a hoax or is it a disease that can be cured with hydroxychloroquine?  or ivermectin?

Why wasn’t Trump treated with hydroxychloroquine when he got COVID-19?

Is it no worse than the flu or is it a deadly Chinese bio-weapon for which Dr. Fauci has the blood of millions on his hands?

If the vaccine is a hoax but Donald Trump’s Warp Speed program should get credit for it, does Donald Trump get credit for the hoax?

If the vaccine is not a hoax and Donald Trump’s Warp Speed program should get credit for it, does it matter that Pfizer, the first company to produce a vaccine, refused Warp Speed money so they wouldn’t be constrained by Warp Speed rules?

Why are both Donald Trump and Joe Biden vaccinated?  Is there anything else they agree about?

Virginia HD64: Your candidate or Dominion Energy’s candidate?

Dominion Energy is the top donor to Michael Drewry’s opponent.   Michael is not accepting donations from big donors like Dominion Energy, because Michael Drewry wants to work for you.  As our delegate in the 64th District, Michael Drewry will represent and fight for the people, as he did on the Surry County Board of Supervisors

As it says on his website,

By the end of the year, all of Surry County will have broadband internet access. And, while his opponent now voted against a Virginia House resolution recognizing water as a human right, Michael brought brand-new water infrastructure to Dendron.

Drewry for Delegate

If you donate to or volunteer for Michael Drewry’s campaign, you will be among real people working for a better future. If you live in the 64th House of Delegates district in Virginia, a vote for Michael Drewry is a vote to put power back in the hands of the people who make up the district.

Despite what you heard, we didn’t defund the police, we increased their funding

At a recent meeting of the Suffolk Democratic Committee, Delegate Clinton Jenkins announced some accomplishments made by the General Assembly. One of those accomplishments was an increase in funding for law enforcement. As I remember, he said, “Despite what you heard, we didn’t defund the police, we increased their funding,” and in response to that, the Suffolk Democrats applauded.

Terry McAuliffe is now fighting accusations of defunding the police when during his time, he, too worked to increase funding for law enforcement.

The phrase “Defund the Police” means different things to different people, except maybe for Republicans who seem unified in thinking the phrase means abolishing rule of law and creating a consequence-free environment for criminals. That’s not what it means to any Democrat.

Whatever the phrase might mean to various proponents and opponents across the nation, it’s a moot point in Virginia where the Democratic chair of the Judiciary Committee said, “No, we don’t need to take money from law enforcement […] We need the police.”

Don’t let Republicans gaslight you into thinking that a vote for Democrats is a vote for crime. The opposite is true, especially in Virginia.

Under Democratic leadership, including during the McAuliffe years of 2014 to 2018, Virginia has had the lowest crime rate in the region (see CDC data and Virginia Ranks Among States with Lowest Crime Rates). That, along with Virginia’s excellent economy, mean things are, and have been, pretty good in Virginia.

But Republicans think it’s time for a change.

A Guy Who Hates Me Gave Me a Jump in Virginia Beach

My wife’s car has a loose battery connector but that’s not why the battery drained today. It drained because I forgot the lights don’t turn out if you don’t open the driver’s door even if you take the key out of the ignition. Stupid feature. When I couldn’t start the car, I called the roadside service that I have through my insurance company.

The guy that arrived saw our bumper stickers and said he was willing to help me even though I was a Biden loving bastard.

Before I came up with a good response, he showed me the loose battery terminal. I said, “I know, but that’s not the problem today.” He fussed with it a bit and said, “Just for giggles, let’s try it now”, then added, “Just for kicks”

The car didn’t start because the battery was drained because of the lights. Like I said, the connector wasn’t the problem today. So he jumped it and got me going.

I didn’t get angry, but I didn’t shy away from talking to him. I don’t remember everything we said but I found out he hates Republicans, too. But he really hated Biden. At one point he spoke about all the illegals coming in. I said, “What about all those Haitians that we’re deporting?”. He said we’re not deporting any Haitians. He said they’re letting them in and telling us they’re being deported. He said they’re lying to me and I believe them.

He was already in his truck by then, and he backed away without saying anything else.

I did right by not insulting the guy – not saying he’s delusional or whatever, because I keep reading insults don’t work. Listen patiently and defend the truth. But I could have done better on the second part. The truth is I wasn’t ready for a debate and delusional people can say whatever they want, but defending the truth means keeping your facts straight.

I would have liked to have asked him, “If everyone is lying, how do you know what to believe?”

That I’m writing this post suggests he’s in my head more than I’m in his. Maybe being hateful and delusional is better for your mood than being contemplative and worried. While I was waiting for the jump I read an opinion piece saying, “The United States is heading into its greatest political and constitutional crisis since the Civil War, with a reasonable chance over the next three to four years of incidents of mass violence, a breakdown of federal authority, and the division of the country into warring red and blue enclaves.” This guy showing up didn’t give me much reason to doubt that.

This paragraph is two days older than the rest of the post. I didn’t think it was relevant at the time, but the insurance company gave this guy the wrong phone number and the wrong color of my car. He found me because my hood was up. He also noticed that my battery bracket was broken. He shook the battery and said, “Here’s why your connector keeps coming loose, buddy”. That sounds reasonable. He alternated between calling me “buddy” and “bastard”. The point is while none of this makes him a genius, I don’t think the guy was stupid. Just delusional. Brainwashed. When talking with these people, we shouldn’t assume their all stupid.

In Django, Using Form to get Field Labels in ListView and DetailView

I don’t know if this is good practice, but to get field labels in a ListView, DetailView, or DeleteView it seems to work fine if you just add a form to the context:


class ItemDetailView(DetailView):
    model = Item 
    context_object_name = "item"

    def get_context_data(self, **kwargs):
        context_data = super().get_context_data(**kwargs)
        # just to get the labels
        context_data['form'] = ItemForm
        return context_data


<div class="label">{{ form.name.label_tag }}</div><div class="value">item.name</div>
<div class="label">{{ form.brand.label_tag }}</div><div class="value">item.brand</div>
<div class="label">{{ form.sn.label_tag }}</div><div class="value">item.sn</div>

You can use label instead of label_tag

This works fine with most fields but fails with ManyToMany fields. Still, it seems to be the easiest way to get most field labels without having to type them in.

Is this a great idea or am I missing some reason that this is bad?

He did what he did but…

Federal judge tosses most claims against Trump, Barr and U.S. officials in clearing of Lafayette Square


Even though

Officials used batons, clubs and spray and fired projectiles as more than 1,000 largely peaceful demonstrators gathered

and the judge

acknowledged claims that Trump tweeted threats and encouragement of violence against protesters, and ordered Barr take charge of the situation before Barr mobilized law enforcement and appeared at the square just before it was cleared.

because apparently,

these events weren’t enough to allow conspiracy claims to go forward

So once again, Trump wiggles out of responsibility for a crime we know he committed because we can’t prove he conspired to commit it.

Remember the Donald as you Get your Shot

Donald Trump wants us to remember him as we get our covid vaccines. So lets review:

Donald Trump ignored pandemic response plans left by the Obama administration, and fired most of his own team members who attended a pandemic response exercise set up by Obama’s transition team

Before Trump’s inauguration, a warning: ‘The worst influenza pandemic since 1918’
Politico, 2020-03-16

Donald Trump cut CDC staff in China, including the epidemiologist responsible for detecting outbreaks

Trump says China “should have told us” about coronavirus. He removed the official meant to do that.
VOX 2020-03-23

Donald Trump ignored coronavirus briefings from his own intelligence officials

Trump Received Intelligence Briefings On Coronavirus Twice In January
NPR 2020-05-02

The first company to produce a vaccine, Pfizer, turned down research and development funding from Trump’s Warp Speed program so they would, according to their CEO, liberate their scientists from bureaucracy. Their vaccine is also the most effective

Pfizer Vaccine’s Funding Came From Berlin, Not Washington
Bloomberg 2020-11-09

Do not appease Republicans or fall for their bullshit

Marco Rubio suggested that they could impeach Hillary Clinton if we convict Trump

Rubio’s question did not mention Clinton by name, but he alluded to the “Lock her up!” chants targeting Clinton that Donald Trump encouraged as a candidate in their 2016 presidential contest.

“Is it not true that under this new precedent, a future House facing partisan pressure to ‘lock her up’ could impeach a former secretary of state, and a future Senate forced to put her on trial and potentially disqualify from any future office?” Rubio asked the impeachment managers and Trump’s attorneys.

In response, Rep. Jamie B. Raskin (D-Md.) noted that Trump was impeached while still in office for conduct while he was the president. The hypothetical, he said, “has no bearing on this case.”

Trump attorney Michael van der Veen disagreed, warning that voting to convict a former president would lead to impeachment proceedings against other ex-officials.

“It could happen to a lot of people. And that’s not the way this is supposed to work,” van der Veen said

The Washington Post https://www.washingtonpost.com/politics/2021/02/12/trump-impeachment-trial-live-updates/

Trump was impeached while he was president of the United States. The Senate is now trying him because the Constitution says the Senate has the authority to try all impeachments. While I don’t know if it’s possible to impeach someone while they are out of office, Jamie Raskin is clearly correct is saying that such a possibility is not related to this case.

Rubio’s question was a threat. It certainly wasn’t asked to find information because even Rubio isn’t that ignorant. If we convict Donald Trump for the crimes that everyone knows he committed, Republicans will continue to do what they have been doing for more than two decades, which is trying to convict Hillary Clinton of something.

Folks, they’ll do it anyway. Republican are enemies of the United States and we should not think that appeasing them will make them relent.

A NextDoor Conversation in Suffolk, Virginia

This is where I live. I retyped for you a conversation from NextDoor, which is a neighborhood-based social media service that’s supposed to be non-political. This is from the Liberty Spring neighborhood in Suffolk Virginia. Emphasis mine.

Your political arguments: I said this earlier on a political post where my friends and neighbors were arguing, but it was deleted.

Don’t believe the media. Everything we see and hear is being controlled. This is what they want. United we stand but divided we fall. We are all family. Love your neighbor and forgive them, for they do not know what they are doing. Do not pass judgement. You can’t control what people are brainwashed by(sic). Just trust God, he has a plan and I believe he will bring us all back together.

Amen Sister!

I agree! Always remember, God is in Control. It is his will. I just pray, people will know him and turn to him. These are trying times! The media is corrupt. I agree, don’t be brainwashed.


What’s ironic?

@person3 talking about being brainwashed by the media while in the same breath throwing the “word of god” around.

If you still believe media as truthful well then I’m lost for words.Well said.

We are to forgive and GOD is in control, however, GOD also gives us the discernment between right and wrong. There are good consequences and bad consequences depending your decision(s).