Error in Django Admin When I try to add.

18 views
Skip to first unread message

Dharwin Perez

unread,
Jan 21, 2014, 4:50:14 PM1/21/14
to django...@googlegroups.com
I was trying to make a API Dispatcher, but when i try to add anything in Django Admin, run APIdispatcher and return Bad Request. I think that is some in the URL because when i comment those line, Django Admin works correctly.

urls.py

url(r'^(?P<version>.*)/(?P<table>.*)/(?P<secret_key>.*)/(?P<mac_address>.*)/$', 'People.views.APIdispatcher', name='API_dispatcher')

views.py

@csrf_exempt
def APIdispatcher(request,version,table,secret_key,mac_address):
# Verificamos que sea una peticion POST
if request.method == 'POST':

if _version == 'V0.9' or _version == 'v0.9':
apiV09()
elif _version == 'V1.0' or _version == 'v1.0':
apiV10( )
        return HttpResponse(status=200)

else:
return HttpResponseBadRequest()
else:
return HttpResponseBadRequest()
admin.py

admin.site.register(Application)

models.py

class Application(models.Model):

    application_id = models.AutoField(
        primary_key = True )

    name = models.CharField(
        max_length = 200,
        blank = False,
        null = False,
        unique      = True )

    secret_key = models.CharField(
        max_length = 150,
        blank = True,
        null = True,
        unique      = True )


    creation_date    = models.DateField( auto_now_add = True )
    creation_ts = models.DateTimeField( auto_now_add = True )
    modification_date = models.DateField( auto_now = True )
    modification_ts = models.DateTimeField( auto_now = True )
    status              = models.CharField(
        max_length  = 20,
        choices     = (
            ('1','ACTIVA'),
            ('2','SUSPENDIDA'),
            ('3','MANTENIMIENTO'),
            ('4','ELIMINADA')
        ),
        default     = '1'
    ) 
 
class Meta:
        db_table = 'Applications'
        verbose_name = 'Application'
        verbose_name_plural = 'Applications'

    def __unicode__(self):
        return self.name
 

Jonathan Pentecost

unread,
Jan 22, 2014, 3:52:26 PM1/22/14
to django...@googlegroups.com
Is your "API_dispatcher" url before or after the admin url?
Reply all
Reply to author
Forward
0 new messages