Tagged: dev Toggle Comment Threads | Keyboard Shortcuts

  • penguin 11:06 on 2018-10-17 Permalink | Reply
    Tags: dev, , ,   

    Misc Django I – forms 

    Custom form errors

    If you want to validate something in the view, and return with a custom error message in the same form, you can use the “Form.add_error(fieldname, errorstring)” method. And then, of course, return to the previous template.

    Dynamic choice fields in forms

    You want a form which fills its choice field from the database? And if the database changes, if you reload the page, the form should change as well? Of course! Django got you covered.

    … now, why the “for field in (‘department’ …)” line you ask?

    Simple. The fields dict is an OrderedDict. If you replace a field it is appended to the end again. So in the form the “Site” input box would be displayed last, although it makes more sense to display it where it is in the original definition.

    Using “.move_to_end()” you can re-adjust this. If someone knows a better method … feel free to tell me.

    (Sources: here)

  • penguin 16:34 on 2018-10-16 Permalink | Reply
    Tags: dev, ,   

    Django, psql & “permission denied” on migrate 

    I got this error:

    … when I wanted to do a “python manage.py migrate”. This post had the solution. In short: You have to change the owner of the tables to the one specified in the Django configuration.

    This is how my script looks:

  • penguin 16:36 on 2015-06-19 Permalink | Reply
    Tags: dev, js, mscode, node, typescript   

    Microsoft Code and Typescript 

    So being on the enterJS conference I wanted to get started with JavaScript. And TypeScript seems really promising. And once again I stumbled over the DIW pattern – Download, Install, Weird error messages.

    So, here’s my take on how to get started.

    I wanted …

    • ┬áto try node-hid to see my USB HID devices, using TypeScript, Microsoft Visual Studio Code, and Node.js.

    So here’s how to get it to work:

    Fire up Code, and “open” the project directory “my_project_dir”.

    Press “CMD-SHIFT-P” (probably CTRL-SHIFT on non-OSX machines) and search for “Configure task runner”. Here you use this configuration:

    Then create a new file called “test.ts”, with the following content:

    Now if you press “CMD-SHIFT-B” this should compile and create a file called “test.js”.

    I don’t know (yet) how to run it from within Code, so on the command line I can test it by doing …

    Article Sources:

    Microsoft Visual Studio Help

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help
shift + esc