Watchdog & Django

2021-05-20 Thread Benjamin Schollnick
Folks,

I’m working on revamping the Gallery/viewer application that I wrote in Django.

One issue I’ve had is that it’s a dynamic on the fly thumbnail creator, but 
I’ve used a homebrew (fairly successfully) cached system to keep track of the 
directories & file contents.  Unlike many of the other gallery style 
applications I don’t require deliberate pre-scanning, the files are detected, 
and thumbnailed in realtime.  

But I realized that I can use Watchdog to simplify that logic, and eliminate 
the need for any caching.

My idea is to have a table that is cleared at every startup, and it just 
contains the directories that have been scanned for that execution of the 
program.  If watchdog has detected a change in a directory, it’s just removed 
from that table, which makes it a candidate for rescanning the next time 
someone views that directory.

But the big kicker is that I can’t find any documentation that can help me add 
watchdog monitoring into Django.  

Now, I know that Django does something similar in the Dev server (which is what 
I primarily use right now)…  And I’ve found a stackoverflow, whichs that I can 
use Signal to capture the SIGINT on shutdown (allowing me to stop watchdog )…  
I should be able to start watchdog in the __init__  file in the APP directory 
as well…  

Now this is the sample app that I used:

import sys
import time
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler

def on_created(event):
print(f"hey, {event.src_path} has been created!")

def on_deleted(event):
print(f"what the f**k! Someone deleted {event.src_path}!")

def on_modified(event):
print(f"hey buddy, {event.src_path} has been modified")

def on_moved(event):
print(f"ok ok ok, someone moved {event.src_path} to {event.dest_path}")

if __name__ == "__main__”:

#   <— startup —> 
patterns = ["*"]
ignore_patterns = None
ignore_directories = False
case_sensitive = True
my_event_handler = PatternMatchingEventHandler(patterns, ignore_patterns, 
ignore_directories, case_sensitive)

my_event_handler.on_created = on_created
my_event_handler.on_deleted = on_deleted
my_event_handler.on_modified = on_modified
my_event_handler.on_moved = on_moved

path = sys.argv[1]#"."
go_recursively = True
my_observer = Observer()
my_observer.schedule(my_event_handler, path, recursive=go_recursively)

my_observer.start()

# stop startup

try:
while True:
time.sleep(1)
except KeyboardInterrupt:
# shutdown
my_observer.stop()
my_observer.join()


Nothing fancy, just a proof of concept based on code that I found online.

Anyone have any suggestions?

I’m thinking that  I could add the startup .. stop startup to an function in 
the __init__ and run that at startup.
And that capturing the SIGINT, and when SIGINT is tripped, I can do the 
observer.stop & join?

Would it be that simple?  Am I missing something?  Is there a better way to do 
this in Django?  
I don’t want to have to stand up a celery server, if I can run this, or 
something equivalent inside of Django…

I haven’t been able to (yet) trackdown STATRELOADER, which appears to be the 
Django built-in equivalent, so I can’t tell if I can repurpose that to do this 
instead?

I’m open to suggestions…

- Benjamin

 

-- 
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/D8BB20B3-0063-4D93-BB39-A39FD66CD860%40schollnick.net.


making TemplateView.template_name point to a file NOT in the templates directory.

2021-05-20 Thread Sharif Mehedi

I do not have a django-admin project and using django views (along with 
other django submodules) in my python app, so, i do not have a directory 
structure like django projects has and I never had a templates directory in 
my app. The way we configured it, serving from templates directory is out 
of the question.

I want to know, if there's an easy solution in making django take a 
template_name as (django.views.generic.base).TemplateView.template_name 
that is (simply said) outside the templates directory.

TIA
Regards,
Sharif

-- 
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/b2291451-6d15-432d-9f35-db60e4f4e65bn%40googlegroups.com.


Re: Need guidance

2021-05-20 Thread lalit suthar
postgres ArrayField will be suitable for your requirement. Serialization 
will work the same like it works for other fields.
On Thursday, 20 May 2021 at 21:00:14 UTC+5:30 xaadx...@gmail.com wrote:

> I wanna to store multiple value in django model using DRF e.g. i have to 
> choose three days from a week. I am using django rest framework. I have 
> tried many solution but failed
>
>
>
> 1. Which field i have to implement in django  model? CharField? Postgre 
> ArrayField?
> 2. How to serialize the data to store multiple values
>
>
> 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/dccb57a6-60c5-46dd-bc07-e80b838b33e3n%40googlegroups.com.


Need guidance

2021-05-20 Thread Muhammad Shehzad
I wanna to store multiple value in django model using DRF e.g. i have to 
choose three days from a week. I am using django rest framework. I have 
tried many solution but failed



1. Which field i have to implement in django  model? CharField? Postgre 
ArrayField?
2. How to serialize the data to store multiple values


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/bc8ca439-ae30-4d26-8067-bedff3d1cd0fn%40googlegroups.com.


Re: I need web scraping to get product information from mfg sites

2021-05-20 Thread Breno Linhares
Interested
Name: Breno Pinheiro
Email Address: breno.pinhe...@ymail.com 
WhatsApp Number: +55 98 98216  4021

Thanks


Em quinta-feira, 20 de maio de 2021 às 10:01:48 UTC-3, ohidas...@gmail.com 
escreveu:

