Edit: Trigger function and trigger are working fine with no errors, problem was with my database itself, dropped the database, created new, it's working now.
How do I prevent UPDATE on any record in a given table, but allow INSERT, I already have created a trigger which prevents update but I found that it also prevents INSERT.
I can INSERT new row/record from the database itself but not from the form for a new record of the application that is connected to this database, after submitting the form, the trigger is being executed.
It's a web application built with Django.
CREATE OR REPLACE FUNCTION prevent_updte() RETURNS trigger AS $BODY$ BEGIN RAISE EXCEPTION 'Data modification not allowed'; END; $BODY$ LANGUAGE plpgsql
CREATE Trigger prevent_update BEFORE UPDATE ON purchases_purchase FOR EACH ROW EXECUTE PROCEDURE prevent_update();