Ray
Ray

Reputation: 21

Error saving custom model admin on Django

I am developing a web with Django 2.0 and I have a curious (and annoying) problem which didn't exist at development environment.

I am on myweb.com/admin, saving data and it has a ImageField and when I am saving Django tells me:

Page not found (404)
Request Method: POST
Request URL:    http://www.myweb.com/admin/about/about/add/

Raised by:  django.contrib.admin.options.add_view
Using the URLconf defined in myweb.urls, Django tried these URL patterns, in this order:
busqueda/
contacto/
sobre-mi/
admin/
[name='home']
<slug:categoria>/ [name='category']
<slug:category>/<slug:slug>/ [name='post']
^media\/(?P<path>.*)$
The current path, about/about/add/, didn't match any of these.

I have mentioned about ImageField because I had no problems with two models without this Field.

This is myproject/urls.py:

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
        path('busqueda/', include('search.urls')),
        path('contacto/', include('contact.urls')),
        path('sobre-mi/', include('about.urls')),
        path('admin/', admin.site.urls),
        path('', include('post.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

And about/urls.py:

from django.urls import path
from .views import AboutView

app_name = 'about'
urlpatterns = [
    path('', AboutView.as_view(), name='about-me'),
]

I am not able to resolve this by myself.

EDIT: about/admin.py

from django.contrib import admin
from .models import About

# Register your models here.
class AboutAdmin(admin.ModelAdmin):
    readonly_fields = ('created', 'updated')

    # Inyectamos nuestro fichero css
    class Media:
        css = {
            'all': ('core/css/custom_ckeditor.css',)
        }

admin.site.register(About, AboutAdmin)

EDIT 2: I've removed the image Field from the model and it was saved correct

Upvotes: 1

Views: 582

Answers (1)

Ray
Ray

Reputation: 21

Solved, the problem was the version of Python wich my company of hosting offered me. They only had python 3.4, but the version of Django needed, as less, python 3.5. I've tried in another enterprise and it works perfectly.

Upvotes: 1

Related Questions