__init__() got an unexpected keyword argument ‘user’

You can’t do because you have an __init__ method that does NOT take user as argument. You need something like Update But, as bruno has already said it, Django’s models.Model subclass’s initializer is best left alone, or should accept *args and **kwargs matching the model’s meta fields. So, following better principles, you should probably have something like Note – If you weren’t using temp as a keyword argument, e.g. LivingRoom(65), then … Read more

ow to ‘bulk update’ with Django?

Update: Django 2.2 version now has a bulk_update. Old answer: Refer to the following django documentation section Updating multiple objects at once In short you should be able to use: You can also use F objects to do things like incrementing rows: See the documentation. However, note that: This won’t use ModelClass.save method (so if you have some logic inside it … Read more

How to query as GROUP BY in django?

If you mean to do aggregation you can use the aggregation features of the ORM: This results in a query similar to and the output would be of the form If you don’t include the order_by(), you may get incorrect results if the default sorting is not what you expect. If you want to include … Read more

What does on_delete do on Django models?

This is the behaviour to adopt when the referenced object is deleted. It is not specific to Django; this is an SQL standard. Although Django has its own implementation on top of SQL. (1) There are seven possible actions to take when such event occurs: CASCADE: When the referenced object is deleted, also delete the objects that have … Read more

What is a “slug” in Django?

A “slug” is a way of generating a valid URL, generally using data already obtained. For instance, a slug uses the title of an article to generate a URL. I advise to generate the slug by means of a function, given the title (or another piece of data), rather than setting it manually. An example: … Read more

Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries

You can change the property categorie of the class Article like this: and the error should disappear. Eventually you might need another option for on_delete, check the documentation for more details: EDIT: As you stated in your comment, that you don’t have any special requirements for on_delete, you could use the option DO_NOTHING: