Skip to content
Advertisement

Tag: django-models

How to register inherited sub class in admin.py file in django?

Project Name : fusion App Name : admin_lte Python 3.7 Django 2 MySql Question is “I want to register sub model in django admin-panel”,when i write code for model registration in admin.py file that time occurred below error. django.core.exceptions.ImproperlyConfigured: The model Device is abstract, so it cannot be registered with admin. NOTE : I used multiple separated model file. device.py

How to list applied migrations from command line?

I had run makemigrations and after that migrate to apply the migration How to find out models in boards from command line? Answer You’ll need to use some undocumented APIs for this, but here’s one way: After this, loader.disk_migrations will be a dictionary whose keys are (app_name, migration_name) tuples, and whose values are the Migration objects. So iterating loader.disk_migrations.keys() will

Getting an Assertion error in my django application(1.8.4)

I am getting an exception value on running application : (“Creating a ModelSerializer without either the ‘fields’ attribute or the ‘exclude’ attribute has been deprecated since 3.3.0, and is now disallowed. Add an explicit fields = ‘__all__’ to the StockSerializer serializer.”,) Answer As the error message says, the required attribute is fields with an ‘s’, not field.

Prevent DateRangeField overlap in Django model?

Now that Django supports the DateRangeField, is there a ‘Pythonic’ way to prevent records from having overlapping date ranges? Hypothetical use case One hypothetical use case would be a booking system, where you don’t want people to book the same resource at the same time. Hypothetical example code Answer I know that the answer is old, but now you can

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

I have two classes in my sqlite database, a parent table named Categorie and the child table called Article. I created first the child table class and addes entries. So first I had this: And after I have added parent table, and now my models.py looks like this: So when I run python manage.py makemigrations <my_app_name>, I get this error:

Advertisement