Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: How To Add To Existing Filter
I am trying to create a page where the user can filter out products based on genres and keywords but I don't like the way that the ModelMultipleChoiceFilter looks so I am trying to do this using buttons because that looks a lot better. I have created a form for each genre and keyword using a for loop in the templates so that I can do a GET request to filter the queryset. I could pass in the id of the genre button that is clicked but that would only filter one genre and I want the user to be able to choose multiple genres to filter at once. So I am trying to find a way to add muliple filters on to the query that already exists: is there a way to add filters on to an existing query? I have looked on stackoverflow and some one said that it could be done by creating a dictionary with each genre filter and pass that into the filtering so maybe that could work? Here is some relevant info: templates: <div class="filters_label">Genres</div> <div class="filter_buttons_container"> {% for genre in genre_list %} <form class="filter_sub_form" id="{{ genre }}" action="{% url 'find' %}" method="GET"> <button … -
How do I make a query with CASE statement on WHERE clause on django ORM?
I'm having some troubles trying to make a complex query on Django ORM. This is the query: SELECT "app_client"."name", "app_order"."client_id", "app_client"."country", (SUM("app_order"."grand_total") - SUM("app_order"."shipping_amount")) AS "total", COUNT("app_order"."id") AS "orders", SUM("app_order"."total_item_count") AS "products", (AVG("app_order"."grand_total") - AVG("app_order"."shipping_amount")) AS "avg", SUM("app_order"."shipping_amount") AS "total_shipping" FROM "app_order" INNER JOIN "app_client" ON ("app_order"."client_id" = "app_client"."id") WHERE (NOT (NOT "app_client"."is_active") AND "app_order"."created_at" at time zone 'utc' at time zone (case WHEN app_client.country = 'CL' THEN 'America/Santiago' WHEN app_client.country = 'CO' then 'America/Bogota' WHEN app_client.country = 'PE' then 'America/Lima' WHEN app_client.country = 'AR' then 'America/Buenos_Aires' else 'GMT' END) BETWEEN '2020-01-01 00:00:00+00:00' AND '2020-01-31 23:59:59+00:00') GROUP BY "app_client"."name", "app_order"."client_id", "app_client"."country" ORDER BY "total" DESC; I have this query on the ORM, but I need to add the CASE statement on the WHERE clause. My ORM query: Order.objects.exclude(client__is_active=False).values('client__name', 'client__pk', 'client__country').filter(created_at__range=(self.request.GET['created_at__gte'], self.request.GET['created_at__lte'])) \ .annotate(total=Sum('grand_total') - Sum('shipping_amount')) \ .annotate(orders=Count('pk')).annotate(products=Sum('total_item_count')) \ .annotate(avg=Avg('grand_total') - Avg('shipping_amount')).annotate(total_shipping=Sum('shipping_amount')).order_by('-total') I try to do it using raw method, but it didn't work. Someone can help me please! Thanks for the help! -
store multiple inputs into single JSON as a Dictionary- Django
I am working on a project which is online printing ordering service. Here on the order page I am getting different attributes of product in radio button list in the form, and all the attributes I want to store in a single json in database. models.py class Product(models.Model): prod_ID = models.AutoField("Product ID", primary_key=True) prod_Name = models.CharField("Product Name", max_length=30, null=False) prod_Desc = models.CharField("Product Description", max_length=2000, null=False) prod_Price = models.IntegerField("Product Price/Piece", default=0.00) prod_img = models.ImageField("Product Image", null=True) def __str__(self): return "{}-->{}".format(self.prod_ID, self.prod_Name) # this is the order table , there is a "attribute_field" I wantto store the attributes in this field # as JSON. class Order(models.Model): order_id = models.AutoField("Order ID", primary_key=True) user_id = models.ForeignKey(User, on_delete=models.CASCADE, null=False, verbose_name="Customer ID") prod_id = models.ForeignKey(Product, on_delete=models.CASCADE, null=False, verbose_name="Product ID") quantity = models.ImageField('Product Quantity', max_length=10, default=500) attribute_value = models.CharField("Item Details JSON", max_length=2000, null=False) order_date = models.DateField("Order Date", auto_now_add=True, null=False) order_job_title = models.CharField("Name of Company/Business", max_length=100, null=False) order_desc = models.CharField("Details for Product", max_length=1000, null=False) product_img = models.ImageField("Template Image", null=False) address = models.CharField("Customer Address ", max_length=100, null=False) state = models.CharField("Customer State", max_length=30, null=False) city = models.CharField("Customer City", max_length=30, null=False) postal_code = models.IntegerField("Area Pin Code", null=False) order_price = models.DecimalField(max_digits=8, decimal_places=2, default=0000.00) class ImageTemplate(models.Model): temp_id = models.AutoField("Template ID", primary_key=True, auto_created=True) temp_img … -
Email not send from server office 365
SMTPAuthenticationError at /clientportal/open_demoac (535, b'5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant. Visit aka.ms/smtp_auth_disabled for more info. [AM0PR04CA0059.eurprd04.prod.outlook.com]') Request Method: POST Request URL: https://hme158.com/clientportal/open_demoac Django Version: 2.2.6 Exception Type: SMTPAuthenticationError Exception Value: (535, b'5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant. Visit aka.ms/smtp_auth_disabled for more info. [AM0PR04CA0059.eurprd04.prod.outlook.com]') Exception Location: /usr/lib/python3.7/smtplib.py in auth, line 642 Python Executable: /home/divsolution/HNXINLUAN/hnxenv/bin/python3 Python Version: 3.7.9 Python Path: ['/home/divsolution/HNXINLUAN/HME/new_crm', '/home/divsolution/HNXINLUAN/hnxenv/bin', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/divsolution/HNXINLUAN/hnxenv/lib/python3.7/site-packages'] Server time: Wed, 17 Feb 2021 19:53:01 +0530 -
Search & Display Polygons on Geodjango-Leaftlet Web App
I am currently working on a Geodjango-Leaflet-Openstreetmap web app. I have around 540000 polygons of property boundaries that were drawn in Arcmap; the polygons will be imported to the web app later through Postgres+Postgis. There is a search bar on the web app. I want the user to enter a polygon's unique ID in the search bar, and the polygon to appear on the screen soon after. However, after entering the polygon's ID at the home page, the site redirects me to the results page with no polygon. Please help me fix the code. Your help will be greatly appreciated. On a separate note, what is the maximum no. of polygons that Geodjango-Leaflet & Postgres/postgis can support? According to this website , it's 67mil vertices. Is this actually correct? I'm asking because I might need to import more than the aforementioned figure in the future. results.html <!DOCTYPE html> <html> {% load static %} {% load leaflet_tags %} <head> {% leaflet_js %} {% leaflet_css %} <title>Home</title> <style type="text/css"> #gis {width: 100%;height:1080px;} </style> <script type="text/javascript" src="{% static 'dist/leaflet.ajax.js' %}" > </script> </head> <body> <h3>Welcome</h3> <br> <script type="text/javascript"> function our_layers(map,options){ var osm = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ maxZoom: 19, attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }); {% for … -
Aunt folly 'pip' and the details
I " virtualenv env_site-Access denied??" can among leap explain what's sowing on her Set Virtual environment- Setting up the virtual environment will allow you to edit the dependency which generally your system wouldn’t allow. Follow these steps to set up a virtual environment- Create a virtual environment by giving this command in cmd- virtualenv env_site C:/Users/viren>virtualenv env_site Access is denied -
send_email is slow in django, how to speed it up?
Getting an email after 10-12 mins or more, I have added email verification feature and reset password mail feature, when user register email is received in 10-12 mins which doesn't looks nice, how to get rid of this? Here is my settings.py: # EMAIL_BACKEND socket.getaddrinfo('smtp.gmail.com',587) EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = socket.gethostbyname('smtp.gmail.com') EMAIL_HOST_USER = 'zoderadmn781@gmail.com' EMAIL_HOST_PASSWORD = 'password' EMAIL_PORT = 587 EMAIL_USE_TLS = True DEFAULT_FROM_EMAIL = 'Zoder Team <noreply@zoderadmin.com>' #email verification def verified_callback(user): user.is_active = True EMAIL_ACTIVE_FIELD = 'is_active' EMAIL_VERIFIED_CALLBACK = verified_callback EMAIL_TOKEN_LIFE = 60 * 60 * 3 EMAIL_SERVER = socket.gethostbyname('smtp.gmail.com') EMAIL_PORT = 587 EMAIL_ADDRESS = 'zoderadmn781@gmail.com' EMAIL_FROM_ADDRESS = 'Zoder Team <noreply@zoderadmin.com>' EMAIL_PASSWORD = 'password' EMAIL_MAIL_SUBJECT = 'Zoder admin: Confirm Email' EMAIL_MAIL_HTML = 'verify/mail_body.html' EMAIL_MAIL_PLAIN = 'verify/mail_body.txt' EMAIL_PAGE_TEMPLATE = 'verify/confirm_template.html' EMAIL_PAGE_DOMAIN = 'http://127.0.0.1:8000/' -
Missing "sessionid" cookie using SessionAuthentication
I got the issue that the sessionid cookie seems not to be saved after deploying on the Amazon EC2. In the setting.py I wrote REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', ) } I login via a rest call that is defined such as from django.contrib.auth import authenticate, login, logout from django.views.decorators.csrf import csrf_protect from django.utils.decorators import method_decorator from rest_framework import status, views from rest_framework.response import Response class LoginView(views.APIView): @method_decorator(csrf_protect) def post(self, request): user = authenticate( username=request.data.get("username"), password=request.data.get("password")) if user is None or not user.is_active: return Response({ 'status': 'Unauthorized', 'message': 'Username or password incorrect' }, status=status.HTTP_401_UNAUTHORIZED) return Response({"username": request.data.get("username")}) class LogoutView(views.APIView): def get(self, request): logout(request) return Response({}, status=status.HTTP_204_NO_CONTENT) On the local windows machine that works well and the sessionid cookie is available and used for all rest-calls. However, using the Amazon EC2, that cookie is not created. Can someone help? THX Lazloo -
How to set ForeignKey attribute knowing just the attribute name and related object's ID?
Is there a way to set ForeignKey attribute value knowing just the name of the attribute and the ID of the ForeignKey related object? I tried to do this using setattr(): setattr(instance, 'product', 41) The result is: Cannot assign "41": "MyModel.product" must be a "Product" instance. -
pass data to form filed in django templae
How can I pass data to form fields in django templat ? , for example I have below code in my project: <td class="col-3"> {{form.number|as_crispy_field}} </td> Can I use <td class="col-3"> {{form.number}} = 10 </td> in django template ? -
Django Gunicorn error : "Active: failed (Result: exit-code)"
I am trying to deploy my server inside a linode server.What i have binded gunicorn with my project,i added necessary codes inside "gunicorn.service" file.And still i am getting this error: gunicorn status (welpieenvironment) root@li2180-35:~/welpie# sudo systemctl status gunicorn ● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: Active: failed (Result: exit-code) since Wed 2021-02-17 13:35:00 UTC; 19s ago Main PID: 709 (code=exited, status=203/EXEC) Feb 17 13:35:00 li2180-35.members.linode.com systemd[1]: Started gunicorn daemon Feb 17 13:35:00 li2180-35.members.linode.com systemd[709]: gunicorn.service: Fai Feb 17 13:35:00 li2180-35.members.linode.com systemd[709]: gunicorn.service: Fai Feb 17 13:35:00 li2180-35.members.linode.com systemd[1]: gunicorn.service: Main Feb 17 13:35:00 li2180-35.members.linode.com systemd[1]: gunicorn.service: Faile Note:Sorry for the unfinished sentences.This is what i got from my command. Here is what i have done: binding operation (welpieenvironment) root@li2180-35:~/welpie# gunicorn --bind 0.0.0.0:8000 welpie.wsgi [2021-02-17 13:36:02 +0000] [742] [INFO] Starting gunicorn 20.0.4 [2021-02-17 13:36:02 +0000] [742] [ERROR] Connection in use: ('0.0.0.0', 8000) gunicorn.service file [Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=/root/welpie ExecStart=/root/welpie/welpieenvironment/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/welpie/welpie.sock welpie.wsgi:application [Install] WantedBy=multi-user.target Virtual Environment files Project Directory What can i do to solve this problem? -
react - create schedule (semester)
I'm new to React, I using react to build a web that retrieves data from Django, the data represents information about the courses such as day and hours, I want to display for each student his schedule for the semester in timetable (The schedule is the same for all the weeks). How do you recommend doing this? -
Some images can't be loaded, but it makes no sense
Some images can load perfectly, but some can't. The problem is, they are in the same directory, following a same naming pattern. For example, this picture can load: but this can't: I'm expecting it to be something like this: but actually, there turn out to be NOTHING. No broken-image icon, just gone, like it never existed: but when I right clicked on the image link(from the source code panel) and opened it in a new tab, the image could be shown normally: It seems like that the broswer be like: "you know what, I don't want to work for no reason. Wait, you want to see this image so eagerly? Fine, fine, I will show it..." Here is the html template: <!DOCTYPE html> <html> <body> <h1>{{ metamodel.metamodel_name }}</h1> {% for group in metamodel.group_set.all %} <h2>{{ group.group_name }}</h2> {% for product in group.product_set.all %} <a href="{% url 'exhibition:models' product.id %}"> <img src="{{ product.picture.url }}"> <p>{{ product.model }}</p> </a> {% endfor %} {% endfor %} </body> </html> The view function: def show_products(request, metamodel_id): try: context = { 'metamodel': Metamodel.objects.get(pk=metamodel_id), } except Metamodel.DoesNotExist: raise Http404("Metamodel Does NOT exist !") return render(request, 'exhibition/show_products.html', context) I'm using Firefox 85 on Windows 10. I also tried … -
How to reached joined table information? -- Django Lookups
I would like to display number of the products that are cheaper than the minimmum price of the competitor products.Also, products are need to be dynamic towards user. How can I handle it? Models: class Product(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE,related_name='products') category = models.CharField(max_length=120) brand = models.CharField(max_length=120) product = models.CharField(max_length=120) price = models.DecimalField(decimal_places=2,max_digits=100) stock = models.BooleanField() class Comp_Product(models.Model): product = models.ForeignKey(Product,on_delete=models.CASCADE, related_name="comp_products") competitor = models.URLField() price = models.DecimalField(decimal_places=2,max_digits=100) change = models.FloatField() stock = models.BooleanField() last_update = models.DateField(auto_now_add=True) view: class DashboardList(ListView): template_name='dashboard_by_user.html' def get_queryset(self): return Product.objects.filter(user=self.request.user) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) Products = context['object_list'] context['num_of_cheapest'] = Products.filter(price__lt=Products.annotate(Min('comp_products__price')).count() return context -
Django-Filter between two dates
Unfortunately I'm stuck and can't find a working solution yet, my Model looks like this: class SubOperatorAssignment(models.Model): operator = models.ForeignKey(Operator, on_delete=models.CASCADE) sub_operator = models.ForeignKey(SubOperator, on_delete=models.CASCADE) start_date = models.DateField(blank=False, null=False, verbose_name='Start Date') end_date = models.DateField(blank=False, null=False, verbose_name='End Date') And I would like to let the User select a Date (with the Django-Filter Library) and check in the Filter if the given Date is between the Models Start and End Date. Unfortunately Date Filter only accepts one field name and there seems to be no lookop_expr for between. Thankful for any hints on how to achieve this! -
Django redirect in views if context don´t exist
I have a template that needs one session variable to show the information. I want to configure my template in case the information don´t came to the template then redirect the user to other template. This is how my code looks now and the error that return class Feedback(TemplateView): template_name = 'cursos/pu.html' def get(self, *args, **kwargs): user_id = self.request.session.get('user_id') username = self.request.session.get('username') password = self.request.session.get('password') apiKey = self.request.session.get('apiKeyUser') complete_name = self.request.session.get('complete_name') context = super(Feedback, self).get_context_data(**kwargs) context['firstname'] = self.request.session.get('firstname') if self.request.session['quizResult'] != None: context['quizResult'] = self.request.session['quizResult'] self.request.session['quizResult'] = None self.request.session.modified = True return context else: return redirect('core:home') #feedback return context The error is: 'dict' object has no attribute 'status_code' How can I modify that to redirect to home in case self.request.session['quizResult'] == None -
django import export incrementing id field by 2
I am trying to use django-import-export in admin site and below is a snapshot of the code. But when I check in database, the id field is getting incremented by 2. Not able to understand where I am going wrong. resources.py class CountriesResource(resources.ModelResource): name = fields.Field(column_name='name', attribute= "name") countrycode = fields.Field(column_name='countrycode', attribute="countrycode") currency = fields.Field(column_name='currency', attribute="currency") currencycode = fields.Field(column_name='currencycode', attribute="currencycode") cohortcountrycode = fields.Field(column_name='cohortcountrycode', attribute="cohortcountrycode") cohortcurrencycode = fields.Field(column_name='cohortcurrencycode', attribute="cohortcurrencycode") class Meta: model= Countries exclude= 'docid','displayorder','createdon','createdby','modifiedon','modifiedby','isactive','isdeleted',) skip_unchanged = True report_skipped = False # import_id_fields = ('name',) fie lds= ('name','countrycode','currency','currencycode','cohortcountrycode','cohortcurrencycode') #admin.py class CountriesAdmin(ImportExportModelAdmin): resource_class = CountriesResource list_display = ('name', 'countrycode', 'currency', 'currencycode', 'cohortcountrycode','cohortcurrencycode') list_filter = ('name', 'countrycode', 'isactive','currencycode') search_fields = ['name', 'countrycode', 'isactive','currencycode'] #db snapshot -
How to get redirected to newly created product page with Axios POST to a route I know only after object is created (uuid route)
I'm new to React and I'm trying to create a POST with AXIOS and automatically be redirected the uuid url page of the created post but I don't know that uuid until product object is created. I'm using Django Rest as backend and I use UUIDField in my models as produit id. When I create a POST with AXIOS, a product with unknown uuid object id is created. I understand that there is maybe two solution to be redirected to the page 'object/uuid_of_object/'. Maybe there is a way to automatically GET the created product object once the POST has been made ?!? This way I would get the uuid generated by Django...and would be able to redirect to the right url. If possible I don't find anything about that on the web. (maybe I search on wrong key words). I could make a GET request to the most recent created object...maybe mixed with some caracteristics known at the moment of POST request. Not a good idea in my opinion but would maybe works. There is maybe a 3rd or more solutions but I can't manage to find one. Your help on best practice would be very appreciated. Thanks a lot … -
Add a message if the fields are empty in my Django app
So I have a Django form and what I want is that it shows a message under (like in red) each field if they are not filled. I have tried adding the "error_messages" attribute to my widgets in each field but it won't work. my forms.py: class WordForm(forms.Form): Word1 = forms.CharField(error_messages={'required': 'Please enter a word'}, required = True, label= 'Word1', widget= forms.TextInput(attrs={ 'class': "form-control is-invalid", 'placeholder': 'Enter First Word' })) Word2 = forms.CharField(error_messages={'required': 'Please enter a word'}, required = True, label= 'Word2', widget= forms.TextInput(attrs={ 'class': 'form-control is-invalid needs-validation was-validated', 'placeholder': 'Enter Second Word' })) Word3 = forms.CharField(error_messages={'required': 'Please enter a word'}, required = True, label= 'Word3', widget= forms.TextInput(attrs={ 'class': 'form-control is-invalid', 'placeholder': 'Enter Third Word' })) Result = forms.CharField(label= 'Result', required=False, widget= forms.TextInput(attrs={'class': 'form-control', 'readonly': 'True'})) my form.html: <form method="post" class="needs-validation was-validated" novalidate> {% csrf_token %} <h2>Inputs</h2> {{ form.as_p }} </form> As you can see, I have added the error messages field and also the is-invalid class in the widgets but It won't do anything. I don't really know if I have to create a function, cause I have seen those feedback messages but not with the form rendering. Help is much appreciated. -
Django : Manager isn't accessible via Process instances
I have the following models : class Process (models.Model): id = models.CharField(max_length=1000, primary_key=True) processName = models.CharField(max_length=100) class Step (models.Model): id = models.CharField(max_length=1000, primary_key=True) process = models.ForeignKey(Process, on_delete=models.CASCADE) stepName = models.CharField(max_length=100) I want to access a specific Step object. I do : step=Process.objects.get(id=stepId) When I try to access an objects in step : step.objects.all() I have the following error : AttributeError: Manager isn't accessible via Process instances How can I access objects in step? -
How do I fill a html form with fields from my database in Django and postgresql?
How do I fill a html form with fields from my database in Django and postgresql? I need to select year from drop down and value of flag(0,1,2), with the combination of these two I want my form to populate from the values stored previously in the table corresponding to the above combination. -
Issues getting primary key django
I started to learn Django and I decided to create a blog to check my skills and train myself with an actual project. In my models.py there is two models : class Article (models.Model): title = models.CharField(max_length = 100) author = models.CharField(max_length = 100) date = models.DateField(auto_now=True) content = models.TextField() is_draft = models.BooleanField(default = True) def __str__(self): return self.title class Comment(models.Model): comment_author = models.CharField(max_length = 100) comment = models.TextField() article = models.ForeignKey(Article,on_delete=models.CASCADE) def __str__(self): return self.comment_author I want to display all the title and content of every articles and the numbers of comment , to do so I used a ListView. views.py : class ArticleListView (ListView): context_object_name = 'articles' model = models.Article # print(models.Article.objects.get(pk=1).models.Comment_set.all()) def get_context_data(self,**kwargs): context = super().get_context_data(**kwargs) context['title'] = models.Comment.objects.get(pk=1) # I don't know how to change this value context['id'] = self.model.id return context article_list.html : {% for article in articles %} <h2>{{ article.title }}</h2> <p>{{ article.content }}</p> <h5>Id of article is {{ id }}</h5> <h6>{{ title }}</h6> {% endfor %} I wanted to use count() on Comment so I get the numbers of comments by post. To get the list of article's comments I thought that I need the pk for each article so I can find … -
django , unable to upload file to a directory using filefield ,
am new to django . and am really confused right now . So i have a code which should upload a file to UPLOAD directory . from their it will be used for furthur processing . But currently am not able to push the file in filefield to UPLOAD directory I did a deep search but was not able to find any related solution to this . so below is my code : class Files(models.Model): files_to_upload = models.FileField(upload_to='UPLOAD/', default = None, validators=[validate_file]) path = models.CharField(max_length=100) server = MultiSelectField(choices=server_list) snippet = models.ForeignKey(Snippet, related_name = "files", on_delete=models.CASCADE) def __str__(self): return str(self.snippet) class Meta: db_table = "files" and in files.html: .<form enctype="multipart/form-data" action="{% url 'files' %}" method="POST"> i gave this too as instructed by one stack question answer . Is there any other thing i should check -
Django Admin: Values for not displayed fields
I need to manually add an entry to the database via the admin panel but give the entry some initial values: #models.py class Product(models.Model): price = models.DecimalField("price") status = models.PositiveIntegerField("status") name = models.CharField("name", max_length=31, unique=True) user = models.ForeignKey(User, on_delete=models.CASCADE,) #admin.py class ProductForm(forms.ModelForm): class Meta: model = Product fields = ["price", "name",] @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ["price", "status", "name",] list_filter = ["status",] form = ProductForm readonly_fields = ["status", "user",] Admin should be able to create a Product and give it a name and price, but the status value should be set to "manually created". I already tried this approach and this one, but did not find a solution. What is the correct way to set the status and user so that the form validates? I am not able to avoid sqlite3.IntegrityError: NOT NULL constraint failed: _TEST_Product.status using the linked posts. -
Send Emails to every user based on their notification's settings
I want to schedule Emails to be sent based on user's settings for example user would have some options like no notifications once daily at 8am twice daily at 8am and 4pm so how should i implement this based on each user's preference using cronjobs?