Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set application default language #2206

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Generated by Django 4.2.15 on 2025-01-20 06:59

import application.models.api_key_model
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('application', '0023_application_stt_autosend'),
]
Expand All @@ -14,6 +12,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='applicationaccesstoken',
name='language',
field=models.CharField(default=application.models.api_key_model.get_language, max_length=10, verbose_name='语言'),
field=models.CharField(default=None, max_length=10, null=True, verbose_name='语言')
),
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no major issues with this code, but here's some minor feedback:

  1. default=None and null=True: The use of None and null=True for the language field means that it can be left blank when creating a new instance of ApplicationAccessToken. This might not be desired behavior if you always want to have a value set.

  2. Redundancy: You're calling application.models.api_key_model.get_language twice within different contexts—once directly on a model class ('models.CharField(...)), and once through an import statement (from application.models.api_key_model ...). If get_language is called elsewhere in your code, consider moving its implementation into a more central location or defining it only once at the top of your migration file.

  3. Consistency with other fields: Ensure consistency between optional attributes like null=True across all columns where it makes sense, especially those that store strings.

Overall, the migration looks clean and functional based on the current state.

This file was deleted.