Accountability 24 Feb 2020

My status this week is:

DONE: As expected, I’ve gone down a Django rabbit hole :frowning: Its really annoying as all I want to do is enable markdown and a media library to my site so I can record progress in other areas. Instead I’m finding myself needing to understand much more about how Django works via settings, and a lot more details about models and forms. I’ll give this one more week as it’s becoming an unwelcome distraction.

BLOCKERS: Django…and web front ends :angry: Last week at work handover.

GOALS: Get one markdown library working so I can start using my blog properly.

I am currently working on … my blog. Then LMPTHW, and some Python testing course to finish.

I am struggling with understanding … how to implement markdownx

I am finally understanding … Django’s mysite layer.

I have work to show at … http://www.grahamkesley.com & GitHub

2 Likes

Hi, @gpkesley, site is down.
As for the editor, have you seen this: https://github.com/agusmakmun/django-markdown-editor ?
Might be worth checking, I see they just bumped up version…

1 Like

Hm… I’m curious, this sounds like a very common requirement. Isn’t there anybody who can help you with it? It’d be a shame if you decided to drop the blog just because you couldn’t get Markdown working! Keep going!

@florian I’ve not dropped it. Just getting deeper into the project than I hoped at present. I’ve got 5 other projects to dedicate my time too and Django was not one of them.

Site (for what it is worth is up… http://www.grahamkesley.com/) but hardly worth the time checking at present @io_io .

I have looked at Martor already and its exactly what I wanted to implement. I’d be happy with just the admin view implementation at this time but I just don’t get it. I followed the setup guide but I don’t really get the Usage part. I might have another go but if you are about on Riot at any point @io_io give me a shout and I might tap you up for some knowledge. Does this need JS/JQuery to work or is it pure python?

Edit: I’m making some progress… I got markdown working in Admin console. That’s step 1. Now to get it to render to the page. I read some SO pages about this…

1 Like

Hey, not using Riot yet :smiley:
Just make sure you add all you need in your settings.py.
Then in your posts model add that martor field like in the example, add it in your post’s form then in the admin.py. Then add it in your template.
Should work.

Its the template bit I don’t seem to understand @io_io. I’ll have another look in a bit. Make slow progress. But thanks :smiley:

Do you use Slack? And if so, what mail address?
You just add {% load martortags %} above your post form, inside your edit post template,
then {{ form.as_p|safe_markdown }} which means you add a safe markdown filter.
Of course, replace form.as_p with whatever form you use in your edit post template. I just gave you an example of where you should add things.
Check this bit about filters:
https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#std:templatefilter-safe

Yeah exactly… but its screwing me up @io_io as I get this when I do that simple implementation…

I read something about JQuery usage this morning if you want to render. I’ll read more on that.

I’m on Slack but mostly hidden behind AD_Groups. Still on Discord from the old days

mmm… seems fine, I wouldn’t mind it as long as it’s just me who sees it :smiley:
Can you use markdown in the post?
And what happens if you click on that editor preview link?
Did you enable all configs in the settings? Jquery etc?

1 Like

Cracked it. Thanks @io_io… Now got markdown rendering on the post_list, post_edit and post_draft template views locally.

I’ve learned more about JS in the last hour than in the last year :smiley: I really need to get my frontend JS knowledge up to spec…but this has helped a bit.

Sorry all for the thread-hog…!! Perhaps it can be moved/removed to JS.

2 Likes

Yay, cool! Way to go!
Do you plan to add a certificate?

1 Like

:partying_face:
Nice. Congrats! Tenacity always pays off.

2 Likes

Thanks folks. A few more tweaks and I think I can just start using the prod version to track my progress again.

TODO:

  • implement MySQL rather than SQLite in host
  • ensure I’ve got the static & media files correctly referenced when debug=False
  • go through deployment shopping list and fix the numerous vulnerabilities
  • get a https certificate (I assume this is what you mean @io_io ? Know any good resources?)
1 Like

Yes, a TLS certificate.
I don’t know how “good” they are, saw recently @zedshaw being grumpy about them, so better ask him.
I am using Let’s encrypt cause it’s free. https://letsencrypt.org/
Mysql? Why not Postgres?

1 Like

Because Postgres is an additional charge and I’m just using a cheap hacker account:

Rationale from Forum:

It’s because of the way we have the MySQL server vs the Postgres server setup.

For MySQL, it is multi-tenanted (ie. you are using the same MySQL server as other people who are just accessing the same server as different users), so sometimes you may suffer from a noisy neighbor etc.

We did not take this approach for Postgres (partly because we believe there is less good support for postgres multi-tenancy), and instead you get your own Postgres server running inside of your own docker container. This way, you can be the admin user (MySQL users won’t get admin rights and for example won’t be able to do db triggers) and do stuff like create your own users, enable plugins etc. (Although to be clear you still don’t get root / there may be stuff you can’t install etc on Postgres)

(and that basically makes Postgres way more resource hungry)

I’d prefer Postgres as have that running fine locally. But cannot justify the cost for a single user application at this time.

2 Likes

Back to the topic:

My status this week:

DONE: Some progress with C and Lisp.
I’ve also been experimenting with Flask, trying to wrap my head around how to build a simple backend for a blog site. Then came that other thread… :slight_smile: about Python vs. JS and now…

GOALS: … I’ve decided to ditch Python and use JS with the frameworks that Zed suggested. What I read about the concepts behind Svelte and Sapper really seems super slick (even though I can’t say that I understand half of the technical stuff).

Next part of the journey! All that web stuff seems kind of intimidating… in contrast, with C, and even more so, Lisp, where I feel like I’m sitting in a quiet monastery high up in the mountains, pondering some obscure branch of math, undisturbed by the chaos of real creation that’s boiling in the lowlands…

3 Likes
A free service run by Zed A. Shaw for learncodethehardway.org.