Skip to content

Modernize model fields: GenericIPAddressField and db_default=Now()#887

Merged
regulartim merged 1 commit intoGreedyBear-Project:developfrom
SupRaKoshti:feature/modernize-model-fields
Feb 26, 2026
Merged

Modernize model fields: GenericIPAddressField and db_default=Now()#887
regulartim merged 1 commit intoGreedyBear-Project:developfrom
SupRaKoshti:feature/modernize-model-fields

Conversation

@SupRaKoshti
Copy link
Copy Markdown
Contributor

Description

Modernized model fields in models.py as suggested in #863:

  • Replaced default=datetime.now with db_default=Now() for all DateTimeField fields, moving defaults to the database level and fixing naive datetime usage (Django 5.0+)
  • Replaced CharField with GenericIPAddressField for Sensor.address, TorExitNode.ip_address, and MassScanner.ip_address
  • Removed redundant blank=False and null=False declarations since False is already the default in Django
  • Updated tests in test_sensor_repository.py to remove redundant database filter assertions for invalid IPs since GenericIPAddressField enforces IP validation at the database level

Note: FireHolList.ip_address was intentionally kept as CharField since it stores both plain IPs and CIDR ranges (e.g. 1.2.3.4/24) which are incompatible with GenericIPAddressField.

Related issues

Closes #863

Type of change

  • New feature (non-breaking change which adds functionality).

Checklist

  • I have read and understood the rules about how to Contribute to this project.
  • The pull request is for the branch develop.
  • I have added documentation of the new features.
  • Linter (Ruff) gave 0 errors.
  • I have added tests for the feature/bug I solved. All the tests (new and old ones) gave 0 errors.
  • If changes were made to an existing model/serializer/view, the docs were updated and regenerated.

@SupRaKoshti
Copy link
Copy Markdown
Contributor Author

Hi @regulartim , I have completed all the changes as discussed. Could you please review the PR when you get a chance? Thank you!

Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for your work! :)

@regulartim regulartim merged commit 49c108a into GreedyBear-Project:develop Feb 26, 2026
4 checks passed
cclts pushed a commit to cclts/GreedyBear that referenced this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants