Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can a MERN stack developer pentest a website using django or java in its backend?
Lets say there is a professional MERN stack developer who knows pentesting too. Can he hack a website which uses django or java in its backend using his general understanding of website working ? Or should he learn python or java to understand it and hack it ? -
Nginx Bad Request (400) using upstream server in proxy_pass
I am really confused... On IP4 123.456.789.123 I have a django app running. On my local computer I create a simple nginx image with docker: FROM nginx COPY default.conf /etc/nginx/conf.d/default.conf and run it. In default.conf I use: server { listen 80; location /api { proxy_pass http://123.456.789.123; } } This version works just fine. Entering 127.0.0.1/api will lead me to my django app online.. But using: upstream djangpapp { server 123.456.789.123; } server { listen 80; location /api { proxy_pass http://djangpapp; } } will give me a bad request 400. I dont understand why. this: proxy_set_header Host $http_host; does not work, even thou it seem'd to be the solution for some people.. it even gives me a 400 in the otherwise working 1st version. -
users to own ther data in django
i want users to own their data but this is the error i keep getting " Cannot resolve keyword 'merchant' into field. Choices are: date_added, id, order, order_id, product, product_id, quantity" models.py class Merchant(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE, primary_key=True) class Product(models.Model): merchant=models.ForeignKey(Merchant, on_delete=models.CASCADE) class OrderItem(models.Model): product=models.ForeignKey(Product, on_delete=models.SET_NULL, null=True) views.py def users_homepage(request): itemsordered=OrderItem.objects.filter(merchant=request.user.merchant).order_by('date_added') thanks beforehand. -
Create Django model at runtime for testing purposes
The idea is to be able to write tests for my abstract models, since they cannot be instantiated or mapped to a table on the (test) database. I'm trying to create the table dynamically from a model, ideally enclosed in a with block. To do that, I dynamically create a model that inherits from the abstract model and execute the SQL to create the associated table (on __enter__), and delete the table when I'm done (on __exit__). I've tried several options: This, which fails with the error AttributeError: 'DatabaseCreation' object has no attribute 'sql_create_model'. It appears that sql_create_model is probably from an older version of Django. Doesn't look viable. This, which fails with the error django.db.utils.NotSupportedError: SQLite schema editor cannot be used while foreign key constraint checks are enabled. Make sure to disable them before entering a transaction.atomic() context because SQLite does not support disabling them in the middle of a multi-statement transaction. It actually looks like a valid solution, but fails with SQLite3. As you can see here, the implementation is trying to disable constraint checking, but failing, for some reason. This option appears as if it could be viable if I could figure out why disabling constraints checking … -
How to access data across M2M tables in Django?
What is the 'best practice' way of accessing data across a 1 (or more) many-to-many tables? This is incredibly difficult for me as I am not sure what I shuld be googling/looking up. I have attached a diagram of my data model. I am able to query data for 'C' related ot a user, by utilizing serializers. there has to be a simpler way of doing this (I'm hoping). Doing it with serializers seems incredibly limiting. I'd like to access a user's 'B' and 'C' and transform the object to only have a custom structure and possible unique values. Any direction is much appreciated. Pretty new to Django, so I apologize for this newb type of question. -
AttributeError: 'list' object has no attribute 'all' when connecting my model to admin
Getting an 'list' object has no attribute all error based on my function in my admin class. def get_stocks(self, obj): return "\n".join([s.stock_list for s in obj.stock_list.all()]) The error seems very trivial, in fact I know what the problem is, but I don't get why Im getting the error for this specific function and not the one above, aka def get_users() Here is my admin.py file @admin.register(models.Bucket) class BucketAdmin(admin.ModelAdmin): list_display = ('id','owner','category', 'get_users', 'name', 'created', 'slug','stock_count','get_stocks', 'about') prepopulated_fields = {'slug': ('name',), } def get_users(self, obj): return "\n".join([u.user_name for u in obj.users.all()]) print(u) def get_stocks(self, obj): return "\n".join([s.stock_list for s in obj.stock_list.all()]) Here is the model in question class Bucket(models.Model): options = ( ('personal', 'Personal'), ('social', 'Social'), ) class BucketObjects(models.Manager): def get_queryset(self): return super().get_queryset().filter(Bucket.owner) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='buckets') users = models.ManyToManyField(settings.AUTH_USER_MODEL) category = models.CharField(max_length=30, choices=options) name = models.CharField(max_length=35) created = models.DateTimeField(default=timezone.now) slug = models.SlugField(unique=True, blank=True, null=True) stock_count = models.IntegerField(blank=True, null=True) stock_list = ArrayField(models.CharField(max_length=6,null=True),size=30,null=True) about = models.CharField(max_length=75) objects = models.Manager() bucketobjects = BucketObjects() class Meta: ordering = ('-created',) def total_stocks_calc(self): self.stock_count = Bucket.objects.aggregate(Sum('stock_list', distinct=True)) self.save() def get_absolute_url(self): return reverse("bucket:bucket-view", kwargs={"slug": self.slug}) def __unicode__(self): return self.stock_list Full TraceBack: File "/home/andres/stockbuckets.io/venv/lib/python3.8/site-packages/django/db/models/options.py", line 575, in get_field return self.fields_map[field_name] KeyError: 'get_stocks' During handling of the above … -
ModuleNotFoundError: No module named 'jinja2' during deployment of django project on heroku
Well Here I am trying to deploy my first django app and getting error :ModuleNotFoundError: No module named 'jinja2'. I don't know where jinja came from. In my requirement file there is no jinja. Tell me if you know how to fix it. I shall be very thankful to you. trackback: remote: -----> $ python manage.py collectstatic --noinput remote: Traceback (most recent call last): remote: File "manage.py", line 21, in <module> remote: main() remote: File "manage.py", line 17, in main remote: execute_from_command_line(sys.argv) remote: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line remote: utility.execute() remote: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute remote: django.setup() remote: File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup remote: apps.populate(settings.INSTALLED_APPS) remote: File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate remote: app_config = AppConfig.create(entry) remote: File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/config.py", line 90, in create remote: module = import_module(entry) remote: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module remote: return _bootstrap._gcd_import(name[level:], package, level) remote: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import remote: File "<frozen importlib._bootstrap>", line 991, in _find_and_load remote: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked remote: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked remote: File "<frozen importlib._bootstrap_external>", line 783, in exec_module remote: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed remote: File "/app/.heroku/python/lib/python3.8/site-packages/knox/__init__.py", line 2, in <module> remote: from … -
Model doesn't show up in admin
I am currently working on a science django blog. I've finished coding it all and I realized that the models items overview and content don't appear in my django.admin. Here's an image so you can see. I know there are other threads related to it. However, I couldn't find the solution in those. Models.py: class Post(models.Model): title = models.CharField(max_length=100) overview = models.TextField() timestamp = models.DateTimeField(auto_now_add=True) content = HTMLField() author = models.ForeignKey(Author, on_delete=models.CASCADE) thumbnail = models.ImageField() categories = models.ManyToManyField(Category) featured = models.BooleanField() previous_post = models.ForeignKey( 'self', related_name='previous', on_delete=models.SET_NULL, blank=True, null=True) next_post = models.ForeignKey( 'self', related_name='next', on_delete=models.SET_NULL, blank=True, null=True) Admin.py: from django.contrib import admin from .models import Author, Category, Post, Comment, PostView # Register your models here. admin.site.register(Author) admin.site.register(Category) admin.site.register(Post) admin.site.register(Comment) admin.site.register(PostView) Settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'crispy_forms', 'tinymce', 'marketing', 'posts' ] And urls.py: urlpatterns = [ path('admin/', admin.site.urls), By the way, the models.py is in the app Posts. Just in case somebody needs this information. -
Getting a foreign key value to edit a post
I have got 2 tables in my models: class Post(models.Model): title = models.CharField(max_length=100) content = HTMLField() class PostImage(models.Model): post = models.ForeignKey(Post, default=None, on_delete=models.CASCADE) image = models.FileField(upload_to = 'post') What I am trying to do is display information about the post, including the images to be able to edit them. Here's my views: def edit_post(request, pk): post = get_object_or_404(Post, pk=pk) if request.method == "POST": form = PostForm(request.POST, instance=post) form2 = ImageForm(request.POST, instance=?) try: if form.is_valid(): form.save() messages.success(request, 'Ok') except Exception as e: messages.warning(request, "No") else: form = PostForm(instance=post) form2 = ImageForm(request.POST, instance=?) context = { 'form':form, 'post': post, } return render(request, "update.html", context) What would be my instance to populate the ImageForm? I have tried: image = get_object_or_404(ImagePost, pk=pk) form2 = ImageForm(request.POST, instance=image) But I was getting this error: No PostImage matches the given query. -
Having problems dockerizing my django project
I am following along in the Django for Professionals book and I am stuck at the first chapter where you create a django project and app using pipenv and then Dockerizing it when running docker build . I get the following error => ERROR [4/5] RUN pip install pipenv && pipenv install --system I ignored that, made a docker-compose.yml file and ran docker-compose build and got this error: ERROR: Exception: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher yield File "/usr/local/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 519, in read data = self._fp.read(amt) if not fp_closed else b"" File "/usr/local/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read data = self.__fp.read(amt) File "/usr/local/lib/python3.8/http/client.py", line 458, in read n = self.readinto(b) File "/usr/local/lib/python3.8/http/client.py", line 502, in readinto n = self.fp.readinto(b) File "/usr/local/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.8/ssl.py", line 1099, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 224, in _main status = self.run(options, args) File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper return func(self, options, args) File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 320, in run requirement_set = resolver.resolve( File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", … -
DJANGO OPENCENSUS url field in request data too long
I am having a similar issue to this question since adding App Insights to my application. It may be related to this other question also, but neither of them are directly related to App Insights and neither have solutions. This is the error from the django-tasks.log Data drop 400: 100: Field 'url' on type 'RequestData' is too long. Expected: 2048 characters, Actual: 3701 {'iKey': <uuid>, 'tags': {'ai.cloud.role': 'manage.py', 'ai.cloud.roleInstance': <instance>, 'ai.device.id': <device>, 'ai.device.locale': 'en_US', 'ai.device.osVersion': '#1 SMP Tue Aug 25 17:23:54 UTC 2020', 'ai.device.type': 'Other', 'ai.internal.sdkVersion': 'py3.6.12:oc0.7.11:ext1.0.4', 'ai.operation.id': 'fcbe18bf6ca9036aa4546af171f3e877', 'ai.operation.name': 'GET /<my_url>/'}, 'time': '2020-12-15T17:58:36.498868Z', 'name': 'Microsoft.ApplicationInsights.Request', 'data': {'baseData': {'id': '116a0658b513bdb9', 'duration': '0.00:00:00.096', 'responseCode': '200', 'success': True, 'properties': {'request.name': 'GET /<my_url>/', 'request.url': 'https://<my host>/<my_url>/?<my very long query string>', 'django.user.id': '90', 'django.user.name': '100044505'}, 'ver': 2, 'name': 'GET /<my_url>/', 'url': 'https://<my host>/<my_url>/?<my very long query string>', 'source': None, 'measurements': None}, 'baseType': 'RequestData'}, 'ver': 1, 'sampleRate': None, 'seq': None, 'flags': None}. I could rewrite the app to use shorter queries, but that seems like the wrong answer. Is there a way to configure djang to support long URLs. -
Django suggestions / autocomplete - remote API (geocoding, forward address, map)
in my spare time I am learning django. I'm making a site and currently I'm stuck, already for two days. In "search module" I try to parse address input from user and provide suggestions on city/town based on that input. Currently I am using ajax, jquery and selectize plugin in my html template. I know that this is not a long term solution as API key (google maps api key) is open to public and probably not the safest way to transfer lat/long data into backend. The reason that I am using API is that I get latitude and longitude for certain address and I need to get it into backend. I've tried to search on github for correct repo, nevertheless most of them are not up to date with django 3.1. What other solution can be used with django to call ajax? tldr: suggestion/autocomplete based on user query; remote api> reverse lookup address to latitude and longitude> latitude and longitude to backend -
Django model - hours calculator
Good evening ! I have a question. I can not find over the internet how to solve my problem. I want to have database row in which i can put hours - not datetime or time but for example 01:34 ( 1 hour 34 minutes). I don't know how to deal with it can someone help ? Regards -
Django - How do I render a parent object in template?
I need to display some product's supplier, next to {{product.description}} but I can't get it to show on my table. models.py class Supplier(models.Model): name = models.CharField(max_length=200, null=True) phone = models.CharField(max_length=200, null=True, blank=True) email = models.CharField(max_length=200, null=True, blank=True) date_created = models.DateTimeField(auto_now_add=True, null=True) def __str__(self): return self.name class Product(models.Model): sku = models.IntegerField(null=True) description = models.CharField(max_length=30) costprice = models.FloatField(null=True, max_length=99, blank=True) retailprice = models.FloatField(null=True, max_length=99, blank=True) barcode = models.CharField(null=True, max_length=99, unique=True) image = models.ImageField(null=True, blank=True) supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE, null=True) def __str__(self): return self.description views.py def products(request): products = Product.objects.all() suppliers = Supplier.objects.all() context = {'products': products, 'suppliers': suppliers} return render(request, 'crmapp/products.html', context) products.html <tr> {% for product in products %} <td>{{product.id}}</td> <td><h6><strong>{{product.description}}</strong></h6></td> <td >{{products.supplier}}</td> <td>£{{product.costprice |floatformat:2}}</td> <td>£{{product.retailprice |floatformat:2}}</td> <td>{{product.barcode}}</td> </tr> {% endfor %} -
(Django) UpdateView query only working sometimes
I have a school management app that has a feature to drop a student or teacher from a particular course. The problem is it only works with some users and not others. In my urls.py, I have the following: path('profile/<int:pk>/drop_session/<int:pk2>', user_views.DropStudentFromSession.as_view(), name='drop_student_session'), Then in my views.py, this is my CBV for dropping a student: class DropStudentFromSession(UserPassesTestMixin, UpdateView): model = Session template_name = 'users/drop_student_session.html' fields = [] def test_func(self): return True if self.request.user.groups.filter(name='Admin').count() > 0 else False def handle_no_permission(self): return redirect('denied') def form_valid(self, form): course = get_object_or_404(Session, pk=self.kwargs.get('pk2')) user = get_object_or_404(User, pk=self.kwargs.get('pk')) user.student.enrolled_courses.remove(course) user.save() return super().form_valid(form) def get_success_url(self): user = get_object_or_404(User, pk=self.kwargs.get('pk')) messages.success(self.request, 'Student withdrawn from session.') return reverse('user_profile', kwargs={'pk': user.id}) So the in the form_valid method, it grabs the user's PK and the session's PK so it can successfully remove it from the student's enrolled courses. But it seemed to only work with my one test user that has a PK=2, but not the others. What am I missing here? -
Windows 10 with firewall: Django developement Server: not able to access on Lan
I have a django server with python manage.py runserver 0.0.0.0:8000 ALLOWED_HOSTS=['*'] CORS_ALLOW_ALL_ORIGINS = True Its running in windows. I have my ip as 192.168.0.5 where the django server is running i can access 192.168.0.5:8000/admin from my pc (i.e where server is running, same as the ip) but then when i try to access from a pc on lan it says CONNECTION TIMEDOUT on that pc on lan i tried to ping the ip 192.168.0.5, ping working fine Later i found that its the firewall. When I disable the firewall DJango project is accessible in LAN, else not. I havent touched the firewall at all. But in the contrary i have a reactjs app running in development mode. but its accessible on lan, SO what can i do with windows firewall to enable the django accessible on lan -
Django: table create_post has no column named links
i am getting this error (table create_post has no column named links) when trying to submit my form models: class Post(models.Model): links = models.CharField(default="", max_length=2000) forms: class NewPost(forms.ModelForm): links = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={'class': 'form_input_text', 'style':'resize:none;'}), required=False) class Meta: model = Post fields = ['links'] views: def newPost(request): if request.method == 'POST': form = NewPost(request.POST) if form.is_valid(): form.save() return redirect('myposts') form = NewPost() return render(request, 'create/new_post.html', {'title_page': 'New Post', 'form': form}) -
Format decimal on definition in Admin Panel Django
I create a definition to get the percentage of completed tasks associated with a project. class ProjectAdmin(ImportExportModelAdmin,admin.ModelAdmin): #... def percentage(sef, obj): return obj.todo_set.filter(state = True).count() * 100 / obj.todo_set.all().count() #... list_display = ['project_title', 'category_list', 'date_format', 'crq_count', 'task_count', 'percentage', 'file_count', 'state'] I want to eliminate the decimals and transform it into whole numbers Finally, the idea is that if all the tasks are completed, the project status should go to finished class Project(models.Model): #... state = models.BooleanField(blank=True, null = True, default = False) -
Django ORM filter SUM different related objects on a loop
I have the following models: class Developer(models.Model): name = models.CharField(max_length=100) class Skill(models.Model): code = models.CharField(max_length=30) class Experience(models.Model): date_from = models.DateField(blank=True, null=True) date_to = models.DateField(blank=True, null=True) developer = models.ForeignKey(Developer, related_name='experience', on_delete=models.CASCADE) class SkillExperience(models.Model): skill = models.ForeignKey(Skill, on_delete=models.CASCADE, related_name='skill_experience') experience = models.ForeignKey(Experience, on_delete=models.CASCADE, related_name='skill_experience') years_experience = models.IntegerField() I know that for a single query I could do: Developer.objects.filter( experience__skill_experience__skill__code='Python' ).annotate( # sum up these years <b>total_years=Sum('experience__skill_experience__years_experience')</b> ).filter( <b>total_years__gte=5</b> ) But how to proceed if I'm on a loop of skills and I need to check an OR, so let's say looping this array: [{code: 'python', years_experience: 5}, {code: 'node', years_experience: 2}] and I need to return Devs who have either 5 years xp with python OR 2 years xp with node? -
django: Unable to connect to django server on LAN
I have a django server with python manage.py runserver 0.0.0.0:8000 ALLOWED_HOSTS=['*'] CORS_ALLOW_ALL_ORIGINS = True I have my ip as 192.168.0.5 where the django server is running i can access 192.168.0.5:8000/admin from my pc (i.e where server is running, same as the ip) but then when i try to access from a pc on lan it says CONNECTION TIMEDOUT on that pc on lan i tried to ping the ip 192.168.0.5, ping working fine Not able to understand whats wrong. Its not connecting only, whereas I have a reactjs server running on my pc whose ip is 192.168.0.5, i am able to access it from anywhere on lan -
Error: sequence item 0: expected str instance, ForeignKey found?
I'm trying to add my model to my admin.py page, I've had to play around with my ManytoMany and Arrayfields fields to get it working correctly, however I'm not out of the mud yet. Im getting this error: Error: sequence item 0: expected str instance, ForeignKey found when I try to add an object in my admin page. Here is my original model: class Bucket(models.Model): options = ( ('personal', 'Personal'), ('social', 'Social'), ) class BucketObjects(models.Manager): def get_queryset(self): return super().get_queryset().filter(Bucket.owner) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='buckets') users = models.ManyToManyField(settings.AUTH_USER_MODEL) category = models.CharField(max_length=30, choices=options) name = models.CharField(max_length=35) created = models.DateTimeField(default=timezone.now) slug = models.SlugField(unique=True, blank=True, null=True) stock_count = models.IntegerField(blank=True, null=True) stock_list = ArrayField(models.CharField(max_length=6,null=True),size=30,null=True) about = models.CharField(max_length=75) objects = models.Manager() bucketobjects = BucketObjects() class Meta: ordering = ('-created',) def total_stocks_calc(self): self.stock_count = Bucket.objects.aggregate(Sum('stock_list', distinct=True)) self.save() def get_absolute_url(self): return reverse("bucket:bucket-view", kwargs={"slug": self.slug}) def __str__(self): return self.stock_list here is my admin.py code: @admin.register(models.Bucket) class AuthorAdmin(admin.ModelAdmin): fields = models.Bucket._meta.get_fields() list_display = ('id','owner','category', 'get_users', 'name', 'created', 'slug','stock_count','get_stocks', 'about') prepopulated_fields = {'slug': ('name',), } def get_users(self, obj): return "\n".join([u.users for u in obj.users.all()]) def get_stocks(self, obj): return "\n".join([s.stock_list for s in obj.stock_list.all()]) Not sure why I'm getting this error. EDIT: Full Traceback error: Request Method: GET Request URL: http://127.0.0.1:8000/bbucketmaster9/bucket/bucket/add/ Django … -
Not able to update an item in Django
I am trying to update the Bar Information for users by getting their details and setting the Bar instance. But every time I click on the link on my dashboard it redirects me to the dashboard which is what I used for the else statement if it is not a post method. view.py def UpdateUserBar(request): user = request.user.id bar = Bar.objects.get(user_id=user) form = UpdateBar(instance=bar) if request.method == 'POST': form = UpdateBar(request.POST, instance=bar) if form.is_valid(): form.save() return redirect('/updatebar') messages.success(request, 'Bar Information Updated successfully') else: return redirect('/dashboard') messages.error(request, 'Only Post method is accepted') else: form = UpdateBar(instance=bar) context = {"form":form, "bar":bar} return render(request, "dashboard/super/landlord/update_bar.html", context) forms.py class UpdateBar(ModelForm): class Meta: model = Bar fields = '__all__' models.py class Bar(models.Model): status = ( ("open", "open"), ("closed", "closed"), ("pending", "pending"), ) user_id = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=50) address = models.CharField(max_length=100) opening_time = models.TimeField() closing_time = models.TimeField() status = models.CharField(choices=status, default="pending", max_length=14) image = models.ImageField(upload_to='images/bars', default='images/bars/default.jpg') def __str__(self): return self.name updatebar.html {% load i18n widget_tweaks %} <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"> {% csrf_token %} <div class="form-group"> <label class="col-md-2 control-label">{{ form.name.label }}:</label> <div class="col-md-10"> <input type="text" id="id_name" name="name" class="form-control" value="{{user.name}}" disabled> </div> </div> <div class="form-group"> <label class="col-md-2 control-label">{{ form.user_id.label }}:</label> <div class="col-md-10"> <input id="id_user_id" name="user_id" … -
Check if number has opted out in twilio
I am building a web application that needs to be able to send SMS messages and check if a number has opted out of SMS. The only option that I have found is to use a web-hook for SMS replies and check there. I am looking for an option where I can just ping the API and check if a number has been opted-out. -
Running through an environmental error during deploying django app on heroku
I have created virtual env with anaconda prompt and created my django project in that env. I have created repository on github and push my code there and also create app on heroku but when i am running this git push heroku main command, it showing me an error which I have given below: ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1605055780383/work'.. traceback: PS C:\Users\AHMED\newrest\source> git push heroku main Enumerating objects: 48, done. Counting objects: 100% (48/48), done. Delta compression using up to 4 threads Compressing objects: 100% (44/44), done. Writing objects: 100% (48/48), 16.22 KiB | 615.00 KiB/s, done. Total 48 (delta 10), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: ! Python has released a security update! Please consider upgrading to python-3.8.6 remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing python-3.8.5 remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Processing /tmp/build/80754af9/asgiref_1605055780383/work remote: ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1605055780383/work' remote: remote: ! Push rejected, failed to … -
Date/Time picker in html + django
I am trying to find solution for my problem, but unfortunately there is no answers. I need one button which will paste the current date/time in one of the inputs on my html form. The website is made with django. I need to put button beside {{form.data_godzina_one}}. <div id='wazne'> {{form.Trailer.label}}: {{form.Trailer}} <br><br> {{form.operacja.label}}: {{form.operacja}} <br><br> {{form.wydzial_one.label}}: {{form.wydzial_one}} <br><br> {{form.data_godzina_one.label}}: {{form.data_godzina_one}}<br><br> {{form.driver_one.label}}: {{form.driver_one}}<br> </div>