Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Email Verification django rest framework
I am creating an api using Django Rest Framework, when user signs up (registers) for an account, the user receives a verification email, with a verification link, once clicked the account should be verified. I got the email sending part working and configured. My question is: How to have the link in the verify-email endpoint activate account when user clicks on it (decode payload) ? I cannot seem to find what I am looking for over the internet, I browsed the DRF documentation, but could not find it. I am using Django Token Authentication for authentication, that ships with Django rest. Your inputs are much appreciated. Thank you. -
How to generate slug according to title of post in django?
Well i dont want to work with id of post in my urls so i want to generate slug according to to post title and that can be same. so i dont understand how can i do that can you guys tell me it can be done, my model post is given below. model.py class Post(models.Model): username = models.ForeignKey(UserProfile, on_delete=models.CASCADE) description = models.CharField(('Description'),max_length=250) title = models.CharField(('Content Title'), max_length=250) create_date = models.DateTimeField(default = timezone.now) image_data = models.ImageField(upload_to='User_Posts', height_field=None, width_field=None, max_length=None) slug = (title) def __str__(self): return self.title -
How do I get the API Key message to go away TinyMCE? (Django)
I've included the TinyMCE editor into my program and it's showing up, but says I need to add a API key. I've tried doing this but can't figure out where: {% extends "blog/base.html" %} {% load crispy_forms_tags %} <head> <script src="https://cdn.tiny.cloud/1/<KEY>/tinymce/4/tinymce.min.js" referrerpolicy="origin"></script> </head> {% block content %} <div class="content-section"> <form method="POST"> {% csrf_token %} {{ form.media }} <fieldset class="form-group" id = #mytextarea> <legend class="border-bottom mb-4">Add Law</legend> {{ form|crispy }} </fieldset> <div class="form-group"> <button class="btn btn-outline-info" type="submit">Finish</button> </div> </form> </div> {% endblock content %} This is my form.html template. Here is my settings.py: TINYMCE_DEFAULT_CONFIG = { 'cleanup_on_startup': True, 'custom_undo_redo_levels': 20, 'selector': 'textarea', 'theme': 'silver', 'plugins': ''' textcolor save link image media preview codesample contextmenu table code lists fullscreen insertdatetime nonbreaking contextmenu directionality searchreplace wordcount visualblocks visualchars code fullscreen autolink lists charmap print hr anchor pagebreak ''', 'toolbar1': ''' fullscreen preview bold italic underline | fontselect, fontsizeselect | forecolor backcolor | alignleft alignright | aligncenter alignjustify | indent outdent | bullist numlist table | | link image media | codesample | ''', 'toolbar2': ''' visualblocks visualchars | charmap hr pagebreak nonbreaking anchor | code | ''', 'contextmenu': 'formats | link image', 'menubar': True, 'statusbar': True, } TINYMCE_JS_URL = 'https://cdn.tiny.cloud/1/<KEY>/tinymce/5/tinymce.min.js' and finally my … -
For loop in Django doesnt show up the result from database
i have a problem with for loop. First i have this views.py: from django.shortcuts import render from .models import * def store(request): products = Product.objects.all() context = {'products':products} return render(request, 'store/store.html') As you see from the .models i am importing everything (*), but in particular i am interested in class Product (code from models.py): class Product(models.Model): name = models.CharField(max_length=200, null=True) price = models.FloatField() digital = models.BooleanField(default=False, null=True, blank=False) def __str__(self): return self.name Then in Django admin http://127.0.0.1:8000/admin i have created several products: So i have the model, products in database and view. Finally in my template store.html i have for loop: {% extends 'store/main.html' %} {% load static %} {% block content %} <div class="row"> {% for product in products %} <div class="col-lg-4"> <img src="{% static 'img/placeholder.png' %}" alt="" class="thumbnail"> <div class="box-element product"> <h6><strong>{{product.name}}</strong></h6> <button class="btn btn-outline-secondary add-btn">Add to Cart</button> <a class="btn btn-outline-success" href="#">View</a> <h4 style="display: inline-block; float: right"><strong>${{product.price|floatformat:2}}</strong></h4> </div> </div> {% endfor %} </div> {% endblock content %} But it doesnt show the products from the database: If i delete in store.html a for loop: {% for product in products %} and {% endfor %} Then the plain html displays. Any clue why the for loop doesnt work please? … -
Python create_user Object of type 'set' is not JSON serializable
I have this code: class usuario(APIView): def post(self, request): try: data = json.dumps(request.data) #usuario = UserSerializer(data = request.data) #print(usuario) #if usuario.is_valid(): # print(usuario.data) #print("'"+str(data['email'])+"'") #firebase_admin.initialize_app() user = auth.create_user( email='user@example.com', email_verified=False, phone_number='+15555550100', password='secretPassword', display_name='John Doe', photo_url='http://www.example.com/12345678/photo.png', disabled=False) print('Sucessfully created new user: {0}'.format(user.uid)) return JsonResponse({"user": 'teste}'}, status=status.HTTP_201_CREATED) except Exception as ex: print(ex) return JsonResponse({"Ocorreu um erro no servidor"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, safe=False) When I try to do a post request with postman, it returns: Object of type 'set' is not JSON serializable line 37, in post Line 37 is: disabled=False) -
Django Rest frame work error get() returned more than one Customer_Notes -- it returned 3
I am using react app to fetch data from a django rest api. The issue here is there are multiple notes added for one single user and when I am trying to make a get request it is throwing the above error. It is allowing me to only fetch one single row when i specify the lookup field to be pk. However I want to return all the objects. class Customer_NotesViewSet(viewsets.ModelViewSet): queryset = Customer_Notes.objects.all() serializer_class = serializers.Customer_NotesSerializer lookup_field = 'customer' class Customer_NotesSerializer(serializers.ModelSerializer): class Meta: model = Customer_Notes fields = "__all__" What changes or work around can be done here ? -
ProgrammingError at /accounts/facebook/login/token/
I'm having trouble setting up the facebook login in django. Whenever I click the facebook log-in link it tells me this: ProgrammingError at /accounts/facebook/login/token/ (1146, "Table 'user$db.account_emailaddress' doesn't exist") I followed the set up recommended here. From what the error message says I suspect it is related to the migrations in my database. The Traceback leads me to /allauth/account/utils.py where I can the see the problem is the use of EmailAddress.objects.filter(). In fact, when I go in the shell and try: from allauth.account.models import EmailAddress I can import EmailAddress successfully. It's only when I try to use EmailAddress.objects.all() that I get the same 1146 error. I tried to redo all migrations related to allauth but my database still never shows any table related to allauth or account. Here are the details of my settings.py file: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'social_django.context_processors.login_redirect', 'django.template.context_processors.request', ], }, }, ] INSTALLED_APPS = [ 'django.contrib.admin.apps.SimpleAdminConfig', 'django.contrib.auth', 'django.contrib.messages', 'django.contrib.sites', 'social_django', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', 'custom_user.apps.CustomUserConfig', 'user_profile', 'django_email_verification', ] AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ] SITE_ID = 1 and urls.py: urlpatterns = [ path('accounts/',include('allauth.urls')), path('request-reset-email', RequestResetEmailView.as_view(), name='request-reset-email'), ] Thanks everybody for your help. -
Django redirect interfering with stat files loading
I am having a Django app where users search for files that are generated as reports (edited html creating reports Impression) . On the front-end,the search form makes a Get action '/search/q=someValue' However,the query url needs to be replaced and so I updated my views.py such that Def search_view(request): //Validate the query is valid //Redirect to some_new_url Def some_new_url(request): //Now use this view for search When i carry out a search, static files are not applying but if i navigate using internal links referencing the same url(some_new_url) everything works okay.What could be the issue -
Counting specific field of deeply nested Object django
I have a model Category and it has children and also the Product model looks like this class Category(models.Model): name = models.CharField(max_length=200) category = models.ForeignKey(Category, related_name='children') product_count = models.IntegerField(null=True) class Product(models.Model): category = models.ForeignKey(Category) sub_category = models.ForeignKey(Category, related_name='sub_category_products') name = models.CharField(max_length=300) price = models.DecimalField() and I need to count all products belong to the specified category it can be in the subcategory of the category. The Category model can be deeply nested. How can I do this query! Any would be appreciated. Thanks in advance! -
TemplateSyntaxError at Could not parse the remainder:
I'm new to Django and trying to get path details of one specific image from the ProductImage table using the place field in the table and display the image.Where place == 'Main Img' Product and ProductImage has one to many relationship. My database has two tables named Product(id, name, price,..) and ProductImage(id, productid, image, place) which contains three images('Main IMG', 'Sub Img 1', 'Sub Img 2') Here is my models.py from django.db import models from django.contrib.auth.models import User class Product(models.Model): name = models.CharField(max_length=200) desc = models.TextField() price = models.DecimalField(max_digits=10, decimal_places=2) discount = models.DecimalField(max_digits=4, decimal_places=0) def __str__(self): return self.name class ProductImage(models.Model): PLACEHOLDER= ( ('Main Image', 'Main Image'), ('Sub Img 1', 'Sub Img 1'), ('Sub Img 2', 'Sub Img 2'), ) product = models.ForeignKey(Product, related_name='image_set', on_delete=models.CASCADE) image = models.ImageField(upload_to='images/') place = models.CharField(max_length=20, choices=PLACEHOLDER) def __str__(self): return str(self.id) views.py def menu(request): products = Product.objects images = ProductImage.objects context = {'products': products, 'images': images} return render(request, 'store/menu.html', context) Template {% for product in products.all %} <a href="#"> <img src="{{ images.filter(product__id=product.id, place='Main Product Image')[0].image.url }}" class="img-fluid mt-3"> {% if product.discount != 0 %} <span class="bonus">{{ product.discount }}% off</span> {% endif %} </a> settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] # Media files … -
Hbase login with django
Good morning, I have a question, I am new in apache Hadoop and django. I am creating login in django but i don't know how customing it becouse only know native methods like: "authenticate()" and "login()", now I am using login() but this needs a model user auth instance. I need create a login based in hbase tables. This is my example code user = User.objects.get(username=username) login(request,user) But in the user var recive a instance of mysql model and I need use Hbase Thanks in advance -
Django Form - Create new entries with multiple foreign k
I have searched a lot about this topic here, but i haven't found the right answer. Here is my problem, i want to create a form(not in admin) where the website users can create new entries, and fill the foreign key for my model Market (who has multiple foreignkey to other models). So in this this form the user can create new entries from the models city, provider and service.(i hope i explain it well) What i try to do is to fill 4 models with a single submit for the user. So far i managed to save one foreign key, using instance with and inlineformset_factory, but i want to know what i have to do in order to write the user input in my 4 models. I want to have only one entry for the models that are related as foreign key, that's why i put extra and max_num at 1 and can_delete as false here is my code, hoping you'll be able to help me. Thanks in advance models.py from django.db import models class Market(models.Model): number = models.CharField(max_length=7) title = models.CharField(max_length=200) description = models.CharField(max_length=200) city = models.ForeignKey(City, on_delete=models.CASCADE, null=True) service = models.ForeignKey(Service, on_delete=models.CASCADE, null=True) provider = models.ForeignKey(Provider, on_delete=models.CASCADE, … -
In django are @transaction.atomic auto applied to nested methods also
I have just started learning django and came across this confusion consider the below code @transaction.atomic def first_method() doing stuff calling_method() def calling_method() items = item.objects.filter(item_id__in=[list of items]) for item in items: item.save() Will the above code save item records one by one in db or will it save all the items at once because I have used @transaction.atomic at the first method? If I have to save all the item records at once in db should I use @transaction.atomic in calling_method() as well? -
Django: put all loop result into one bloc json
Django - Json I've tried many time to get all the result of the loop ['results'][0]['analyzedInstructions'][0]['steps'][steps] (multiple results) in only one bloc. But that does not work. Do you have any idea to get all this results and put them together? All others fields works, and the json location is good. try: name = response_title_data['results'][0]['title'] ... steps = "" for step in response_title_data['results'][0]['analyzedInstructions'][0]['steps']: steps += step.step current_post = get_object_or_404(Post, slug=self.slug) create_recipe = self.recipe.create(name=name,source=source,url=url,score=score_brut,steps=steps) current_post.recipe.add(create_recipe) except Exception as e: pass -
Django queryset annotation filters (for max)
I have the following model: class Room(models.Model): # model fields class Table(models.Model): room = models.ForeignKey( Room, [...], related_name='tables' ) class Seat(models.Model): table = models.ForeignKey( Table, [...], related_name='seats' ) timestamp = models.DateTimeField(auto_now_add=True) is_vip = models.BooleanField(default=False) I would like to get the timestamp of the latest seat with a vip on it. Getting the latest seat is easy like this: Room.objects.all().annotate(latest_seat=Max('tables__seats__timestamp')) But how do I filter this on is_vip=True only? -
Django recursive foreign key use template improve sql query
I want improve database sql query Need to change models.... Now 1reply 3 database sql My model Comment(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE) author = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) reply = models.ForeignKey('self', related_name='reply', on_delete=models.SET_NULL, null=True) content = models.TextField() My template(relpy.html) <li> <label>{{ comment.author }}</label> <p>{{ comment.content }}</p> </li> <li class="gb-padding-left_large"> <form method="post" action="{% url 'post_detail' post.board.pk post.pk %}"> {% csrf_token %} <input type="hidden" required="true" name="comment_id" value="{{ comment.pk }}"/> <input type="text" required="true" name="content" placeholder="reply"/> <input type="submit" placeholder="submit"/> </form> </li> <div class="gb-padding-left_x-large reply"> {% for reply in comment.reply.all %} {% include 'boards/reply.html' with comment=reply %} {% endfor %}</div> -
Django Apache2 VirtualEnv - no response from server
So I am trying to migrate my app to a new production server. I'm not getting a reply from the server Apache server when I access it. The server is on AWS and it's a standard Apache config with just one site enabled: <VirtualHost *:80> Alias /static/ /home/ubuntu/myapp/myapp/myapp/static Alias /media/ /home/ubuntu/myapp/myapp/myapp/media <Directory /home/ubuntu/myapp/myapp/myapp/static> Require all granted </Directory> <Directory /home/ubuntu/myapp/myapp/myapp/media> Require all granted </Directory> <Directory /home/ubuntu/myapp/myapp/myapp> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> WSGIDaemonProcess myapp python-home=/home/ubuntu/myapp/myapp/myapp python-path=/home/ubuntu/myapp:/home/ubuntu/myapp/lib/python3.6/site-packages WSGIProcessGroup myapp WSGIScriptAlias / /home/ubuntu/myapp/myapp/myapp/myapp/wsgi.py ErrorLog /var/log/apache2/myapp_error.log LogLevel warn CustomLog /var/log/apache2/myapp_access.log combined </VirtualHost> I have made sure that all files are owned by the ubuntu user and that www-data has group rights. The wsgi file is the original, but I added a print statement to see the folder it's checking for the application: """ WSGI config for match2 project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ """ import os, sys print(sys.path) from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") application = get_wsgi_application() Eventually, the error log will produce: Timeout when reading response headers from daemon process 'myapp': /home/ubuntu/myapp/myapp/myapp/myapp/wsgi.py I'd appreciate any advice. -
Reading file from other folder in Django
My file structure is: project --support_file --topic_cluster.json recommend.py i am trying to read topic_cluster.json in recommend.py file.My code for the same is with open("project/support_file/topic_clusters.json") as f: topic_clusters=json.load(f) It is giving me FileNotFoundError: [Errno 2] No such file or directory: -
certbot works in command line but fails when running through django call to script
So I have been dealing with this problem for days now and have exhausted every possible thing I can think of. For clarification purposes I am running Machine: Centos 7 WebServer: Django Python Version: 3.6 I have this shell script at /usr/local/bin/activate_https_hostedvoice #!/bin/bash echo "<REMOVE_FOR_SECURITY>" | sudo -S curl -i -XPOST "http://<REMOVED_FOR_SECURITY>/records/""$1""/""$2""" sleep 10 NGINX_CONFIG_FILE=/etc/nginx/guiconf.d/guiserver.conf sed -i "s/]/,'""$1""']/g" /var/lib/guiserver/astgui2/db_pass.py echo "<REMOVE_FOR_SECURITY>" | su -c "/sbin/service guiserver reload" root echo "" >> ${NGINX_CONFIG_FILE} echo "server{" >> ${NGINX_CONFIG_FILE} echo "server_name $1;" >> ${NGINX_CONFIG_FILE} echo "client_max_body_size 4G;" >> ${NGINX_CONFIG_FILE} echo "include guiconf.d/server_params;" >> ${NGINX_CONFIG_FILE} echo "include guiconf.d/static_files;" >> ${NGINX_CONFIG_FILE} echo "include guiconf.d/web_path;" >> ${NGINX_CONFIG_FILE} echo "include guiconf.d/local_path;" >> ${NGINX_CONFIG_FILE} echo "include guiconf.d/ws_path;" >> ${NGINX_CONFIG_FILE} echo "}" >> ${NGINX_CONFIG_FILE} echo "<REMOVE_FOR_SECURITY>" | su -c "systemctl reload nginx" root echo "<REMOVE_FOR_SECURITY>" | su -c "systemctl stop iptables" root echo "<REMOVE_FOR_SECURITY>" | su -c "certbot --nginx -d ""$1"" --agree-tos --email <REMOVED_FOR_SECURITY> -n" root echo "<REMOVE_FOR_SECURITY>" | su -c "systemctl reload nginx" root echo "<REMOVE_FOR_SECURITY>" | su -c "systemctl start iptables" root echo "<REMOVE_FOR_SECURITY>" | su -c "/sbin/service guiserver reload" root echo "<REMOVE_FOR_SECURITY>" | su -c 'echo "0 */12 * * * certbot --nginx renew -n" >> /var/spool/cron/root' root echo "<REMOVE_FOR_SECURITY>" | su -c "rm -f /var/lib/guiserver/bin/https_config" … -
password field is missing in forms django?
I want to replace username with email in django authentication.So when I was going through documentation it says that If you’re starting a new project, it’s highly recommended to set up a custom user model, even if the default User model is sufficient for you So First I created a custom user model which extends AbstractUser.In which I made username=None and USERNAME_FIELD='email' class User(AbstractUser): username = None first_name = None last_name = None email = models.EmailField(unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] Then I created a modelform which uses custom user model.When I render this form in my template, password and confirm password field is missing.I don't know whats going wrong. class UserForm(forms.ModelForm): class Meta: model = get_user_model() fields = ['email'] I thought password and confirm password will be there by default.Am I right? -
How do I plot multiple xy arrays using Chartsjs?
I'm trying to plot to xy arrays using chartsjs x1 = [1,2,3,4,5,6] y1 = [2,4,6,8,10,12] x2 = [4,5,6] y2 = [3,6,9] I can do: var myChart = new Chart(ctx, { type: 'line', data: { datasets: [{ label: 'Scatter Dataset', data: [{ x: 1, y: 2 }, { x: 2, y: 4 }, { x: 3, y: 6 }] { label: 'Scatter Dataset2', data: [{ x: 4, y: 3 }, { x: 5, y: 6 }, { x: 6, y: 9 }] }] }, The problem is that i have a larger x1,y1,x2,y2 array. How do I place a whole array of xy values instead of individual xy values? Instead of data: [{ x: 1, y: 2 }, { x: 2, y: 4 }, { x: 3, y: 6 } I want to be able to do data: [{ x: [1,2,3] y: [2,4,6] }] Do you recommend any other libraries/packages other than chartsjs? -
How the change the appearance of btn btn-outline-success using Django?
I am struggling with button appearance in Django. I implemented a button in this way: <form class="form-inline mt-2 mt-md-0"> <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search" > <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> At this moment, the button has a green border color, a green text and a green hover when the mouse is on it. I really would like to change these properties but maybe I am messing with CSS. Could you help me? Thank you so much -
django ImageField not saving files in proper directory via django rest framework
When post request is sent the images is saved in media/user_None/pic/1602746423.311224_profile.png instead of media/user_{id}/pic/1602746423.311224_profile.png Teacher Model class Teacher(AbstractUser): profile_pic = models.ImageField(verbose_name="Profile Picture",blank=True,null=True,upload_to=file_pic,default='default.png') middle_name = models.CharField(max_length=30, blank=True, null=True) dob = models.DateField(verbose_name='Date Of Birth', null=True) doj = models.DateField(verbose_name='Date Of Join', null=True) mobile_num = models.CharField(verbose_name='Mobile Number',max_length=10,null=True,blank=True) SEX_CHOICE = ( ('m','Male'), ('f','Female'), ('t','Transgender'), ('o','Others') ) sex = models.CharField(max_length=1,choices=SEX_CHOICE,default='m') department = models.ForeignKey('Department',on_delete=models.SET_NULL,null=True) file_pic function for ImageField, to save photos in users folder based on its id def file_pic(instance, filename): return 'user_{0}/pic/{2}_{1}'.format(instance.id, filename, time.time()) Serializer for teacher creation class TeacherCreateSerializer(ModelSerializer): password2 = CharField(write_only=True, style={'input_type':'password'}) class Meta: model = Teacher fields = [ 'username', 'email', 'mobile_num', 'first_name', 'middle_name', 'last_name', 'dob', 'doj', 'sex', 'department', 'profile_pic', 'password', 'password2' ] extra_kwargs = { 'password' : {'write_only':True, 'style':{'input_type':'password'}} } def create(self,validated_data): vd_cpy = validated_data password1 = vd_cpy['password'] password2 = vd_cpy['password2'] vd_cpy.pop('password2') vd_cpy.pop('password') teacher = Teacher(**vd_cpy) if(password1!=password2): raise ValidationError('password doesn\'t match') teacher.set_password(password1) teacher.save() return validated_data def validate_mobile_num(self,value): value = self.initial_data.get('mobile_num',None) if value is None or len(value) == 0: return None if(re.search(r'^((\+?91|0)?){1}[1-9]{1}[0-9]{9}$',value) is None): raise ValidationError('Invalid Mobile Number') return value def validate_email(self,value): if(Teacher.objects.filter(email=value).exists()): raise ValidationError('email already registered') return value APIView for teacher creation class TeacherCreateAPIView(CreateAPIView): queryset = Teacher.objects.all() serializer_class = TeacherCreateSerializer permission_classes = [AllowAny] parser_classes = (JSONParser,FormParser,MultiPartParser) What DRF API explorer shows just … -
Django ImageField is not accessed when in for loop
I'm using telebot to create Telegram bot and Django for model management. When I try to send post to multiple users through a loop I get an error on trying to access ImageField Here is my code def empty_generator(*kwargs): return types.InlineKeyboardMarkup() @bot.message_handler(commands=['test']) def test_send(message): post = Mailing.objects.get(id=79) for i in range(0, 3): print(post.file, len(post.file)) send_generator_with_preview(message.chat.id, post, post.broadcast_language, empty_gener) def send_generator_with_preview(chat_id, post, ln, generator): if (post.file): if post.text: # No photo post bot.send_photo(chat_id, caption=post.text, photo=post.file, reply_markup=generator(post, ln), parse_mode='markdown') else: # No text post bot.send_photo(chat_id, photo=post.file, reply_markup=generator(post, ln), parse_mode='markdown') else: # No Image post bot.send_message(chat_id, text=post.text, reply_markup=generator(post, ln), parse_mode='markdown') Unfortunately, trying to run this code will result in an error: > ERROR - TeleBot: "ApiException occurred, args=('A request to the > Telegram API was unsuccessful. The server returned HTTP 400 Bad > Request. Response > body:\n[b\'{"ok":false,"error_code":400,"description":"Bad Request: > file must be non-empty"}\']',) Traceback (most recent call last): > File > "/Users/number16/Documents/GitHub/urus-master/venv/lib/python3.7/site-packages/telebot/util.py", > line 62, in run > task(*args, **kwargs) File "/Users/number16/Documents/GitHub/urus-master/urus/bot.py", line 1628, > in test_send > send_generator_with_preview(message.chat.id, post, post.broadcast_language, empty_gener) File > "/Users/number16/Documents/GitHub/urus-master/urus/bot.py", line 1691, > in send_generator_with_preview > reply_markup=generator(post, ln), parse_mode='markdown') File "/Users/number16/Documents/GitHub/urus-master/venv/lib/python3.7/site-packages/telebot/__init__.py", > line 700, in send_photo > parse_mode, disable_notification, timeout)) File "/Users/number16/Documents/GitHub/urus-master/venv/lib/python3.7/site-packages/telebot/apihelper.py", > line 315, in send_photo > … -
i'm trying to push my python-django app to heroku, here is the code from the teminal and settings.py :
I get the error in the terminal ( AttributeError: module 'posixpath' has no attribute 'adspath') i tried changing the BASE_DIR file and nothing worked, I fixed the static files and it didn't work either, be patient with my problem please, I have been trying for 3 days to upload this app and this is my final resort. thank you for checking out my question.. This is my terminal after running git push heroku master: git push heroku master Enumerating objects: 6962, done. Counting objects: 100% (6962/6962), done. Delta compression using up to 4 threads Compressing objects: 100% (4022/4022), done. Writing objects: 100% (6962/6962), 15.05 MiB | 189.00 KiB/s, done. Total 6962 (delta 1888), reused 6927 (delta 1865), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: -----> Installing python-3.9.0 remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: Collecting asgiref==3.2.10 remote: Downloading asgiref-3.2.10-py3-none-any.whl (19 kB) remote: Collecting dj-database-url==0.5.0 remote: Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB) remote: Collecting dj-static==0.0.6 remote: Downloading dj-static-0.0.6.tar.gz (3.4 kB) remote: Collecting Django==3.1.2 remote: Downloading Django-3.1.2-py3-none-any.whl (7.8 MB) remote: Collecting django-bootstrap3==14.1.0 remote: Downloading django_bootstrap3-14.1.0-py3-none-any.whl (23 kB) remote: Collecting gunicorn==20.0.4 …