Using External HTML files in Django
Hi, I have few html files which are not part of my django project templates directory. I want to render these html files as a response into some url. Could someone help if you have any idea? I tried using {% include %} and it gave TemplateDoesNotExist error. -Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/470e1ec2-58c3-4682-8698-7e7afe258c37n%40googlegroups.com.
Re: Using External HTML files in Django
Thanks Mike. It worked ! On Tuesday, May 3, 2022 at 9:32:26 AM UTC+5:30 Mike Dewhirst wrote: > On 3/05/2022 8:44 am, Hazho Human wrote: > > Why not serving that specific URL with Nginx or Apache? > > On Tue, 3 May 2022 at 03:15, Santhosh sridhar > wrote: > >> Hi, >> >> I have few html files which are not part of my django project templates >> directory. >> I want to render these html files as a response into some url. >> >> Could someone help if you have any idea? >> >> I tried using {% include %} and it gave TemplateDoesNotExist error. >> > > In your settings file try naming the directory where the html files exist > so that Django's template engine knows to look there. > > TEMPLATES = [ > ... > { > ... > "DIRS": ["./path/to/templates", "./path/to/htmlfiles", ...], > ... > }, > ] > > Don't know if that will work if the html files are outside your project > scope and there will be permissions to consider etc > > >> -Santhosh >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/470e1ec2-58c3-4682-8698-7e7afe258c37n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/470e1ec2-58c3-4682-8698-7e7afe258c37n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAAtm9hvOd44zihVirJ2P0LyL6F1LW-2ikn01G8QOBQBcb3RjsQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/django-users/CAAtm9hvOd44zihVirJ2P0LyL6F1LW-2ikn01G8QOBQBcb3RjsQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > > -- > Signed email is an absolute defence against phishing. This email has > been signed with my private key. If you import my public key you can > automatically decrypt my signature and be sure it came from me. Just > ask and I'll send it to you. Your email software can handle signing. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4358f0ff-dbc1-4647-84dd-388ff95a7446n%40googlegroups.com.
Django values_list queryset returns queryset object instead of list
Hi, I have a table named View, I'm filtering values like this : views = View.objects.all().values_list('name',flat=True).order_by('id') I get the output as instead of list of the names. So I face error when try to parse it in jquery : jQuery.parseJSON(JSON.stringify("{{views|safe}}".replace(/'/g, '"').replace(/u"/g, '"').replace(/"/g, '"'))); it gives me the result as -- > . How to fix this? Appreciating any help. Regards, Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93ee9e2e-4f23-4de5-bd31-3dba75d5d26b%40googlegroups.com.
Error while adding entries through django admin
Hi, I have registered a model in my django admin page. When I click the Add link, it throws me this error, Invalid block tag: 'change_list_object_tools', expected 'endblock' *django.template.base.TemplateSyntaxError: . I could not get any solution. Appreciating someone's help.* *Regards,* *Santhosh* -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82a9e589-680e-4abc-a7f5-844f2bc88b97%40googlegroups.com.
Count the number of emails sent everyday
Hi, I am working on django and I trigger emails to multiple email IDs in different scenarios, Is there a way to get the count of emails sent everyday instead of storing it in tables. Regards, Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b2ef2992-ed9c-45f5-86ad-06e0feb76085%40googlegroups.com.
Embed an image in email Django
Hi, I am using Django's Email message module to trigger an email with an embed image from my static folder. Could someone help? Below is the code that I have used. Code : recipient_list = ['a...@gmail.com'] from_email = 'a...@gmail.com' message = '' path = "{% static 'images/Welcome_image.jpg' %}" //*Using this image in the below html* message += "\ \ \ \ \ \ \ \ \//*Using this image here but it is not rendered properly.* \ \ \ \ \ \ \ Hi User,\ Welcome to the world.\ \ \ \ \ \ \ \ \ \ \ \ "%(path) subject = "Welcome to the place!" try: msg = EmailMessage(subject, message, from_email, recipient_list) msg.content_subtype = "html" # Main content is now text/html if any(recipient_list): msg.send() except Exception: print("Exception while sending mail") -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f72cbde4-66f5-47f6-b133-dad3787f33b8%40googlegroups.com.
Embed an image in email Django
Hi, I am using Django's EmailMessage module to trigger an email with embedded image from the static directory path. Somehow the image is not rendering properly in the triggered email. Please find the below code and appreciating your help. Thanks, Santhosh *Code:* recipient_list = ['a...@gmail.com'] from_email = 'a...@gmail.com' message = '' path = "{% static 'images/Welcome_image.jpg' %}" //*Using this image in the below html* message += "\ \ \ \ \ \ \ \ \ #*Using this static path here* \ \ \ \ \ \ \ Hi User,\ Welcome to the world.\ \ \ \ \ \ \ \ \ \ \ \ "%(path) subject = "Welcome to the place!" try: msg = EmailMessage(subject, message, from_email, recipient_list) msg.content_subtype = "html" # Main content is now text/html if any(recipient_list): msg.send() except Exception: print("Exception while sending mail") -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ebc6368-bc16-4d6b-9f4b-77af1f5fe377%40googlegroups.com.
Integrate React with Django
Is it possible to integrate React Js framework with Django? What is the advantage of using react over Ajax with Django? Any example would help me. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d682ecc9-4550-45e9-81b1-94372553dee1%40googlegroups.com.
How to use django-request module to log all the user activities in a table?
I'm using Django 1.8 version. Need to know how to use django-request or any other module to capture the all the user activities of a website. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f9666901-ae28-4449-be41-378be1e2b73f%40googlegroups.com.
Display Multiselect bootstrap drop-down value in div with checkbox options
Hi, I have a multiselect bootstrap drowdown. I want to display the selected values from a drop-down in a separate div as rows with multiple checkboxes to select. How I can proceed for this? Like I have selected 3 items(I1,I2,I3) from dropdown then i should display all the three items as rows with 5 checkboxes to select in each row. The count of checkbox is fixed. This div should not be available on page load and clearing the values of dropdown. Any idea would help.Thanks. JSFiddle Link : http://jsfiddle.net/dcskfowp/ Thanks, Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e51085db-a8c7-4023-b4e6-4363a3b51d68%40googlegroups.com.
Prefill Checkboxes and send values to backend
Hi, I have a multiselect drowdown. I want to display the selected values from a drop-down in a separate div as rows with multiple checkboxes to select. I have tried this code in JSFiddle, jsfiddle.net/k7nL3s2z . Please let me know if there is any better approach. I need to pass this data(Selected dropdown value with selected checkbox for that row) to backend. Also, the next step would be if Mustard is selected then I need to prefill A,B and C checkboxes already and option to check the rest of the boxes(Will get the list of list of checkboxes to prefill from backend). How to have prefilled checkboxes? Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/048cfee1-495f-4657-ba2a-6a92f71e4177%40googlegroups.com.
Integrate Django with React
Is there a way to integrate React JS framework with Django? How to do that? What is the advantage of using such frontend frameworks over normal ajax? Any help or explanation would be helpful. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0d673a79-cbb3-4ef6-a490-48687a680be2%40googlegroups.com.
specefic field(s) for each query.
You can query like this in Django, say the table name is A and column name is name. A.objects.all() will give all the objects and A.objects.filter(name='Django') will give all the objects whose name is Django. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/38de7a8f-0711-4137-8bde-d603c5fa97e9%40googlegroups.com.
specefic field(s) for each query.
You can query like this in Django, say A is the table name and B is the columns. A.objects.all().values('B') or A.objects.all().values_list('B',flat=True) Regards, San -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/81764917-e19d-4a71-bf3b-88f583b4aa5b%40googlegroups.com.
Create Dashboard for CSV data
I have a csv file : each line having some inputs and some status. I need to read this csv file and present the data as a dashboard with some charts. I came across to use chart js plugin. Is there any better approach? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/70da7790-e3ed-4320-b374-c7a5d1a1f95a%40googlegroups.com.
django-request to log user statistics
Hi All, I am trying to use django_request module to login the user statistics. I have two versions of django-request 1.5.2 and 1.5.5 installed and I could see both the egg files inside site-packages directory. But when I tried to use 'request' in my INSTALLED_APPS settings I am getting an error. Could someone help?? Regards, Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf5f3306-2fc6-4760-a3b7-82aa705f4db9%40googlegroups.com.
Upgrading django from 1.8 to 2.2.0
Hi, Im upgrading my django project from 1.8 to 2.2.0. I have done the below changes. 1. Added on_delete to all the Foreign Key fields 2. Changed the url reverse import as from django.urls import reverse 3. Included path/re_path instead of url in all the app's url files. 4. Changed the MIDDLEWARE_CLASSES import in settings files to MIDDLEWARE = {} I tried to run the server, still it says "TypeError: __init__() missing 1 required positional argument: 'on_delete' and it is pointing to /usr2/santhosh/myproject/myapp/migrations/0002_abc.py What should I do now? Do I need to delete all the migration files and re-run python manage.py migrate or what?? Help me you are aware. Regards, Santhosh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b907f25b-ffd3-462b-b3e9-5d87a20dd942%40googlegroups.com.
Invalid Literal for int() with base10 error
I have a model called Project, class Project(models.Model): name = models.CharField(max_length=50, unique=True) technology = models.ForeignKey(Technology, related_name='projects',on_delete=models.CASCADE) chipName = models.CharField(max_length=50) is_swarm = models.NullBooleanField(default=0, blank=True, null=True) p_state = models.ForeignKey(ProjectStage, related_name='projects', default=6,on_delete=models.CASCADE) project_poc = models.TextField() bto_date = models.DateField(blank=True, null=True) mto_date = models.DateField(blank=True, null=True) description = models.CharField(max_length=500, null=True) last_updated = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name def save(self, *args, **kwargs): """ Overriding base save method to set the default values for few fields based on user inputs. """ if not self.mto_date: self.mto_date = self.bto_date + timedelta(days=15) super().save(*args, **kwargs) In my views.py, I am trying to get Projects.objects.all() but I get this error : ValueError: invalid literal for int() with base 10: b'17 04:47:27.864928' What could be the issue? I am using Django 2.2.1 and Python 3.6 versions. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/507aa871-5f40-4e87-acef-c5871f742767%40googlegroups.com.