Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Cannot migrate model in django
I'm trying to create a following/follower system on my django project, and I created a model to do so, but I cannot migrate it. Here is the code: from django.db import models from django.contrib.auth.models import User class Follow(models.Model): follow_user = models.ForeignKey(User, models.DO_NOTHING, related_name="user") follow_followed = models.ForeignKey(User, models.DO_NOTHING, related_name="followed") I can create the migration, but when I migrate, it gives me this error: django.db.utils.OperationalError: foreign key mismatch - "blog_main_following_following" referencing "blog_main_following" I have no idea what this means. Can anyone help me resolve this error? -
how to keep messages showing with django-channels
i'm looking for suggestions: Everytime i click on one of the links (on the right under Module), i lose the messages showing in the chat box, is there a way to prevent that, thank you very much. build with django channels and jquery, followed the docs on channels. -
how can I turn boostrap studio designs into django templatates
I just started using bootstrap studio and I would like to convert the design I do in it into django templates directly. I have tried to follow up on the solution provided at https://github.com/lingster/django-bootstrap-studio-tools and https://github.com/AbcSxyZ/bootstrap-studio-to-django-template but I have failed to figure it out where to find django_export.sh. Could someone help me out on where I can get the path to this django_export.sh script? -
Django Creating Virtual Environment Errors
I'm trying to set up a virtual environment but I cannot figure it out. I've installed Python 3.5.0 as that's the last Python version compatible with Django according to their website. Then, I executed successfully: pip3 install virtualenvwrapper-win However, after trying to set up the environment, I get a bunch of errors: PS C:\Users\nollb> mkvirtualenv my_django_environment Traceback (most recent call last): File "c:\users\nollb\appdata\local\programs\python\python35\lib\runpy.py", line 170, in _ run_module_as_main "__main__", mod_spec) File "c:\users\nollb\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\nollb\AppData\Local\Programs\Python\Python35\Scripts\virtualenv.exe\__main__.py", line 5, in <module> File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\__init__.py", line 3, in <module> from .run import cli_run, session_via_cli File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\__init__.py", line 12, in <module> from .plugin.activators import ActivationSelector File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\plugin\activators.py", line 6, in <module> from .base import ComponentBuilder File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\plugin\base.py", line 9, in <module> from importlib_metadata import entry_points File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\importlib_metadata\__init__.py", line 88 dist: Optional['Distribution'] = None ^ SyntaxError: invalid syntax The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. Is setting up an environment really necessary for creating a small-ish website, and no other django work would be done on my computer? And if it is necessary, what have I done wrong? -
Running Django Project after Cloning from Github not working?
I happened to push my repo from my other computer and perhaps could have missed some files? I omitted the sqlite file since my application was just routing and serving web pages/forms. Anyways, I am attempting to python manage.py runserver and I keep getting an error message. It says : python manage.py runserver Watching for file changes with StatReloader Performing system checks... Exception in thread django-main-thread: Traceback (most recent call last): File "/home/alejandro/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/home/alejandro/anaconda3/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 579, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module return import_module(self.urlconf_name) File "/home/alejandro/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line … -
Adding data to the database through the front-end in django
I am writing a small blog and I will like to have a page through which I will be updating the website without going to the admin panel but it seems am not getting something right. I've writing a view function but it is not responding yet. Am still a newbie Below is my models.py file class UserUpload(models.Model): artist = models.CharField(max_length=300) title = models.CharField(max_length=200, unique=True) slug = models.SlugField(default='', blank=True, unique=True) thumbnail = models.ImageField(blank=False) audio_file = models.FileField(default='') music_tag = models.ManyToManyField(MusicTag) uploaded_date = models.DateTimeField(default=timezone.now) page_views = models.IntegerField(default=0) moderation = models.BooleanField(default=False) class Meta: ordering = ['-uploaded_date'] def save(self): self.uploaded_date = timezone.now() self.slug = slugify(self.title) super(UserUpload, self).save() def __str__(self): return self.title + ' by ' + self.artist def get_absolute_url(self): return reverse('music:detail', kwargs={'slug': self.slug}) This is my views.py file def upload(request): if request.method == 'POST': AUDIO_FILE_TYPE = ['wav', 'mp3', 'ogg'] IMAGE_FILE_TYPE = ['png', 'jpg', 'jpeg'] form = UserMusicForm(request.POST or None, request.FILES or None) if form.is_valid(): form.save(commit=False) form.artist = request.POST.get('artist') form.title = request.POST.get('title') form.thumbnail = request.POST.FILES('thumbnail') form.audio_file = request.POST.FILES('audio_file') form.music_tag = request.POST.get('music_tag') messages.success(request, 'has been successfully uploaded') if form.thumbnail.url.split('.')[-1] not in IMAGE_FILE_TYPE: context = { "form": form, "message": "Image file must be PNG, JPG, or JPEG" } return render(request, "music/upload1.html", context) if form.audio_file.url.split('.')[-1] not in AUDIO_FILE_TYPE: … -
css adding linear-gradient to background does not work, but adding single color does
I am trying to add a linear gradient background to the login page of my website, however I cannot seem to get it to work. #login { background-image: linear-gradient(red, yellow); } <body id="login" class="vh-center"> ... </body> I have tried; background-image: linear-gradient(red, yellow);, and background-image: linear-gradient(red, yellow); If I add background: red;, It works as expected Am I missing something here? Edit: css #login { background: linear-gradient(red, yellow); } Screenshot: css #login { background: red; } Screenshot: -
Adding List of Related IDs to returned values in a Django Queryset
According to the example in Django's Docs, I can obtain a list of reverse related objects like this: Blog.objects.values('entry__id') Which would presumably give me the ids of all related Entry objects. If I wanted this information in addition to all the other information returned in a normal .values() call, is there a short way to add it on? Or do I need to explicitly list all of the models' fields in .values() to have the reverse keys included in the output? -
How to create a function that counts total string objects in my ArrayField column for my model?
Trying to create a column in my model called, stock_count, that finds the sum of the total string objects in my ArrayField(), aka stock_list. Here is my function. def total_stocks_calc(self): self.stock_count = Bucket.objects.aggregate(Sum('stock_list', distinct=True)) self.save() However it doesn't seem to be doing anything, no calculating, leaving the field blank in my model, admin page, and DRF interface... Here is my model. class Bucket(models.Model): 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=category_options) name = models.CharField(max_length=35) created = models.DateTimeField(default=timezone.now) slug = models.SlugField(unique=True, blank=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 __unicode__(self): return self.stock_list Would like to know the proper way to count total items in ArrayField(), thank you in advance. -
Why django page may not load?
Project in /root/code/mysite, i activating venv ". ./env/bin/activate", starting server "python3 manage.py runserver 0.0.0.0:8000", all ok System check identified no issues (0 silenced). December 25, 2020 - 00:27:24 Django version 2.2.17, using settings 'main.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C., but on http://IP:8000 nothing. What could be the problem? -
Bootstrap Table from Model
I have a table that I am trying to convert from static, mock data into real, live SQLite3 data. I am hoping to display my SQLite3 table within my HTML code including all three of my columns (Question | Answer | Pub_Date) and then display the values in the table. My current code (below) adds the list of questions in, but it is adding them in as values from left to right rather than up and down (screenshot below). What would I need to adjust to get my simple table shown rather than the fake data? <table class="table table-hover"> <thead> <tr style="font-family: Graphik Black; font-size: 14px"> <th scope="col">#</th> <th scope="col">First</th> <th scope="col">Last</th> </tr> </thead> <tbody> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row" class="container">1</th> {% for question in latest_question_list %} <td><li style="font-weight: 500;"><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li></td> {% endfor %} <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td> </tr> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row">2</th> <td>Jacob</td> <td>Thornton</td> <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td> </tr> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row">3</th> <td colspan="2">Larry the Bird</td> <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px"data-toggle="modal" data-target="#new">Edit</button></td> </tr> </tbody> </table> Desired … -
How to upload Large Files to heroku from a GitHub repository?
Im trying to upload Large files from GitHub respository to my heroku app. This files are uploaded correctly to the repository through LFS method. In Heroku the deployment method is already connected to my github repository. The problem is that the files are not uploaded correctly to Heroku, due to the size of these files, and therefore the python script (views.py) that must read these files, cannot find them. At the end, the deployment is unsuccessful and none of the files are uploaded correctly. The sizes of this 3 files are: 40.7 mb, 65.1 mb and 227 mb -
Django psycopg2.errors.StringDataRightTruncation: value too long for type character varying(200)
Facing the above error when running the django app. What exactly needs to be changed though? The comment_body = models.TextField() aspect most probably is the culprit since it stores reddit comments which can be of varying lengths. Models.py from django.db import models # Create your models here. class Subreddit(models.Model): # Field for storing the name of a subreddit subreddit_name = models.CharField(max_length=200, unique=True) # Field for storing the time the model object was last saved last_updated = models.DateTimeField(auto_now=True) class Submission(models.Model): subreddit = models.ForeignKey(Subreddit, on_delete=models.CASCADE) # The Reddit submission id of the object submission_id = models.CharField(max_length=200, unique=True) # Reddit Submission URL url = models.URLField(max_length=200) # Reddit Submission Title title = models.CharField(max_length=200) class SubmissionComment(models.Model): # Parent submission object submission = models.ForeignKey(Submission, on_delete=models.CASCADE) # Text of the comment comment_body = models.TextField() class Meme(models.Model): memeurl = models.URLField(max_length=200) -
How do I change labels for a dropdown in a Django form?
I have a form that asks the user to choose an origin and destination from a drop down. However, the labels are not what I want them to be. I would like to change this. Models.py: class locations(models.Model): id = models.AutoField(primary_key=True) location = models.TextField() class drones(models.Model): origin = models.ForeignKey('locations', models.PROTECT, null=True, related_name='destination_id') destination = models.ForeignKey('locations', models.PROTECT, null=True, related_name='origin_id') Views.py: def book(request): form = BookForm(request.POST or None) context = { "form": form } return render(request, '../../drone_system/templates/drone_system/book.html', context) Book.html: {% extends "drone_system/base.html" %} {% block content %} <nav class="mx-auto card w-25" style=text-align:center;border:none;padding-top:12%> <form action="book" method="POST">{% csrf_token %} <h3 style="padding-bottom: 10px">Book</h3> <div class="form-group"> <div> <label for="Origin">Origin</label> {{ form.origin }} <br> <label for="Destination">Destination</label> {{ form.destination }} </div> </div> <button type="submit" class="btn btn-primary btn-lg btn-block">Book</button> </form> </nav> {% endblock %} Forms.py: from django import forms from django.forms import ModelForm from .models import drones class BookForm(ModelForm): class Meta: model = drones fields = ['origin', 'destination'] widgets = { 'origin': forms.Select( attrs={ 'class': 'my-1 mr-2', }, choices=((1, 'London'), (2, 'Plymouth'), (3, 'Swansea'), (4, 'Birmingham'), (5, 'Manchester'), (6, 'Edinburgh'), (7, 'Belfast')) ), 'destination': forms.Select( attrs={ 'class': 'my-1 mr-2', }, choices=((1, 'London'), (2, 'Plymouth'), (3, 'Swansea'), (4, 'Birmingham'), (5, 'Manchester'), (6, 'Edinburgh'), (7, 'Belfast')) ) } As you can … -
Django ManyToMany Field Not Accepting Correct Model
I'm trying to make a manytomany field from a model that is not the model that the manytomany field will contain a list of. e.g. class Following(models.Model): following_id = models.AutoField(primary_key=True) following_user = models.ForeignKey(User, models.DO_NOTHING, related_name="following_user") following = models.ManyToManyField(User, related_name="following") This looks all good to me, but when I try to enter the shell and do something like User.following.add(OtherUser), I get an error saying that it was expecting OtherUser to be an instance of Following. Why is this? Did I not specify that the ManyToManyField was storing User instances when I declared the following variable? models.ManyToManyField(**User**, related_name="following") -
Reconciling application code structure vs linux server deployed code
I recently started work for a small outfit (lets call it xes) building an internal tool. I was given access to three repositories: xes-api xes-ui xes-identity-server The ui is a javascript application built in Angular, the api is a python django application, and the identity server is an asp.net application. The general structure the asp.net identity server is the initial application that is rendered, then upon login it is redirected to the angular application and the django api is used for any data transfer to an sql db. Originally, there were three developers working in each one of the three applications, respectively. All three of the developers are no longer with the team, and documentation is sparse so I'm left to fend for myself. In terms of understanding the intricacies of the code base - I've ramped up fairly quickly. However, my question lies in the way that .dll files and linux servers work. Apparently (anthithetical to best practices) we are not deploying our application via manual or automated deploy processes from the repository, I am expected to ssh into a linux server and then use an FTP client (winSCP was suggested) to copy the locally bundled build content from … -
Adding data to the database from the front-end in django
I am writing a small blog and I will like to have a page through which I will be updating the website without going to the admin panel but it seems am not getting something right. I've writing a view function but it is not responding yet. Am still a newbie This is my views.py file def upload(request): if request.method == 'POST': AUDIO_FILE_TYPE = ['wav', 'mp3', 'ogg'] IMAGE_FILE_TYPE = ['png', 'jpg', 'jpeg'] form = UserMusicForm(request.POST or None, request.FILES or None) if form.is_valid(): form.save(commit=False) form.artist = request.POST.get('artist') form.title = request.POST.get('title') form.thumbnail = request.POST.FILES('thumbnail') form.audio_file = request.POST.FILES('audio_file') form.music_tag = request.POST.get('music_tag') messages.success(request, 'has been successfully uploaded') if form.thumbnail.url.split('.')[-1] not in IMAGE_FILE_TYPE: context = { "form": form, "message": "Image file must be PNG, JPG, or JPEG" } return render(request, "music/upload1.html", context) if form.audio_file.url.split('.')[-1] not in AUDIO_FILE_TYPE: context = { "form": form, "message": "Audio file must be WAV, MP3, or OGG" } return render(request, "music/upload1.html", context) print("Remaining save") form.save() return redirect('/') else: form = UserMusicForm(request.POST or None, request.FILES or None) context = { "form": form, "title": "Upload Your Song", } return render(request, "music/upload1.html", context) This is my html file <div class="login-box"> <h2>Upload Your Song</h2> <form action="" method="POST">{% csrf_token %} <div class="user-box"> <input type="text" name="artist" required="required"> … -
How to auto-upload an image from django app to aws s3
When a user creates or registers for a new account on my website, an image is created(generated) and is supposed to be uploaded to the s3 bucket. The image is successfully created(verified by running the ls command on the server in the media directory) but it's not getting uploaded to s3. However, when I try uploading an image for a user account from the admin panel, changes are correctly reflected in s3 (i.e newly uploaded image from admin panel is shown in s3 bucket's directory, but this is not feasible as the users cannot be given admin panel access). I aim to auto-upload the generated image to the s3 bucket when a new account is created. Here's some related code. views.py def signup(request): if request.method == "POST": base_form = UserForm(data=request.POST) addnl_form = AddnlForm(data=request.POST) if base_form.is_valid() and addnl_form.is_valid(): usrnm = base_form.cleaned_data['username'] if UserModel.objects.filter(user__username=usrnm).count()==0: user = base_form.save() user.set_password(user.password) user.save() #print(img) addnl = addnl_form.save(commit=False ) addnl.user = user img = qr.make_image() #create a qr code image, full code not included. img.save('media/qrcodes/%s.png'%usrnm) addnl.qr_gen = 'qrcodes/%s.png'%usrnm addnl.save() else: messages.error(request,base_form.errors,addnl_form.errors) else: base_form = UserForm() addnl_form = AddnlForm() return render(request,'app/signup.html',{'base_form':base_form,'addnl_form':addnl_form} ) models.py class UserModel(models.Model): . . . qr_gen = models.ImageField(upload_to='qrcodes',default=None,null=True,blank=True) settings.py DEFAULT_FILE_STORAGE = 'project.storage_backend.MediaStorage' storage_backend.py from storages.backends.s3boto3 … -
Trigger image upload to s3 from django app when new account is created
When a user creates a new account on my website, an image is created(generated) and is supposed to be uploaded to s3. The image is successfully created(verified by running the ls command on the server in the media directory) but it's not getting uploaded to s3. However, when I try uploading an image for a user account from the admin panel, changes are correctly reflected in s3 (i.e newly uploaded image from admin panel is shown in s3 bucket's directory). I aim to auto-upload the generated image to the s3 bucket when a new account is created. views.py def signup(request): if request.method == "POST": base_form = UserForm(data=request.POST) addnl_form = AddnlForm(data=request.POST) if base_form.is_valid() and addnl_form.is_valid(): usrnm = base_form.cleaned_data['username'] if UserModel.objects.filter(user__username=usrnm).count()==0: user = base_form.save() user.set_password(user.password) user.save() #print(img) addnl = addnl_form.save(commit=False ) addnl.user = user img = qr.make_image() #create a qr code image, full code not included. img.save('media/qrcodes/%s.png'%usrnm) addnl.qr_gen = 'qrcodes/%s.png'%usrnm addnl.save() else: messages.error(request,base_form.errors,addnl_form.errors) else: base_form = UserForm() addnl_form = AddnlForm() return render(request,'app/signup.html',{'base_form':base_form,'addnl_form':addnl_form} ) models.py class UserModel(models.Model): . . . qr_gen = models.ImageField(upload_to='qrcodes',default=None,null=True,blank=True) settings.py DEFAULT_FILE_STORAGE = 'project.storage_backend.MediaStorage' storage_backend.py from storages.backends.s3boto3 import S3Boto3Storage class MediaStorage(S3Boto3Storage): location = 'media' default_acl = 'public-read' file_overwrite = False Please help me find a solution to this problem. -
can't login with normal user account in django
I'm workin on an app where I have a personalized User model, I can use the superuser to login but when I try with a normal user I get error of wrong password and user name. when I look to data of the user I find that the password of normal users isn't hashed. The models definition models.py: from django.db import models from django.contrib.gis.db import models from phonenumber_field.modelfields import PhoneNumberField from django.contrib.gis.db import models as gis_models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from .managers import EmployeeManager class Employee(AbstractBaseUser, PermissionsMixin): PERMANENT = 'Per.' TEMPORAIRE = 'Tem.' VIREMENT = 'Vir' ESPECES = 'Esp' TYPE_OF_CONTRACT = [ (TEMPORAIRE,'Temporaire'), (PERMANENT,'Permanent'), ] PAYMENT_MODE = [ (VIREMENT,'Virement'), (ESPECES,'Especes'), ] first_name = models.CharField(max_length=128, blank=False, null=False) last_name = models.CharField(max_length=128, blank=False, null=False) registration_number = models.PositiveSmallIntegerField(unique=True, blank=False, null=False) email = models.EmailField() driving_licence = models.PositiveIntegerField(blank=True, null=True) recruitment_date = models.DateField(auto_now=False, auto_now_add=False, blank=True, null=True) phone = PhoneNumberField(blank=True, help_text='numéro de telephone', null=True) is_exploitation_admin = models.BooleanField(default=False) is_supervisor = models.BooleanField(default=False) is_controlor = models.BooleanField(default=False) is_driver = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=True) USERNAME_FIELD = 'registration_number' REQUIRED_FIELDS = ['first_name', 'last_name', 'email'] objects = EmployeeManager() def __str__(self): return (self.first_name) class Supervisor(Employee): zone_name = models.CharField(max_length=128, blank=True) def __str__(self): return (self.last_name) the template of the login is: {% extends 'Drivers_App_Management/base.html' %} … -
Aldatılıyorum ne yapmalıyım?
Aldatılıyorum! Ne yapmalıyım? diyorsanız bu yazı tamda sizin için hazılandı. Ülkemizde aldatılan, ihaneti kanıtlamaya çalışan ve aldatıldığını ispat etmek isteyen insanlar yadırganamayacak kadar fazla. İhanete uğramak, aldatılmak dünyanın en kötü hislerinden biri olsa gerek. Sevdiğiniz ve güvendiğiniz insanlardan asla bir aldatılmayı beklemeseniz de; dünyada ne kadar çok sayıda insanın başına geldiğini bilseniz çok şaşırırdınız. Ne yazık ki aldatılan, ihanete uğrayan kişi, gerçekleri en son öğrenen oluyor. Aldatılan kişinin dünyası başına yıkılıyor, kendini ve ilişkisini sorgulamaya başlıyor. Sıklıkla suçluluk duyguları, öfke de hissedilen duygular arasında oluyor. Oysa ki aldatılmak herkersin yaşayabileceği bir olay. Aldatmanın güzeli çirkini, genci yaşlısı, kadını erkeği olmuyor. Her zaman her insanın başına gelebilir. Aldatılma nedeni ile boşanma istatistiklerine bakıldığında, geniş bir insan profilini kapsadığını daha iyi görebiliriz. O yüzden ben aldatıldım diye üzülmenize ve eksikliği kendinizde aramanıza gerek yok. Ancak gerçek olan bir şey var ki, o da herkesin hayatındaki gerçekleri bilme hakkı. Gerçekleri bildiğiniz zaman, hayatınızın bundan sonrasına nasıl ve kiminle devam edeceğinize karar vermeniz de kolaylaşır. Kanunlara göre evli iseniz sadakatsizliği öğrendiğiniz süreden 6 ay içinde, daha sonra öğrendiyseniz de 5 ay içinde boşanma davası açma hakkınız vardır. Siz de hayatınızdaki kişinin gizli gizli aldatıldığınızdan mı şüpheleniyorsunuz? İşinin ehli, profesyonel aldatma ispatı hizmeti için özel … -
chat socket closed unexpectedly
I'm truly sorry, I do not know how I share code here. Hello.. I watched the video of making chat application from youtube with django. Even though I follow the same procedures there, I am getting an error. When I try send a message... click button(message look like send but... no) and then message doesn't show up page.. and I click F12 , and consele say like this; Error Like; Chat socket closed unexpectedly.. Would anyone help me please? Thx <3 HERE CODES; Project = justchat (python manage.py startproject justchat) app = chat (python manage.py startapp chat) my setting.py ; (I'll just show the things I added) enter code here STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] WSGI_APPLICATION = 'justchat.wsgi.application' ASGI_APPLICATION = 'justchat.asgi.application' CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, } and of course I added APPLICATIONS.. 'chat' and 'channels' justchat/routing.py; enter code here import os from channels.routing import ProtocolTypeRouter from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'justchat.settings') application = ProtocolTypeRouter({ "http": get_asgi_application(), # Just HTTP for now. (We can add other protocols later.) }) justchat/asgi.py enter code here import os from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter from django.core.asgi import get_asgi_application import chat.routing … -
How do I parameterize the django url using router.register?
I am newbie in Django. So this might be a trivial question. I have been been building urlpatterns as following router = DefaultRouter() router.register('posts', views.PostViewSet) urlpatterns = [ path('', include(router.urls)) ] This creates URLs like api/posts and so on. Now, I am trying to add a voting model to this.. For which I want to create URL like api/posts/<id>/vote But I don't want to create a path like urlpatterns = [ path('', include(router.urls)), path('posts/<int:pk>/vote', views.SomeView) ] Is there a way to do this via router.register way? -
Update an order after POST method Django Rest Framework
I just started learning Django Rest Framework together with React and i am stuck on this problem for a couple of weeks now. Hope you guys can help me out.. Here's what i am trying to achieve: When a user clicks on 'Buy Now' there will be an order created with the status of the order set to open. This all works fine. My Orders model looks like this: class Orders(models.Model): userID = models.CharField(max_length=30) pakket = models.CharField(max_length=30) price = models.CharField(max_length=30) created_at = models.DateTimeField(default=one_hour_later) status = models.CharField(max_length=30) orderID = models.CharField(max_length=30) user = models.EmailField(max_length=120) def __str__(self): return self.user My serializer called OrdersSerializer looks like this: class OrdersSerializer(serializers.ModelSerializer): class Meta: model = Orders fields = '__all__' read_only_fields = ('user','status','orderID','userID') After the status of the order has changed (the user made the purchase or not) my webhook is called (a POST) and i am retreiving the order by the id which is POSTED to the webhook. This is all taken care of by using an API client (mollie_client). This all works fine too. My View looks like this: class OrderStatusView(ListCreateAPIView): serializer_class = OrdersSerializer queryset = Orders.objects.all() permission_classes = [AllowAny,] def post(self, request): data = request.data payment_id = data['id'] payment = mollie_client.payments.get(payment_id) if payment.is_paid(): return … -
How to add check on admin side actions in django?
Here i'm using django latest verion which is 3.1.4 and I just want to add condition in django admin side. I just wanted to return some text in terminal if i update my model from admin panel. In my case user submit kyc form admin person approved that form user will get notification on approval. (Right now I just want to print some message when admin update his kyc by updating his kyc form by updated approved boolean field. In short Just wanted to show message when admin updates any model in django admin side. admin.py class KycAdmin(admin.ModelAdmin): list_display = ['__str__','owner'] class Meta: model = KycModel def post(self,request): response = "i'm updated" print(vu) return vu admin.site.register(KycModel,KycAdmin) If more detail is require then you can just tell me in a comments.