Coder Social home page Coder Social logo

Comments (14)

aminalaee avatar aminalaee commented on July 22, 2024 1

Hey, thanks for reporting this.

I think maybe a better approach would be to use a Bootstrap DateTime picker and not depend on the browser supports? What do you think?

If you also would like feel free to make a PR for it.

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024 1

Even here it says it should be supported: caniuse.com/input-datetime

But it's the type="datetime-local" supported, not type="datetime":

image

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024 1

yeah I think it is deprecated, and as I checked the datetime-local is not fully supported, so we can change this to datetime-local and also add a UI library? But one should be enough.

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024 1

I noticed tabler use litepicker as date form picker, But๐Ÿ˜‘:

tabler/tabler#1136

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024 1

@ischaojie Can we still use litepicker and then switch to the new one when tabler switches?

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024

The reason is <input type="datetime"> still has almost no support in modern browsers, So It's better to use datetime-local:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local

Can we add DatetimeLocalField or some?

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024

BTW, what browser and what version are you using?

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024

BTW, what browser and what version are you using?

I using chrome 102.0.5005.61

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024

hmm.I'm using chrome 101.x.x and it's working alright. weird though.

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024

Weird, the code is like this:

class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True)
    name = Column(String)
    age = Column(Integer)
    created_at = Column(DateTime, default=datetime.now())


Base.metadata.create_all(engine)  # Create tables

app = FastAPI()
admin = Admin(app, engine)


class UserAdmin(ModelAdmin, model=User):
    column_list = [User.id, User.name, User.age]


admin.register_model(UserAdmin)

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024

Even here it says it should be supported: https://caniuse.com/input-datetime

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024

I change the code like this:

    @converts("DateTime")
    def conv_DateTime(
        self, model: type, prop: ColumnProperty, kwargs: Dict[str, Any]
    ) -> UnboundField:
        kwargs.setdefault("format", "%Y-%m-%dT%H:%M:%S")
        return DateTimeLocalField(**kwargs)

It's worked now:
image

I reading the Mozilla doc, Looks like type=datetime has been removed๏ผš

One thing the datetime-local input type doesn't provide is a way to set the time zone and/or locale of the date/time control. This was available in the datetime input type, but this type is now obsolete, having been removed from the spec.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#try_it:~:text=This%20was%20available%20in%20the%20datetime%20input%20type%2C%20but%20this%20type%20is%20now%20obsolete%2C%20having%20been%20removed%20from%20the%20spec

from sqladmin.

ischaojie avatar ischaojie commented on July 22, 2024

@ischaojie Can we still use litepicker and then switch to the new one when tabler switches?

litepicker didn't support choosing time, but new easepick supports it.

see: wakirin/Litepicker#1

Or use another lib. or wait for tabler to support it ๐Ÿ˜

from sqladmin.

aminalaee avatar aminalaee commented on July 22, 2024

Added flatpickr to handle Date and DateTimes: #288

from sqladmin.

Related Issues (20)

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.