I have the model set up as a binaryfield. The problem is I have no idea how 
to save the information to it. I can retrieve information from it easy 
enough but if I try and enter in new information, saved in the same format 
as that it returns

Here's what I have in model.py

class Users(models.Model):
    ....
    rfid = models.BinaryField(editable = True, unique=True, blank=True, 
null=True)
    ....

    def set_rfid(self,rfid_new):
        print self.rfid # print the existing object data
        try:
            self.rfid = bytearray(rfid_new)
            print self.rfid
        except Exception as ex:
            template = "An exception of type {0} occured. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            print message

It doesn't raise an exception but it also doesn't save it into the field. 
This is the print out (Standard PostgreSQL escape format):

E\xa343c5ea

E\x52577ade


Any help would be appreciated. 


Thanks,

Brian

On Wednesday, February 22, 2017 at 2:19:14 PM UTC-5, ludovic coues wrote:
>
> Can't you use django's BinaryField ? 
>
> 2017-02-22 20:09 GMT+01:00 Shawn Milochik <shawn...@gmail.com 
> <javascript:>>: 
> > Why not base64 encode it and just store it in a charfield? There doesn't 
> > seem to be any compelling reason to store it in binary. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com <javascript:>. 
> > To post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/CAOzwKwG9WD2g4nvjpnbA1Y%2BuKxLmShz%3D3woTAKG%2B3VvQroWs0g%40mail.gmail.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/df8f2577-d475-4584-b970-9dade08449a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to