MarkusH / django-osm-field

http://markush.github.io/django-osm-field
MIT License
29 stars 12 forks source link

Add Django admin integration #3

Closed MarkusH closed 7 years ago

ghost commented 9 years ago

What i am doing for this atm:

class AppointmentsAdmin(admin.ModelAdmin):
    ...    
   # we need those for OSMField to work
    class Media:
        css = {
            'all': ('css/appointments.css',),
        }
        js = (
            'js/jquery-2.1.1.min.js',
        )

The inluded CSS file contains a fix to have the map push down the lat/lon fields below when it appears :

.field-location > div {
    position: relative;
    padding-bottom: 10px;
    min-height: 25px;
}

.field-location .osmfield-map {
    position: relative;
    left: 0px;
    top: 40px;
    width: 500px;
    margin-bottom: 30px;
}

.field-location input {
    position: absolute;
    left: 105px;
    top: 0px;
}

which i sussed out with @netAction a few weeks ago.

MarkusH commented 9 years ago

Do you want to open a pull request for this issue? The CSS code won't work though in a generic case. field-location might also be named field-poi or something.

keimlink commented 9 years ago

Maybe you want to have a look at django-geoposition which has this feature already, but for Google Maps.

int-ua commented 9 years ago

With django-grappelli field class is just .location.

I also changed js to

js = (
    'https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
)
int-ua commented 8 years ago

Update: fixed. It stopped working after upgrade to 0.3.0 and I can't understand why.

blag commented 8 years ago

@int-ua: Can you give me more information? Like copy/paste the files you use on your admin page, the HTML from your admin page, and anything else that might be relevant? I can't really help you without any additional information.

int-ua commented 7 years ago

Sorry, it was completely my fault, somehow I've defined widgets not in a Meta subclass of ModelForm but on itsefl and it had no effect. It's completely functional after fixing this error.

blag commented 7 years ago

@int-ua No worries, we all make mistakes. I'm glad you got it working again! 😄

blag commented 7 years ago

This seems to be working just fine for. I'm closing this unless somebody has a more specific issue.