2

I have one model "Inventario" like this:

class Inventario(models.Model):
    producto = models.ForeignKey(Producto)
    cantidad = models.DecimalField(default=0, decimal_places=2, max_digits=10)
    ubicacion = models.ForeignKey(Ubicacion, null=True, blank=True, related_name='en_inventario')
    epc = models.CharField(max_length=25)
    serial = models.CharField(max_length=35)
    fecha = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return '%s (%s)' % (self.producto.item, self.epc)

and registered in the admin.py like this:

from almacen.models import Inventario
admin.site.register(Inventario)

The List of Entries are shown in the Admin

enter image description here

But inside the details of one of that entries, nothing appears enter image description here

Even if I try to save and continue, an error is thrown enter image description here

What is happening? This error is affecting only this Model

1
  • What version of Django are you using? Commented Oct 8, 2015 at 18:32

1 Answer 1

2

You probably can't use the default admin.py. Turn on DEBUG and try something like this:

from django.contrib import admin
from almacen.models import Inventario

class InventarioAdmin(admin.ModelAdmin):
    readonly_fields = ['producto', 'fecha', 'ubicacion']

admin.site.register(Inventario, InventarioAdmin)

I suspect that something (the ForeignKey? the auto_now_add field?) isn't being well-handled by the default Admin. Try shrinking the number of fields available.

See also the ModelAdmin docs

Sign up to request clarification or add additional context in comments.

1 Comment

You were right, one of the Foreign Key fields were doing a mess, I had an error in the unicode of one of the ForeignKeyFields, the strange thing is that the DEBUG doesn't show anything. Thnks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.