<commit_before># -*- coding: utf-8 -*-
from django.contrib import admin
from .models import Photo


@admin.register(Photo)
class PhotoAdmin(admin.ModelAdmin):
    list_display = ('admin_thumbnail', 'title', 'file', 'taken_at', 'camera', 'lens',
                    'focal_length', 'exposure_time', 'aperture', 'iso')
    date_hierarchy = 'taken_at'
<commit_msg>fix: Make django admin default to current user<commit_after># -*- coding: utf-8 -*-
from django.contrib import admin
from .models import Photo


@admin.register(Photo)
class PhotoAdmin(admin.ModelAdmin):
    list_display = ('admin_thumbnail', 'title', 'file', 'taken_at', 'camera', 'lens',
                    'focal_length', 'exposure_time', 'aperture', 'iso')
    date_hierarchy = 'taken_at'

    def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        if db_field.name == 'user':
            kwargs['initial'] = request.user.id

        if not request.user.is_superuser:
            kwargs['disabled'] = True

        return super().formfield_for_foreignkey(db_field, request, **kwargs)

{'fraction_non_alphanumeric': 0.1435228331780056, 'fraction_numerical': 0.001863932898415657, 'mean_word_length': 3.6493506493506493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185439', 'n_tokens_mistral': 343, 'n_tokens_neox': 323, 'n_words': 80}