CreateView for non default database

2023-07-25 Thread Muhammad Juwaini Abdul Rahman
Hi all,

I have two different databases as below:

DATABASES = {
'tvet': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
},
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'jpk',
'USER': 'jpkuser',
'PASSWORD': 'jpkpassword',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}

When I want to create a CreateView, I am unable to save it.

This is my CreateView:

class BiodataCreateView(CreateView):
template_name = 'bio_create.html'

# model = Biodata.objects.using('tvet').all()
def get_queryset(self):
return Biodata.objects.using('tvet').all()

fields = 'name', 'hobby'

def get_success_url(self):
return reverse('biodata-list')

Any idea on how to do it?

-- 
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/4985efd7-437c-432e-86c8-9a902430513fn%40googlegroups.com.


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Mike Dewhirst

On 25/07/2023 10:47 pm, M Cain wrote:
User application permits registration for upcoming events.  User wants 
the registration page to be open on 4th Saturday of every month at 9am 
ET as the events are very popular with limited capacity and made 
available on first come first serve basis.


Django application is deployed on Heroku. Heroku scheduler works 
except it doesn't 'guarantee' running at specific time (but near the 
requested time).


Would celery-redis be better for this?

Any other suggestions?


I wrote baklabel.py to produce grandfather back-up label fragments such 
as "mon", "tue" etc and "fri_1", "fri_2" etc as well as month-end and 
year-end label fragments. It has no dependencies and accepts args so you 
could change "fri_1" etc to "sat_1".


If you called it at 9am ET every day it would tell you "sat_4" once per 
month.


There are options to nullify month-end and year-end which you would need 
to employ to prevent them from spoiling "sat_4" if it fell on a 
month-end or year-end.


pip install baklabel

https://github.com/mdewhirst/baklabel

Cheers

Mike



Thank you in advance for replying.
--
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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com 
.



--
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. 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/9cc2d261-a402-62ae-384e-69187b535777%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Sebastian Jung
Very cool solution chetan. I think i should try it. Thank you

Chetan Ganji  schrieb am Di., 25. Juli 2023, 22:56:

> Hi Mr Cain,
>
> This would make more sense to me!
> https://django-celery-beat.readthedocs.io/en/latest/
>
> You could create background tasks to create background tasks that run at
> any specific time ;-)
> AFAIK, this solution is as good as it can get!
>
> Thanks!
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Tue, Jul 25, 2023 at 11:43 PM M Cain  wrote:
>
>> User application permits registration for upcoming events.  User wants
>> the registration page to be open on 4th Saturday of every month at 9am ET
>> as the events are very popular with limited capacity and made available on
>> first come first serve basis.
>>
>> Django application is deployed on Heroku. Heroku scheduler works except
>> it doesn't 'guarantee' running at specific time (but near the requested
>> time).
>>
>> Would celery-redis be better for this?
>>
>> Any other suggestions?
>>
>> Thank you in advance for replying.
>>
>> --
>> 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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%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/CAMKMUjupcTZN-fq%3DCrYN%3DgTe%3Dv2wbKbpq6H81coJ_7zncurkuw%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/CAKGT9mwZGS_7BDrzx4oS963cq525y9KcC8feXaDH%3DGLgqswLwA%40mail.gmail.com.


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Chetan Ganji
Hi Mr Cain,

This would make more sense to me!
https://django-celery-beat.readthedocs.io/en/latest/

You could create background tasks to create background tasks that run at
any specific time ;-)
AFAIK, this solution is as good as it can get!

Thanks!

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Jul 25, 2023 at 11:43 PM M Cain  wrote:

> User application permits registration for upcoming events.  User wants the
> registration page to be open on 4th Saturday of every month at 9am ET as
> the events are very popular with limited capacity and made available on
> first come first serve basis.
>
> Django application is deployed on Heroku. Heroku scheduler works except it
> doesn't 'guarantee' running at specific time (but near the requested time).
>
> Would celery-redis be better for this?
>
> Any other suggestions?
>
> Thank you in advance for replying.
>
> --
> 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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%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/CAMKMUjupcTZN-fq%3DCrYN%3DgTe%3Dv2wbKbpq6H81coJ_7zncurkuw%40mail.gmail.com.


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Ross Meredith
No need to involve anything asynchronous, if I understand you correctly.
Just check when the request is made whether it's the right time.  If so
process the registration, otherwise show the other page to indicate it's
the wrong time.

Ross

On Tue, Jul 25, 2023 at 7:13 PM M Cain  wrote:

> User application permits registration for upcoming events.  User wants the
> registration page to be open on 4th Saturday of every month at 9am ET as
> the events are very popular with limited capacity and made available on
> first come first serve basis.
>
> Django application is deployed on Heroku. Heroku scheduler works except it
> doesn't 'guarantee' running at specific time (but near the requested time).
>
> Would celery-redis be better for this?
>
> Any other suggestions?
>
> Thank you in advance for replying.
>
> --
> 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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%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/CAA1Tdz0CCYAKHL4G69tgJvvz1dqz0wbLS1tKU3xc3hzfpwb3Bg%40mail.gmail.com.


Need to trigger action on 4th Saturday of the month

2023-07-25 Thread M Cain
User application permits registration for upcoming events.  User wants the 
registration page to be open on 4th Saturday of every month at 9am ET as 
the events are very popular with limited capacity and made available on 
first come first serve basis.  

Django application is deployed on Heroku. Heroku scheduler works except it 
doesn't 'guarantee' running at specific time (but near the requested time). 

Would celery-redis be better for this? 

Any other suggestions? 

Thank you in advance for replying. 

-- 
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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com.