Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why are uploaded images via Django admin not showing up in the production server?
I have the following model field logo = models.ImageField(upload_to=municipality_logo_file_name) and function that uploads the image to the desired location. def municipality_logo_file_name(instance, filename): name, extension = os.path.splitext(filename) return os.path.join('municipality', 'logo', str(uuid.uuid4()) + extension.lower()) In the development mode, a file uploads correctly to for example /media/municipality/logo/1e3cc24a-841b-4577-aa59-b53e5b10420b.png and then displays correctly in the template using <img src="{{ municipality.logo.url }}" alt="Logo obce" style="max-height: 8rem; width: auto"> In the production, file uploads well, but does not display in the template and the url cannot be followed to display image, the response is Not Found The requested resource was not found on this server. Any hint as to why this might be happening would be much appreciated. -
DJANGO translate complex template variable
I would like to translate a more 'complex' template variable, however I am running into unexpected error. The simple texts on my template are translated properly. I have a template variable that looks like this: {{ days|index:class.gym_class.day }} days is a list of week days, index is a custom tag that looks looks like this: @register.filter def index(List, i): return List[int(i)] The variable evaluates to "Monday" I have this in my .po file, and the .po file is compiled msgid "Monday" msgstr "Hétfő" Now if I want to translate the variable like this: <td>{% trans days|index:class.gym_class.day %}</td> I get an error: AttributeError at /hu/login 'list' object has no attribute 'replace' To me it seems, that the translation tries to happen before the template tag evaluation? I also tried <td>{% blocktrans %}{{ days|index:class.gym_class.day }}{% endblocktrans %}</td> Which interestingly returned nothing. Neither "Monday" neither "Hétfő" is printed. How can this problem be solved? -
DJANGO translate template variable
I am having problems translating template variables according to this thread: django translate variable content in template Simple text on the template get translated perfectly, however evaluated template variables dont. I have a template that looks like this: <td>{{ days|index:class.booking.day }}</td> The variable there evaluates to "Monday", with capital M and no spaces. In my .po file, I have msgid "Monday" msgstr "Hétfő" After compiling the .po file I thought I should be able to translate this by <td>{% trans days|index:class.booking.day %}</td> But only "Monday" is shown, not its translation. I also tried blocktrans to no avail <td>{% blocktrans %}{{ days|index:class.booking.day }}{% endblocktrans %}</td> What am I doing wrong? -
'QuerySet' object has no attribute 'save' Error Occurred
I am a student studying Django. Currently, the member information has been entered in the Member table. I want to create Mypage so that member information registered in the Member table can be modified, and develop so that member information can be modified on Mypage. But while developing, I faced the following error: How can I solve this? Any help would be greatly appreciated. Detail Error : AttributeError at /mypage/mypage_modify/ 'QuerySet' object has no attribute 'save' Request Method: POST Request URL: http://127.0.0.1:8000/mypage/mypage_modify/ Django Version: 3.1.5 Exception Type: AttributeError Exception Value: 'QuerySet' object has no attribute 'save' Exception Location: C:\zeronine_project\mypage\views.py, line 27, in mypage_modify Python Executable: D:\anaconda3\envs\vnv_zn\python.exe Python Version: 3.7.6 Python Path: ['C:\\zeronine_project', 'D:\\anaconda3\\envs\\vnv_zn\\python37.zip', 'D:\\anaconda3\\envs\\vnv_zn\\DLLs', 'D:\\anaconda3\\envs\\vnv_zn\\lib', 'D:\\anaconda3\\envs\\vnv_zn', 'D:\\anaconda3\\envs\\vnv_zn\\lib\\site-packages'] Server time: Thu, 08 Jul 2021 21:05:53 +0900 view.py from django.http import HttpResponseRedirect from django.shortcuts import render, redirect from mypage.forms import * from zeronine.models import * # Create your views here. def mypage_list(request): categories = Category.objects.all() return render(request, 'mypage/mypage_list.html', {'categories':categories}) def mypage_modify(request): current_category = None categories = Category.objects.all() member = Member.objects.all() if not request.user.is_authenticated: return HttpResponseRedirect(reverse('zeronine:login')) if request.method == "POST": member.name = request.POST['name'] member.password = request.POST['password'] member.username = request.user member.save() return redirect('zeronine:post') else: memberForm = MemberForm return render(request, 'mypage/mypage_modify.html', {'memberForm':memberForm, 'member':member, 'current_category': current_category, … -
How to get choices field from django models in a list?
I have a model having choices field. I want to fetch the choices options in a list.please help me to achieve that OPTIONS = ( ('COOL', 'COOL'), ('WARM', 'WARM'), ) class My_Model(models.Model): options = models.CharField(max_length=20, choices=OPTIONS, default=None,blank=True, null=True) I want options values in a list like ['COOL','WARM'], How to achieve it, I tried something like My_Model.options but it is not working -
Angular CRUD backend frontend
In Django I build a backend, with the Model Person, which contains of two foreign keys: 'gender' and 'work'. I have build the REST API for the app and it is working as intended. When I try to create a Person in my Angular frontend, I get the multiple select options for 'work', but no for 'gender' - which is weird, because I just applied the same code for the both of them. This is my Form Field in Angular to create Person: When I try to select form Gender Foreign Key, I get nothing, but for Work Foreign Key it works perfect. I will do edits with code, if you tell me which files are needed. Because I have no idea where my error is. -
How to convert integer months to year in python
I have inputs start date and end date. I want output like 2 years 7 months from dateutil.relativedelta import relativedelta rdelta = relativedelta(now, birthdate) print 'years - ', rdelta.years print 'months - ', rdelta.months in this method, I got output like >>> years - 2 >>> months - 18 I prefer output like I want output like 2 years 7 months -
Blog Category Slugify is not working in Django
I am getting an error when I click on the post category it says Field 'id' expected a number but got 'coding'. Each post is added under a category below is my Code: Model: class Item(models.Model): title = models.CharField(max_length=100) description= RichTextField(blank=True, null=True) main_image= models.ImageField(null=True, blank=True,upload_to='images/') date = models.DateTimeField(auto_now_add=True) item_category = models.ForeignKey(Categories, default='Coding', on_delete=SET_DEFAULT) slug = models.SlugField(null=False, unique=True) # new View: def CategoryView(request, cats): category_posts = Item.objects.filter(item_category=cats.replace('-','')) return render(request, 'waqart/categories.html', {'cats':cats.title(), 'category_posts':category_posts }) URL: urlpatterns = [ path('', ItemListView.as_view(), name='waqart-home'), path('add_item/', ItemCreateView.as_view(), name='create_item'), path('item/<int:pk>/', ItemDetailView.as_view(), name='item_detail'), path('item/edit/<int:pk>/', ItemUpdateView.as_view(), name='item_update'), path('category/<str:cats>/', CategoryView, name='category'), I am new to django appreciate if anyone can solve this for me -
How to get a full path of file uploaded via HTML form in django view.py file?
home.html <form action="" method="POST" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name = 'img' > <button type="submit"> Post On Facebook </button> </form> views.py def home(request): if request.method == 'POST': # get the image absolute location return render(request,'home.html') I want the file path, so that I can upload the file on facebook using GraphAPI. -
Where to store raw SQLs on Django Project
In my Django project I'm using two dbs. Postgres which works with ORM and Bigquery. To query Bigquery I have a bunch of extensives SQLs and I dont want to store it on a View. Curently I'm storing in a folder called queries in the same level of views folder. But I keep asking myself if those SQLs should be in models folder in some way. Well, where is the best place to store raw SQLs on a Django Project? -
Django admin do not display all fields
This question is created to help other people with similar problem. I know how to fix the issue, but I'm also interested Why this happens. In my models.py I've had a model class CEOSetting(models.Model): title = models.CharField('Заголовок', help_text='Содержимое тега <title>. Так-же поддерживает переменные.', max_length=200, blank=True) page = models.CharField('Описание страницы', max_length=120) key = models.CharField('Ключ', max_length=50, unique=True) variables = models.TextField('Доступные переменные', null=True, blank=True) description = models.TextField('Meta description', blank=True) keywords = models.TextField('Meta keywords', blank=True) robots = models.TextField('Meta robots', blank=True) And registered this model in admin.py @admin.register(CEOSetting) class CEOSettingAdmin(admin.ModelAdmin): pass When I've tried to add or edit CEOSetting record in admin, the admin site was showing me only one field (title) and nothing more. Even buttons at bottom of the page were missing. -
Save position in sortable list
I'm trying to make an sortable list for a website with Django, I need to keep the order of the cards when they are changed position, saving this in a database table. The POST method below, returns me the old position of the card, the new position and the ID of a card. $(function() { var start_pos; var end_pos; var id; $('#sortable').sortable({ start: function(event, ui) { start_pos = ui.item.index(); ui.item.data('start_pos', start_pos); }, stop: function(event, ui) { end_pos = ui.item.index(); id = ui.item.attr("id"); $.ajax({ url: "/project/", data:{ start_pos, end_pos, id, csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken').val() }, method: 'POST', }) }, update: function(event, ui) { $('#sortable li').removeClass('highlights'); } }); }); In the database, each card have a ID and and "order_number" fields, when the card changes, I want to keep the ID the same and the "order_number" change, replacing the older "order_number". I don't have any idea how make an SQL statement to save this order or something in the jQuery code. Thanks in advance! -
Django Datatables View filter/search
Using django-datatable-view at https://github.com/pivotal-energy-solutions/django-datatable-view for a class based DataTable. It is all working and loading but i have the issue with searching data. I cannot work out how to search for the whole sentence entered, at the minute it seems to search per word. class StoresDatatable(Datatable): class CustomColumn(columns.DisplayColumn): def __init__(self, *args, **kwargs): self.field = kwargs.get('field', None) if self.field: kwargs.pop('field') super().__init__(*args, **kwargs) def search(self, model, term): return Q(**{ '%s__name' % self.field : term }) attr = CustomColumn( 'Attrs', 'count_attr', # data source field='attributes', processor="get_attributes", allow_regex=True ) Code that triggers on choosing filter (outside of table). const searchValue = 'new test' $(".datatable") .DataTable() .column(columnIndex) .search(searchValue, true, true, false) Searching for 'new test' searches twice, so i would get results for 'new' and results for 'test'. What i need is just results for 'new test'. Print shows what is being searched <th data-name="attrs" data-config-sortable="true" data-config-visible="true">Attrs</th> test <th data-name="attrs" data-config-sortable="true" data-config-visible="true">Attrs</th> new -
get() returned more than one-- Django Restframework
I have a Django model which needs to have more than 1 images and more than 1 files (numbers may vary as per requirement), for which I adjusted my Admin Panel accordingly like this models.py class MasterIndividualMembers(models.Model): individualmemberId = models.CharField(primary_key=True, max_length=100, default=1) ... ... def __str__(self): return self.firstname + " " + self.lastname class IndividualMemberPhotos(models.Model): individualmemberId = models.ForeignKey(MasterIndividualMembers, default=None,on_delete=models.CASCADE) image = models.ImageField(upload_to="individualmemberphotos/") class IndividualMemberCatalogue(models.Model): individualmemberId = models.ForeignKey(MasterIndividualMembers, default=None,on_delete=models.CASCADE) files = models.FileField(upload_to="individualmembercatalogue/") admin.py class IndividualMemberPhotosAdmin(admin.StackedInline): model = IndividualMemberPhotos class IndividualMemberCatalogueAdmin(admin.StackedInline): model = IndividualMemberCatalogue @admin.register(MasterIndividualMembers) class MasterIndividualMembersAdmin(admin.ModelAdmin): inlines = [IndividualMemberPhotosAdmin,IndividualMemberCatalogueAdmin] class Meta: model = MasterIndividualMembers For the views I simply make a function to provide details of all the Images, Document and that User views.py @csrf_exempt @api_view(['POST']) @permission_classes([IsAuthenticated]) def get_individualmember(request): if request.method == 'POST': try: individualmemberId = request.POST.get('individualmemberId') result = {} result['individualMemberDetails'] = json.loads(serializers.serialize('json', [IndividualMemberPhotos.objects.get(individualmemberId=individualmemberId)])) result['individualPhotoDetails'] = json.loads(serializers.serialize('json', IndividualMemberPhotos.objects.filter(individualmemberId__individualmemberId = individualmemberId))) result['individualCatalogueDetails'] = json.loads(serializers.serialize('json', IndividualMemberCatalogue.objects.filter(individualmemberId__individualmemberId = individualmemberId))) except Exception as e: return HttpResponseServerError(e) Problem: While fetching the details for any individual member, it throws an error get() returned more than one IndividualMemberPhotos -- it returned 2!, which is expected to have more than 1 objects. How can I make the Restframework to provide me details of all image object together. -
TypeError: Got a `TypeError` when calling `create()`. You may need to make the field read-only, or override create() method to handle this
I have this Graph view: class GraphView(generics.ListCreateAPIView): permission_classes = (IsAuthenticated,) serializer_class = GraphSerializer def get_serializer_context(self): return {"request": self.request} def get_queryset(self): return Graph.objects.filter(entity=self.request.source_entity) def perform_create(self, serializer): if serializer.is_valid(raise_exception=True): serializer.save(entity=self.request.source_entity, creator=self.request.user, context=self.get_serializer_context()) Iam getting following error while I try POST req: TypeError: Got a TypeError when calling Graph.objects.create(). This may be because you have a writable field on the serializer class that is not a valid argument to Graph.objects.create(). You may need to make the field read-only, or override the GraphSerializer.create() method to handle this correctly. However , i cant make all fields read-only. how can i override create ()? -
Page not found (404) No Track matches the given query. error Django
I'm getting this page not found error when clicking on a link to the eq_detail page. the links are generated by a for loop in the "instrument_detail.html" template , the first link works but the others come back with this error. error Page not found (404) No Track matches the given query. Request Method: GET Request URL: http://127.0.0.1:8000/eq-detail/wonderful/guitar/2/ Raised by: feed.views.eq_detail not sure what the fault is , here's my url, views and templates urls.py path('instrument-detail/<slug:track_slug>/<int:id>/', views.instrument_detail, name='instrument_detail'), path('eq-detail/<slug:track_slug>/<slug:instrument_slug>/<int:id>/', views.eq_detail, name='eq_detail'), views.py @login_required def instrument_detail(request, track_slug, id): user = request.user track = get_object_or_404(Track, id=id) my_inst = Instrument.objects.filter(track_id=track.id) instrument_obj = get_object_or_404(Instrument, id=id) if my_inst.exists(): instruments = Instrument.objects.filter(track_id=track.id) context = { 'instruments': instruments, 'track': track, 'instrument': instrument_obj, } return render(request, 'feed/instrument_detail.html', context) else: print('There are no instruments set in your track') return redirect('create_instrument', track_slug=track.slug, id=track.id) @login_required def eq_detail(request, track_slug, instrument_slug, id): user = request.user track = get_object_or_404(Track, id=id) instrument = get_object_or_404(Instrument, id=id) eq_obj = get_object_or_404(EQ, id=id) eqs = EQ.objects.filter(instrument_id=instrument.id) if eqs.exists(): context = { 'track': track, 'instrument': instrument, 'eqs': eqs, 'eq_obj': eq_obj, } return render(request, 'feed/eq_detail.html', context) else: return redirect('create_eq', track_slug=track.slug, instrument_slug=instrument.slug, id=instrument.id) eq_detail.html <a href="{% url 'instrument_detail' track.slug track.id %}"><b>Back To Instruments</b></a> <br> <br> <div class="container my-tracks"> {% if eqs|length >= … -
In which Model should I include approved status of a labour getting a particular job?
So I have created 2 models namely JobModel and LabourModel and I have used Many-to-Many relation between them because 1 labour can apply for multiple jobs and there can be multiple labours applying for 1 job. Now I want to add a feature where the jobcreator can accept/reject a particular labour applying for that particular job and then the labour should be able to see the status regarding approval. I am confused about how should I make a model about this. Here's my current model from django.db import models from django.contrib.auth.models import User from django.urls import reverse_lazy, reverse # Create your models here. class UserModel(models.Model): user = models.OneToOneField(User,related_name = 'user_profile',on_delete=models.CASCADE) CATEGORY_CHOICES = (('Labour','Labour'),('Owner','Owner')) category = models.CharField(max_length=100,choices=CATEGORY_CHOICES,default='NA') is_Labour = models.BooleanField(default=False) is_Owner = models.BooleanField(default=False) def __str__(self): return self.user.username def get_absolute_url(self): return reverse("basic_app:landing") class JobModel(models.Model): user = models.ForeignKey(UserModel,related_name='assigned_job',null=True,on_delete=models.CASCADE) title = models.CharField(max_length=255,null=True) description = models.CharField(max_length=500,null=True) def __str__(self): return self.user.user.username def get_absolute_url(self): return reverse("basic_app:landing") class LabourModel(models.Model): user = models.OneToOneField(UserModel,related_name = 'assigned_labour',null=True,on_delete=models.CASCADE) registered = models.BooleanField(default=False) job_add = models.ManyToManyField(JobModel,related_name = 'labours') def __str__(self): return self.user.user.username def get_absolute_url(self): return reverse("basic_app:landing") -
queryset add more data return in django rest framework
I have issue in django and I want query in table follow to get data performance. this is my problem I have a table follows in django: class Follows(TimeStampedModel): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user_follower = models.ForeignKey(User, related_name="following", on_delete=models.CASCADE) user_following = models.ForeignKey(User, related_name="follower", on_delete=models.CASCADE) class Meta: ordering = ["created"] unique_together = ("user_follower", "user_following") verbose_name = "Follows" this is my serializer: class FollowsSerializer(serializers.ModelSerializer): class Meta: model = Follows fields = "__all__" This is my view query set: class FollowsApiView(generics.ListCreateAPIView): serializer_class = serializers.FollowsSerializer def get_queryset(self): user = self.request.user query_set = Follows.objects.filter(user_following=user).annotate(followed=(Follows(user_follower=user))) self.serializer_class = serializers.FollowersSerializer return query_set when I have 1 record A is user_follower, B is user_following and 1 record B is user_follower, A is user_following then when get list Follow how to I can check this condition in query set view: if A followed B and B followed A then return followed = True else False -
How do you containerize a Django app for the purpose of running mulptiple instances?
The idea is to create a Django app what would serve as the backend for an Android application and would serve an web admin interface for managing the mobile application's data. Different sites of the company sometimes need different backends for the same android app (data has to be manageable completely separately). Application will be hosted on Windows server/s. How can I containerize the app so I can run multiple instances of it (listening on different ports of the same IP) and I can move it to different servers if needed and set up a new instance of it there? The Django development part I'm familiar with but I have never used Docker(nor other) containers before. What I need: Either a tutorial or documentation that deals with this specific topic OR Ordered points with some articles or tips how to get this done. Thank you. -
Django: How to add another form to my homepage when the homepage already has a template
On my homepage(http://127.0.0.1:8000/) I created a template and its function in views.py and the URL of the homepage directs to it, however, there is a form that I want also to show on the homepage. -
TypeError: Direct assignment to the forward side of a many to many set is prohibited. Use groups.set() instead
I am currently getting this error when making a POST request, and I am not sure what is causing it because I have not explicitly declared anything as a many-to-many relationship. What's also confusing me is that I don't have any object/relation called group, so why is it saying use groups.set()? I am using nested serializers, as when creating a student I want it to create a user object underneath it. I have attached an image of the GET request succeeding, as it shows the format in which data should be POST'ed Here is an image of the error I'm getting as well These are the two current relations in question that are giving me problems Users(id(PK), username, password, first_name, last_name, dob, role, email, house, comments) Students(id(PK), user_id(FK), grade, enrollment_year) Here is the serializer create method and the view's POST method def create(self, validated_data): user_data = validated_data.pop('user') user = User.objects.create(**user_data) student = Student.objects.create(**validated_data, user=user) return student def post(self, request): """ Create new student """ serializer = StudentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) -
Django migration: `AlterUniqueTogether` fails with `constraint does not exist` but I think it's there
I'm trying to run the following migration using Django 2.2: class Migration(migrations.Migration): dependencies = [ ('actstream', '0002_remove_action_data'), ] operations = [ migrations.AddField( model_name='follow', name='flag', field=models.CharField(blank=True, db_index=True, default='', max_length=255), ), migrations.AlterUniqueTogether( name='follow', unique_together=set([('user', 'content_type', 'object_id', 'flag')]), ), ] The model before the git commit that adds the migration has the following constraint: unique_together = ('user', 'content_type', 'object_id') And after the git commit that adds the migration: unique_together = ('user', 'content_type', 'object_id', 'flag') (flag is a new field and it's also been added to the unique_together constraint). When I try to apply the migration, I get the following error message: psycopg2.errors.UndefinedObject: constraint "actstream_follow_user_id_content_type_id_object_id" of relation "actstream_follow" does not exist Inspecting my database as it is without the migration, tho, I see the following: What am I missing? Thanks! -
Related Field got invalid lookup: name
I am trying to implement Q search on my APIView, but it says invalid lookups name which is strange. I have added the search fields according to the fields of the models. My view: from django.db.models import Q class PrdouctSearchAPIView(ListAPIView): permission_classes = [AllowAny] # def list(self, request, *args, **kwargs): def get(self, request, *args, **kwargs): qur = self.request.query_params.get('search') item = Product.objects.filter(Q(category__name__icontains=qur)| Q(brand__name__icontains=qur)| Q(description__icontains=qur)| Q(collection__name__icontains=qur)| Q(variants__name__icontains=qur)) serializer = ProductSerializer(item,many=True) return Response(serializer.data) My models: class Product(models.Model): merchant = models.ForeignKey(Seller,on_delete=models.CASCADE,blank=True,null=True) category = models.ManyToManyField(Category, blank=False) sub_category = models.ForeignKey(Subcategory, on_delete=models.CASCADE,blank=True,null=True) brand = models.ForeignKey(Brand, on_delete=models.CASCADE) collection = models.ForeignKey(Collection, on_delete=models.CASCADE) featured = models.BooleanField(default=False) # is product featured? class Category(models.Model): #parent = models.ForeignKey('self',related_name='children',on_delete=models.CASCADE,blank=True,null=True) name = models.CharField(max_length=100, unique=True) image = models.ImageField(null=True, blank=True) class Brand(models.Model): brand_category = models.ManyToManyField(Category,blank=True,null=True) name = models.CharField(max_length=100, unique=True) class Collection(models.Model): name = models.CharField(max_length=100, unique=True) image = models.ImageField(null=True, blank=True) My url is : path('api/productsearch',views.PrdouctSearchAPIView.as_view(),name='api-productsearch'), As we can see there are fields "category__name" and such not only "name", but the error says invalid lookup "name". -
What am I doing wrong that leads to a NOT NULL constraint failed: error on django form submission?
I am working on a little self project and I need some help. I have a doctor model and every time I create a doctor I want to create a new user as well. So a doctor is a user of the system as well. My view has 2 forms, 1 for the doctor part and 1 for the user part, but every time I submit my form I get this error NOT NULL constraint failed: medical_doctor.user_id. If I look in the db afterwards, it has created the user and the doctor but there is no data about the user or the doctor. Any help would appreciated. Here is my model.py file: class Doctor(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) doctor_name = models.CharField(max_length=200) doctor_surname = models.CharField(max_length=200) contact_number = models.CharField(max_length=10) def __str__(self): return self.doctor_name + ' ' + self.doctor_surname def get_absolute_url(self): return reverse('medical:doctor-details', args=[str(self.id)]) @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Doctor.objects.create(user=instance) else: instance.doctor.save() Here is my form.py file: class DoctorCreationForm(forms.ModelForm): class Meta: model = Doctor fields = ['doctor_name', 'doctor_surname', 'contact_number'] class UserCreationForm(forms.ModelForm): class Meta: model = User fields = ['username', 'password', 'email', 'first_name', 'last_name'] Here is my view.py file: def createDoctorUser(request): if request.method == 'POST': doctor_form = DoctorCreationForm(data=request.POST, prefix='docForm') user_form … -
Django get_fields() Not Returning Parent Fields
I have an abstract class called CustomBaseModel. It contains 2 fields that record when an entry is created and updated. The Country model inherits this CustomBaseModel. class CustomBaseModel(models.Model): created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False) class Meta: abstract=True class Country(CustomeBaseModel): ID = models.BigAutoField(primary_key=True) name = models.CharField(max_length=250) currency = models.CharField(max_length=3) piTag = models.CharField(max_length=4) I also have 2 admin classes that handle model behavior in the admin interface. class CustomAdmin(ImportExportModelAdmin): def get_fields(self, request, obj=None, **kwargs): fields = super().get_fields(request, obj, **kwargs) print(fields) #For debugging ... Additional Operations (ex. fields.remove('created_at')) ... class CountryAdmin(CustomAdmin): resource_class = CountryResource Using get_fields() in the Django Shell, you can see that the parent fields created_at, and updated_at are returned. >>> from aboveSites.models import Country >>> Country._meta.get_fields() (<django.db.models.fields.DateTimeField: created_at>, <django.db.models.fields.DateTimeField: updated_at>, <django.db.models.fields.BigAutoField: ID>, <django.db.models.fields.CharField: name>, <django.db.models.fields.CharField: currency>, <django.db.models.fields.CharField: piTag>) However, the application itself crashes when run due to the following error. list.remove(x): x not in list The print statement in CustomAdmin class confirms that the updated_at, and created_at fields are not returned. [08/Jul/2021 09:17:57] "GET /admin/country/ HTTP/1.1" 200 40484 ['name', 'currency', 'piTag'] Internal Server Error: /admin/aboveSites/country/add/ myApp | Traceback (most recent call last): .... Is it clear to anyone why get_fields in the shell works as expected, but not …