> Hello John,
>
> I am interested. Please find my details below:
>
> Name: Sefiyat Ohida
> Contact Number: +2347034777957 <+234%20703%20477%207957>
> Email Address: ohidas...@gmail.com
>
> Regards
> Sefiyat
>
> On Tue, May 18, 2021 at 3:55 PM John McClain  wrote:
>
>> Hello,
>>
>> I am looking for individuals that can set up scraping routines for me and 
>> place the results in google.docs for me.
>>
>> If interested in helping out please let me know. Some compensation for 
>> your efforts is available. There are 20+ sites needed to be scraped which 
>> is why I am seeking help with the project.
>>
>> If interested drop your name and contact details here and I'll be in 
>> touch.
>>
>> Cheers,
>>
>> J
>>
>> -- 
>> John McClain
>>
>> Cell: 085-1977-823
>> Skype: jmcclain0129
>> Email: jmccla...@gmail.com
>>
>> -- 
>>
> 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/CAN-hv_pQ67gGF10S4J1pk1CtSzmX9qqtDp_-j_Pax3tvpmeczg%40mail.gmail.com
>>  
>> 
>> .
>>
>

-- 
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/c89507c7-1860-4fd3-9cd8-254fcde35b7fn%40googlegroups.com.


Re: Can you help me solve this

2021-05-20 Thread Sharif Mehedi
I do not see anything solvable there. Maybe soak it into water! :P .Maybe, it 
will help if you can provide us with a clue to whatever you are trying to do 
and the nature of the problem you are facing in trying in doing.
   On Thursday, May 20, 2021, 7:02:25 PM GMT+6, Sameer Gedam 
 wrote:  
 
 OperationalError at /admin/products/product/add/no such table: 
main.auth_user__oldRequest Method:
POSTRequest URL:
http://127.0.0.1:8000/admin/products/product/add/Django Version:
2.0.7Exception Type:
OperationalErrorException Value:
no such table: main.auth_user__oldException Location:
C:\Users\user\.virtualenvs\trydjango-SjDXbmBR\lib\site-packages\django\db\backends\sqlite3\base.py
 in execute, line 303Python Executable:
C:\Users\user\.virtualenvs\trydjango-SjDXbmBR\Scripts\python.exePython Version:
3.9.5Python Path:
['C:\\Users\\user\\Dev\\trydjango\\src', 'c:\\python39\\python39.zip', 
'c:\\python39\\DLLs', 'c:\\python39\\lib', 'c:\\python39', 
'C:\\Users\\user\\.virtualenvs\\trydjango-SjDXbmBR', 
'C:\\Users\\user\\.virtualenvs\\trydjango-SjDXbmBR\\lib\\site-packages']Server 
time:
Wed, 19 May 2021 16:51:46 +


-- 
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/f4b616e3-be6b-49d9-8d62-577e32d45121n%40googlegroups.com.
  

-- 
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/1572993905.688196.1621516160432%40mail.yahoo.com.


Can you help me solve this

2021-05-20 Thread Sameer Gedam
OperationalError at /admin/products/product/add/no such table: 
main.auth_user__oldRequest Method:
POSTRequest URL:
http://127.0.0.1:8000/admin/products/product/add/Django Version:
2.0.7Exception Type:
OperationalErrorException Value:
no such table: main.auth_user__oldException Location:
C:\Users\user\.virtualenvs\trydjango-SjDXbmBR\lib\site-packages\django\db\backends\sqlite3\base.py
 
in execute, line 303Python Executable:
C:\Users\user\.virtualenvs\trydjango-SjDXbmBR\Scripts\python.exePython 
Version:
3.9.5Python Path:
['C:\\Users\\user\\Dev\\trydjango\\src', 'c:\\python39\\python39.zip', 
'c:\\python39\\DLLs', 'c:\\python39\\lib', 'c:\\python39', 
'C:\\Users\\user\\.virtualenvs\\trydjango-SjDXbmBR', 
'C:\\Users\\user\\.virtualenvs\\trydjango-SjDXbmBR\\lib\\site-packages']Server 
time:
Wed, 19 May 2021 16:51:46 +

-- 
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/f4b616e3-be6b-49d9-8d62-577e32d45121n%40googlegroups.com.


Re: I need web scraping to get product information from mfg sites

2021-05-20 Thread Ohida Sefiyat
Hello John,

I am interested. Please find my details below:

Name: Sefiyat Ohida
Contact Number: +2347034777957
Email Address: ohidasefi...@gmail.com

Regards
Sefiyat

On Tue, May 18, 2021 at 3:55 PM John McClain  wrote:

> Hello,
>
> I am looking for individuals that can set up scraping routines for me and
> place the results in google.docs for me.
>
> If interested in helping out please let me know. Some compensation for
> your efforts is available. There are 20+ sites needed to be scraped which
> is why I am seeking help with the project.
>
> If interested drop your name and contact details here and I'll be in touch.
>
> Cheers,
>
> J
>
> --
> John McClain
>
> Cell: 085-1977-823
> Skype: jmcclain0129
> Email: jmcclain0...@gmail.com
>
> --
> 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/CAN-hv_pQ67gGF10S4J1pk1CtSzmX9qqtDp_-j_Pax3tvpmeczg%40mail.gmail.com
> 
> .
>

-- 
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/CAA95jHRaEWAG0-vTVMpz4c%3D6HzgULbqVVjcZ%2BPD9kzhhqgPkHw%40mail.gmail.com.