Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Calculate user input from form and display results - Django
I have a form to calculate the weight of a postal tray - the form works and when i submit it goes to the database. However, what I'd like to do now is take the information submitted in those fields and do some math to give the calculation they need. views.py @login_required def tray_calc_view(request): model = TrayCalcModel tray_form = TrayCalcForm() if request.method == "POST": tray_form = TrayCalcForm(request.POST) if tray_form.is_valid(): tray_form.save(commit=True) return redirect('tray_weight') return render(request, "tray_weight_calculator.html", {'tray_form': tray_form}) models.py class TrayCalcModel(models.Model): sheets = models.IntegerField(max_length=30) paper_weight = models.IntegerField(max_length=30) I'd like to submit the form and it take me to a new page with the filled in form and a box with the calculation in. I'd like to be able to update that form on this page and recalculate and it update that calculation. urls.py path('tray-weight-calculator/', tray_calc_view, name="tray_weight"), My form is at tray-weight-calculator/ and I'd like the calculated form to be at tray-weight-calculator/calculated-weight How would I need to set up my views.py to do this? -
How to use django social media icons instead of link_text
I am trying to use django-social-media share buttons. The share link comes with text instead of social media icons such as facebook, linkedin and twitter. How can i display the icons instead of "Post to FaceBook" text link? <a href="#!"> <span class="fa-stack fa-lg"> <i class="fas fa-circle fa-stack-2x" style="color:#4267B2"></i> <i class="fab fa-facebook-f fa-stack-1x fa-inverse"></i>{% post_to_facebook object_or_url %} </span> </a> <a href="{{ linkedin_url }}"> <span class="fa-stack fa-lg"> <i class="fas fa-circle fa-stack-2x" style="color: #0e76a8"></i> <i class="fab fa-linkedin fa-stack-1x fa-inverse"></i>{% post_to_linkedin object_or_url %} </span> </a> <a href="#!"> <span class="fa-stack fa-lg"> <i class="fas fa-circle fa-stack-2x" style="color: #1DA1F2"></i> <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>{% post_to_twitter "New Article: {{object.title}}. Check it out!" object_or_url %} </span> </a> -
Django: Encryption for Data at Rest?
I am using Django and am trying to encrypt data at rest in my database which is making use of Django Models. What would be the best way of going about this? I am aware that there are several libraries for encryption in Django. But, I'm a little spoilt for choice and need some recommendations. Thanks in advance. -
Values Not Appending In List As Expected
test={ "licenceFile": "", "pfxFilePath": "", "pfxPassword": "", "pfxAlias": "fin", "inputs": [ { "docBase64" :"RjJVBERi0xLjMNCiX", "signedBy": "Hasan حسن.", "location": "Location", "reason": "Reason", "appearanceRunDirection": "RUN_DIRECTION_LTR", "coSign": 'true', "pageTobeSigned": "Specify", "coordinates": "BottomLeft", "pageNumbers": "1", "pageLevelCoordinates": "", "appearanceBackgroundImage": "", "appearanceType": "", "type": "PDF" } ], "signerInfo": { "rkaName": "", "kycId": "20476", "englishName": "Hasan", "arabicName": "", "mobile": "", "email": "", "address": "", "regionProvince": "", "country": "SA", "photoBase64": "" }, "SIPID": "", "logLevel": "NoLog", "tempFolderPath": "Temp", "sipIsRka": 'true', "userConsentObtained": 'true', "kYCIdProvider": "SELF_NID", "requestTimeout": 0, "proxyPort": 0, "eSignURL": "" } test2= ['hashi','jayesh','midhu'] inp= test['inputs'] inp2=[] for i in range(len(test2)): for j in test['inputs']: inp2.append(j) for i in inp2: i['docBase64'] = test2[0] test2.pop(0) print(i['docBase64']) if not test2: print(inp2) print(inp2) I'm Getting an output as [{'docBase64': 'midhu', 'signedBy': 'Hasan حسن.', 'location': 'Location', 'reason': 'Reason', 'appearanceRunDirection': 'RUN_DIRECTION_LTR', 'coSign': 'true', 'pageTobeSigned': 'Specify', 'coordinates': 'BottomLeft', 'pageNumbers': '1', 'pageLevelCoordinates': '', 'appearanceBackgroundImage': '', 'appearanceType': 'EMDHA_LOGO', 'type': 'PDF'}, {'docBase64': 'midhu', 'signedBy': 'Hasan حسن.', 'location': 'Location', 'reason': 'Reason', 'appearanceRunDirection': 'RUN_DIRECTION_LTR', 'coSign': 'true', 'pageTobeSigned': 'Specify', 'coordinates': 'BottomLeft', 'pageNumbers': '1', 'pageLevelCoordinates': '', 'appearanceBackgroundImage': '', 'appearanceType': 'EMDHA_LOGO', 'type': 'PDF'}, {'docBase64': 'midhu', 'signedBy': 'Hasan حسن.', 'location': 'Location', 'reason': 'Reason', 'appearanceRunDirection': 'RUN_DIRECTION_LTR', 'coSign': 'true', 'pageTobeSigned': 'Specify', 'coordinates': 'BottomLeft', 'pageNumbers': '1', 'pageLevelCoordinates': '', 'appearanceBackgroundImage': '', 'appearanceType': 'EMDHA_LOGO', 'type': 'PDF'}] But Im expecting … -
Django REST get query with symmetric fields
The idea is that, given two hashes, I should return the comparison number between them. These two hashes uniquely identify a database entry and the comparison is symmetric. I have the following model: models.py class Comparison(models.Model): result = models.FloatField() hash1 = models.CharField(max_length=100) hash2 = models.CharField(max_length=100) class Meta: constraints=[ models.UniqueConstraint(fields=['hash1','hash2'], name='compared') ] serializers.py class ComparisonSerializer(serializers.ModelSerializer): class Meta: model = Comparison # exclude = [''] fields = '__all__' views.py class ComparisonView(viewsets.ModelViewSet): serializer_class = ComparisonSerializer queryset = Comparison.objects.all() def get_queryset(self): h1 = self.request.query_params.get("hash1") h2 = self.request.query_params.get("hash2") try: return self.queryset.filter(hash1=h1, hash2=h2) except Comparison.DoesNotExist: try: return self.queryset.filter(hash1=h2, hash2=h1) except Comparison.DoesNotExist: return None Which works, but is clunky since the overridden method get_queryset tries searching for the data one way around and if it doesn't find anything, tries the other direction. This is necessary since I only store one entry per comparison in order to save space, for instance, hash1 = ab5d..., hash2= ef3h..., result=0.4 and not hash1 = ef3h..., hash2= ab5d..., result=0.4. Is there any way to make a query that is more "symmetric"? Finally, one other small annoyance is that ideally I want to return a single object, while currently filter returns a list containing a single object for a unique hash pair. Replacing … -
How to Deploy Multiple Django Apps on Single server using Ngnix & GUnicorn?
I am trying to Deploy Two Django apps with single AWS EC2 Instance having same IP. But it always failed when I have added the second App.sock and test Supervisor. I fond some body asked similar question before. but Not answered properly, and my use case is little different. ( Run multiple django project with nginx and gunicorn ) I have followed these steps: . Cloned my project from Git * pip install -r requiernments.txt pip3 install gunicorn sudo apt-get install nginx -y sudo apt-get install supervisor -y cd /etc/supervisor/conf.d sudo touch testapp2.conf sudo nano testapp2.conf Updated config file same as below [program:gunicorn] directory=/home/ubuntu/projects/testapp2/testerapp command=/home/ubuntu/projects/testapp2/venv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/projects/testapp2/testerapp/app.sock testerapp.wsgi:application autostart=true autorestart=true stderr_logfile=/home/ubuntu/projects/testapp2/log/gunicorn.err.log stdout_logfile=/home/ubuntu/projects/testapp2/log/gunicorn.out.log [group:guni] programs:gunicorn *---------- sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl status The below steps will work and Site available on browser if there is only One configuration above. But when i have added an additional configuration, it shows 502 Bad Gateway on the Browser. Please help me to solve this issue. -
Creating websocket connections from Django
I’m using Django (ASGI) with channels to handle websocket connections from IoT devices. I also have a task runner in the background to handle periodic and expensive tasks. Devices connect to certain WSS endpoints. The devices lose connection from time to time but usually reconnect. I now have a situation where I need to create websocket connections to a server that acts as a proxy for other IoT devices. I will be the one initiating the connection and ensuring that it remains open. Django is based on request/response. My question is about how to handle this new requirement - with Django or some other approach. I could create a background task that opens and monitor connections for these devices. I could create a separate service that monitors and maintains connections. What is a robust approach considering the stack is Django and the data from these devices will ultimately be used in Django. -
crontab fails to write logs
I'm using crontab to run a python script every minute. This is my how my crontab file looks like: */1 * * * * source /root/.bashrc && source /home/env/bin/activate && python /home/manage.py shell < /home/script.py >> /var/log/navjob.log 2>&1 When try to check cron output in syslog with this command #grep CRON /var/log/syslog the output is like this: ...CRON[764888]: (root) CMD (source /root/.bashrc && source /home/env/bin/activate && python /home/manage.py shell < /home/script.py >> /var/log/navjob.log 2>&1) ...CRON[764887]: (CRON) info (No MTA installed, discarding output) But the log file (/var/log/navjob.log) is empty and the code is not run! -
field is required DRF
serializers.py class UserRegisterSerializer(serializers.ModelSerializer): password1 = serializers.CharField(write_only=True, style={'input_type': 'password', 'placeholder': 'Password'}) password2 = serializers.CharField(write_only=True, style={'input_type': 'password', 'placeholder': 'Password confirm'}) is_superuser = serializers.BooleanField(default=True,read_only=True) class Meta: model = User fields = ['username','email','is_superuser','first_name','last_name','password1','password2'] def create(self,validated_data): user = User( username = validated_data.get('username'), email = validated_data.get('email'), first_name = validated_data.get('first_name'), last_name = validated_data.get('last_name') ) password1 = validated_data.get('password1') password2 = validated_data.get('password2') if password1 !=password2: raise serializers.ValidationError({'password2':'عدم همخوانی گذرواژه'}) user.set_password(password1) user.save() Token.objects.create(user=user) return user views.py class UserRegister(generics.CreateAPIView): serializer_class = UserRegisterSerializer queryset = User.objects.all() my error this is my error when I wanna register new user... plz help me to solve it........................ -
html field returning none via POST request (Django)
On submitting password field is showing none while as confirm password is working fine, don't know where I am wrong in this, tried changing name attribute doesn't work Thanks in advance! <div class="form-row"> <div class="form-group col-md-6"> <label>Create password</label> <input name="password" class="form-control" type="password"> </div> <!-- form-group end.// --> <div class="form-group col-md-6"> <label>Repeat password</label> <input name="confirm_password" class="form-control" type="password"> </div> <!-- form-group end.// --> </div> my view @csrf_exempt def register(request): city = City.objects.all() if request.method== 'POST': first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') email = request.POST.get('email') print(email) gender = request.POST.get('gender') city = request.POST.get('city') country = request.POST.get('country') print(country) password = request.POST.get('password') <-- this returns None conf_password = request.POST.get('confirm_password') contact_no = request.POST.get('mob_number') print(conf_password,password) if password != conf_password: messages.add_message(request,messages.ERROR,'passwords does not match kindl re-enter') return redirect('/register') else: username = email.split('@')[0] print(username) user= User(username=username,first_name=first_name,last_name=last_name,email=email) user.set_password(password) user.save() customer=Customers(user=user,contact_no=contact_no,city=city,gender=gender) customer.save() return redirect('/') return render(request,'register.html',{ 'city':city } ) -
how to pass if else statement in django db for fetching model in django
i create model name item in that some of them field can be empty some of them not so what i want to render is the model field is empty then pass and go look for another and if it has some value render without throwing error right now it will throw if request a null field so how can i fix it is there any way to do that my models.py class Item(models.Model): categories = models.ForeignKey(Categories, on_delete=models.CASCADE, related_name='our_items') subcategories = models.ForeignKey(Subcategories, on_delete=models.CASCADE, related_name='products') can_buy = models.ForeignKey(For, on_delete=models.CASCADE, related_name='for_wearing') name = models.CharField(max_length=200, blank=False) contain_size = models.CharField(max_length=50, blank=True) brand_name = models.CharField(max_length=100, blank=False, default='Bagh') first = models.ImageField(upload_to='items', blank=False) second = models.ImageField(upload_to='items', blank=False) third = models.ImageField(upload_to='items', blank=False) fourth = models.ImageField(upload_to='items', blank=False) fifth = models.ImageField(upload_to='items', blank=True) rating = models.FloatField(blank=False,default='4.0') item_vedio = models.FileField(upload_to='item_vedio', blank=True) color = models.CharField(max_length=30, blank=False, default='Black') material = models.CharField(max_length=50, blank=False, default='Plastic' ) return_policy = models.CharField(max_length=100, blank=False, default='7Days Return Policy') stock = models.CharField(max_length=50, blank=False, default='In Stock') price = models.FloatField(blank=False,) actual_price = models.FloatField(blank=False) about_one = models.CharField(blank=False, max_length=100, default='washable') about_two = models.CharField(blank=False,max_length=100, default='Lusturous') offer = models.CharField(max_length=4, blank=True) joined_date = models.DateTimeField(default=timezone.now,editable=False) update_at = models.DateTimeField(auto_now=True) def __str__(self): return self.name my views.py class Product_detail(View): def get(self, request, item_id): item = Item.objects.filter(id=item_id) category_list = Categories.objects.all() print(item) return render (request, … -
Run a function after django server has started
I want to run a function after django server has started. Now, that function should run after all the views and URLs are initialized because the function might make requests to one of the registered routes. -
Set initial value in django model form
I want to set initial data in model form, how can i do that? I've been looking for an answer but mostly the answer is using initial or instance in view. Is there a way so we can initialize form field in model form? views.py def create_order(request, *args, **kwargs): # move this thing into model form initial_data = { 'user': request.user.username, 'products': Product.objects.get(pk=kwargs['pk']) } form = CreateOrderForm(request.POST or None, initial=initial_data) if form.is_valid(): form.save() return redirect('homepage') return render(request, "orders/create_order.html", {"form": form}) forms.py class CreateOrderForm(forms.ModelForm): # How to initialize value in this model form? class Meta: model = Order fields = ['user', 'products', 'quantity', 'address', 'total_price'] widgets = { # Make user fields disabled 'user': forms.TextInput(attrs={'disabled': True}), } Thank you. -
How to shuffle/randomize list items after regrouping them using Django's regroup template tag
I have this list presented in dictionaries: cities = [ {'name': 'Mumbai', 'population': '19,000,000', 'country': 'India'}, {'name': 'Calcutta', 'population': '15,000,000', 'country': 'India'}, {'name': 'New York', 'population': '20,000,000', 'country': 'USA'}, {'name': 'Chicago', 'population': '7,000,000', 'country': 'USA'}, {'name': 'Tokyo', 'population': '33,000,000', 'country': 'Japan'}, ] I have regrouped the list using Django's regroup tag: {% regroup cities by country as country_list %} <ul> {% for country in country_list %} <li>{{ country.grouper }} <ul> {% for city in country.list %} <li>{{ city.name }}: {{ city.population }}</li> {% endfor %} </ul> </li> {% endfor %} </ul> This is the template output: India Mumbai: 19,000,000 Calcutta: 15,000,000 USA New York: 20,000,000 Chicago: 7,000,000 Japan Tokyo: 33,000,000 That is pretty much of what I intended to do. I now want to randomly shuffle items under each country list. For example, under USA, I want to shuffle New York and Chicago so that the display is not biased to the viewer. When I use shuffle(cities) in my views, I get an output like this: India Mumbai: 19,000,000 USA New York: 20,000,000 India Calcutta: 15,000,000 USA Chicago: 7,000,000 Japan Tokyo: 33,000,000 I basically want to shuffle cities while remaining intact under their countries. I dont want the position of … -
Chnaging the DATABASE_URL in heroku
So i tried to deploy my django app to heroku and used the heroku postgres as the database. But the problem was that i have to use postgis and to do that, we need to change the postgres to postgis in the DATABASE_URL. But in heroku we cannot change it as it gives the error; attachment values cannot be changed. So i came up with a solution. I removed the heroku-postgres from my main app and create another app, created heroku-postgres there and then took the url of that other app and used that as the value of DATABASE_URL in my main app. Now i can easily update that as that is not attached with my main app and that worked perfectly. Now the problem is that, is it necessary to have db attached because heroku says; Please note that these credentials are not permanent. Heroku rotates credentials periodically and updates applications where this database is attached. Credentials mentioned above are the database credentials. So if the creds change, my app will not work but i cannot attach the db with my main app, as the url will be stored as a new env variable which will be of no … -
Django ORM for sum with group by
I have a database table consisting of scores for students on individual courses they took over the years. And I am trying to get the sum of scores for each student. How can I achieve this using Django ORM? The query that I used is qs = Enrollment.objects.filter( semester__gte=start, semester__lte=last, course__teacher__teacher=request.user ).values('student_id').annotate(total=Sum('score')) And the result produced is like this id student_id course_id semester score grade status comments total 0 2 2 1 1 87 B Passed 87 1 3 2 3 1 97 A Passed 97 2 6 8 1 1 84 B Passed 84 3 7 8 3 1 65 D Passed 65 4 9 7 3 1 88 B Passed 88 5 11 7 1 1 79 C Passed 79 From this, how can I derive this? student_id total 2 184 8 149 7 167 -
Django Channels ValueError: No route found for path
I follow this tutorial to build a chat system https://channels.readthedocs.io/en/stable/tutorial/part_1.html It works fine when the room name is a string without white spaces, say "Room1". WebSocket HANDSHAKING /ws/chat/Room1/ WebSocket CONNECT /ws/chat/Room1/ However, when I change the room name to "Room 1", it results in WebSocket HANDSHAKING /ws/chat/Room%201/ [127.0.0.1:59947] Exception inside application: No route found for path 'ws/chat/Room 1/'. ValueError: No route found for path 'ws/chat/Room 1/'. I have tried to change the roomname by replacing the white space with "%20" in the HTML, routing.py and consumers.py. None of them works. How can I solve this problem? -
Djnago:How to generate a pdf file
i want to generate a pdf file containing the OCR result of an uploaded image, but i can't seem to figure out how. when i store the result in a txt file it works but every pdf i create is corrupted. i used FPDF to create the pdf but it's not working. if self.id : #this here to see if there is an image upload in order to generate the file c=''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(10)) file=(ContentFile(Create_Pdf(self.image),name='file.pdf')) pdf = FPDF(format="A4") pdf.add_page() pdf.set_font("Arial", size=12) for x in file.readlines(): pdf.cell(0,7, txt=x, ln=1) res=pdf.output("Data.pdf") File.objects.create( file=(ContentFile(res,name='file.pdf') )) -
Can I develop live video streaming website using django?
If yes then what should I need to know before starting, please specify I'm trying to build a Live video and text Streaming Application (Web & Mobile) Through my search, I found the Gevent-socketio library, but it is old and I did not find a suitable explanation to start with -
How to include images kept in static folder in JavaScript as variables in Django
how to do the image part here I'm getting my data from a JSON data list. I can't figure out how to include those image sources from the data inside the JavaScript ${variable} notation like others variables as shown in the figure. The images are kept in the static folder -
How to use an email URL with a password which contains slash character of `/`
For a Django app, I'm trying to set environment variable EMAIL_URL to smtp://username:password@email-smtp.us-east-1.amazonaws.com:587/?tls=True where password contains slash character of /. Amazon SES is giving me a password which contains / character for some reason. For example: export EMAIL_URL="smtp://AKIAYZT73XCKGD:BFB6UvkMgn9dniEGQZc/xM/KDS9Agc/S2@email-smtp.us-east-2.amazonaws.com:587/?tls=True" And then running: python3.9 manage.py runserver But I'm receiving an error: ValueError: Port could not be cast to integer value as 'BFB6UvkMgn9dniEGQZc' Error is thrown at this file: myapp-venv/lib/python3.9/site-packages/dj_email_url.py At 'EMAIL_PORT': url.port, statement of this function: def parse(url): """Parses an email URL.""" conf = {} url = urllib.parse.urlparse(url) qs = urllib.parse.parse_qs(url.query) # Remove query strings path = url.path[1:] path = path.split('?', 2)[0] # Update with environment configuration conf.update({ 'EMAIL_FILE_PATH': path, 'EMAIL_HOST_USER': unquote(url.username), 'EMAIL_HOST_PASSWORD': unquote(url.password), 'EMAIL_HOST': url.hostname, 'EMAIL_PORT': url.port, 'EMAIL_USE_SSL': False, 'EMAIL_USE_TLS': False, }) if url.scheme in SCHEMES: conf['EMAIL_BACKEND'] = SCHEMES[url.scheme] # ... return conf Tried I tried to escape the / with \ but it didn't work! -
Django receives incomplete POST data
I am posting json-formatted data to the backend written with Django 3.1.2. However, the data does not seem to received correctly. js code: var httpRequest = new XMLHttpRequest(); httpRequest.open("POST", "http://" + window.location.host + "/upload/", true); httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); httpRequest.send(encodeURI("data=" + json); httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4 && httpRequest.status == 200) { console.log("Done!"); } Django: data = request.POST.get('data') f = open('data.txt', 'w+') f.write(data) f.close() The data written in the file is incomplete. Nor is it complete when I try to print it. What might be the problem? Is it because the json string I post is too long? -
Django Rest Framework: Disable save in update
It is my first question here, after reading the similar questions I did not find what I need, thanks for your help. I am creating a fairly simple API but I want to use best practices at the security level. Requirement: There is a table in SQL Server with +5 million records that I should ONLY allow READ (all fields) and UPDATE (one field). This is so that a data scientist consumes data from this table and through a predictive model (I think) can assign a value to each record. For this I mainly need 2 things: That only one field is updated despite sending all the fields of the table in the Json (I think I have achieved it with my serializer). And, where I have problems, is in disabling the creation of new records when updating one that does not exist. I am using an UpdateAPIView to allow trying to allow a bulk update using a json like this (subrrogate_key is in my table and I use lookup_field to: [ { "subrrogate_key": "A1", "class": "A" }, { "subrrogate_key": "A2", "class": "B" }, { "subrrogate_key": "A3", "class": "C" }, ] When using the partial_update methods use update and this … -
Get ids of many to many table
in django if there's table with many to many field like that : class Category(models.Model): name = models.CharField(unique=True, max_length=255) icon = models.ImageField(upload_to='images') sport = models.ManyToManyField(Sport) when you try to get all objects from this table you do this : Category.objects.all() and the result will be like that after serializing : "data": [ { "id": 1, "name": '..' "icon": '...' "sport": [ 1, 2 ] ] } so my question here how to achieve the same result using pure sql I tried this : sql = '''select a.*,b.sport_id,array_agg(b.sport_id) as sport from category a join category_sport b on b.category_id=a.id group by a.id,b.sport_id ;''' but the result was like that : "data": [ { "id": 1, "name": '..' "icon": '...' "sport": [ 1, ] }, { "id": 1, "name": '..' "icon": '...' "sport": [ 2 ] ] } -
every-time i use .update(release_time=initial_time) i get an error 'int' object is not iterable but if i changed it to .all() it work out just fine
here is my code : def release_it(request, id): if request.method == "POST": x = Lap.objects.get(pk=id) x.released = True p = request.POST["release_time"] initial_time = datetime.strptime(p, '%Y-%m-%dT%H:%M') x.release_time = initial_time x.save() load = Loaded.objects.filter(lap=id).update(release_time=initial_time) for l in load: l.save() return render(request, "race/index.html", { "message":"released!", "x":x, "load":load }) return render(request, "race/index.html", { "message":"released!" }) i get this error File "/Volumes/John HDD/Visual Studio Code /CS50-web-Programming-with-Python-and-JavaScript/Project/pigeon_race/race/views.py", line 27, in release_it for l in load: TypeError: 'int' object is not iterable but when i replace load = Loaded.objects.filter(lap=id).all(). it work just fine here is my model class Loaded(models.Model): race_id = models.CharField(max_length=64) lap = models.CharField(max_length=64) lap_name = models.CharField(max_length=64) pigeon_id = models.CharField(max_length=65) pigeon_name = models.CharField(max_length=64) pigeon_ring = models.CharField(max_length=64, blank=True) pigeon_hcode = models.CharField(blank=True, max_length=64) release_time = models.CharField(blank=True, max_length=64) clock_time = models.CharField(blank=True, max_length=64)