Two scathing audits released last week, one done by the state of Colorado and the other by the city of Denver, show just how laughably inept the two governments have been at regulating medical marijuana.

But what we also hope the audits show, in the form of humiliating but constructive criticism, is a way forward for Denver and the state in the regulation of recreational pot, which will become legal for sale in January and which they’re going to have to regulate properly.

A prior state audit focused on the shoddy regulation by the Department of Revenue’s Medical Marijuana Enforcement Division, but the latest report zeroed in on “weak controls” at the Department of Public Health and Environment, which maintains the medical marijuana registry of patients and regulates caregivers.

The audit showed there was little oversight of who gets the medical marijuana cards or who gives them to patients. Just 12 doctors were responsible for 50 percent of the 108,000 red cards that have been issued. Just 1 percent of patients had AIDS, 3 percent had cancer, and 1 percent had glaucoma, the audit said.

Meanwhile, 94 percent complained of “severe pain.” We don’t doubt some of those people fit the criteria for medical marijuana, but we also suspect many were just aching for marijuana.

Yet there will be no need in the future for feigning lower back pain, no need for a Dr. Feelgood. Coloradans, and anyone else, over 21 will be able to walk straight into a storefront and buy pot for recreational use.

In November, votes will consider a state sales tax and an excise tax — the former to pay for regulation. It’s also likely Denver and Boulder voters will be asked to approve local taxes on pot.

There is no question paltry funding played a part in the problems at the state’s Medical Marijuana Enforcement Division, but we’d note the audit released last week actually dinged the Department of Public Health and Environment for keeping red-card fees too high, which created an $11.3 million surplus at one point. Clearly, lack of funding is not always the culprit.

And as the report from Denver Auditor Dennis Gallagher showed, even prior audits that pointed out problems with medical marijuana enforcement by the city’s Department of Excise and Licensing weren’t enough to course-correct the agency.

The department’s medical marijuana records were so sloppy that employees couldn’t locate some files requested by auditors. The city also can’t say for sure how many medical marijuana businesses — a number that includes dispensaries, grow operations and infused-product manufacturers — Denver has. The state’s records say 676; the city’s say 739.

City and state officials must demonstrate they have learned from prior mistakes and can get it together to regulate recreational pot. This is too important to keep screwing up.