Giter VIP home page Giter VIP logo

django-composite-field's Introduction

Hi, I'm Michael and I love to write and share software with the world. I deeply believe in the FreeSoftware movement and contribute to projects whenever I can.

Open source projects

  • webwire – Contract-First API System
  • deadpool – Dead simple pool implementation for rust with async-await
  • deadqueue – Dead simple queue implementation for rust with async-await
  • tusker – PostgreSQL migration management tool

Links

django-composite-field's People

Contributors

bikeshedder avatar jakubste avatar johnnoone avatar mathiasertl avatar michaelkim0407 avatar nemesifier avatar noamkush avatar petrdlouhy avatar pmdarrow avatar thomaspinna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-composite-field's Issues

Add __gt__ comparison

Django's Field implements __eq__ and __lt__, which allows fields to be sorted.

CompositeField also implements __eq__ and __lt__.
However, this does not guarantee that a list containing Fields and CompositeFields can be sorted.
This is because Field.__lt__ is only aware of Field but not CompositeField, which means Field() < CompositeField() returns NotImplemented.
To fix this issue, CompositeField needs to tell Python how to do Field() < CompositeField() by implementing __gt__.

help_text (and other keyword arguments) missing

Hi, I try to create a simple CompositeField:

class PeriodField(CompositeField)
    start=models.DateTimeField()
    end=models.DateTimeField()

and use it somewhere...

class MyModel(models.Model):
    period = PeriodField(help_text="fooo")

And it prints an error:

    period = PeriodField(
TypeError: __init__() got an unexpected keyword argument 'help_text'

I saw in your Changelog, that you seemed to implement this at some point of time, is that gone again?

can't I add help_text etc. to a composite field, like blank/null?

Variable options for field inside CompositeField

I wanted to ask if there is some way how to pass options like verbose_name into the individual fields while using CompositeField.

Example usage:

class PrerenderedMarkdownxField(CompositeField):
    markdown = MarkdownxField()
    prerendered = TextField(null=True)

class TestModel(Model):
   markdown = PrerenderedMarkdownxField(markdown_verbose_name="Markdown Field")

Add poetry for packaging and release

This project should be converted to a poetry setup.
That would make it much easier to work on it and make releases.

The current solution is a Makefile so I don't forget the commands that need to be issued and the typical setup.py + setup.cfg mess.

Django 5 compatibility

Hey!

I'm trying to upgrade my project to Django 5 and I run into such an issue:

  File "/Users/jakubste/.virtualenvs/bdsm-S0d35qI4-py3.11/lib/python3.11/site-packages/django/db/models/base.py", line 511, in __init__
    if field.attname not in kwargs and field.column is None or field.generated:
                                                               ^^^^^^^^^^^^^^^
AttributeError: 'PartialDateField' object has no attribute 'generated'

PartialDateField is my class that uses CompositeField and it's quite simple:

class PartialDateField(CompositeField):
    year = models.IntegerField(null=True, blank=True)
    month = models.IntegerField(null=True, blank=True)
    day = models.IntegerField(null=True, blank=True)

Django 5 introduced generated fields and it looks like the fix is as easy as adding generated = False field in CompositeField.

Any chances for patching this? :)

Fix tests and improve CI testing

I used to run the tests with tox and a lot of python versions installed directly on my Ubuntu machine via the deadsnakes PPA. The current GitHub action works exactly like that.

This is not very future proof and it would be great if the tests were run in parallel with a matrix in the GitHub workflow file rather than running all tests as part of a single command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.