Re: Difference in datetime with timezone

2022-03-28 Thread Antonis Christofides

Hello,

1. Please copy your code exactly. Is it really "pytz.timezone(TIME_ZONE)"? Or
   is it "pytz.timezone(*settings.*TIME_ZONE)"? If it is the first one, please
   include the definition or importing of TIME_ZONE.
2. Please pretty-print your dictionary. You can use pprint for that. If it
   doesn't work on OrderedDicts, convert it to a simple dictionary before
   pretty printing.
3. Likewise, do something so that your SQL statement is more readable, such as
   manually inserting newlines and indents.

Regards,

Antonis

Antonis Christofides
+30-6979924665 (mobile)


On 28/03/2022 22.02, Andrés Alvarez wrote:
I need to save some fields in my database in the format YYY-MM-MM 00:00:00+00. 
So I decide to do this:

field_to_save = datetime.combine(date_to_save, time.min, 
pytz.timezone(TIME_ZONE))
in settings.py I have:
TIME_ZONE = 'America/Mexico_City'
USE_I18N = True
USE_L10N = True
USE_TZ = True

My model:
class Program(models.Model):
    objects = models.Manager()
    objects_custom = ProgramManager()
    class Meta:
        ordering = ['id']
    # ... others fields
    start_at = models.DateTimeField(null=True)
    finish_at = models.DateTimeField(null=True)

Here are my values to create the register:
OrderedDict([('has_individual_budget', False), ('name', 'plan test create 
program start_at datetime'), ('program_budget', '0'), ('uuid4', 
'd6effacf-3c19-48db-ab06-5af1d97df599'), ('country_list', 
'[{"id":239,"name":"Venezuela","iso_code2":"VE","iso_code3":"VEN","phone_prefix":58,"currency":"VEF","flag":"U+1F1FB 
U+1F1EA","phone_national_regex":"^[68]00d{7}|(?:[24]d|[59]0)d{8}$","active":1}]'), 
('method_payment', '7fb39a7e-a6de-488b-9564-9bd853b598ec'), ('currency', 
'USD'), ('is_saved', False), ('start_at', datetime.datetime(2022, 3, 28, 0, 0, 
tzinfo=)), 
('finish_at', datetime.datetime(2022, 4, 27, 23, 59, 59, 99, 
tzinfo=)), 
('company', ), ('card_provider', stripe-usa>), ('payment_provider', )])
as you can see the field 'start_at' is the datetime that I want to store in 
the database, but when I look the insert query:
{'sql': 'INSERT INTO "user_program" ("name", "program_budget", "company_id", 
"active", "uuid4", "country_list", "method_payment", "currency", "create_at", 
"discharge_program", "updated_at", "deleted_at", "is_saved", "is_suspended", 
"start_at", "finish_at", "has_individual_budget", "card_provider_id", 
"payment_provider_id") VALUES (\'plan test create program start_at datetime\', 
\'0\', 247, true, \'d6effacf-3c19-48db-ab06-5af1d97df599\', 
\'[{"id":239,"name":"Venezuela","iso_code2":"VE","iso_code3":"VEN","phone_prefix":58,"currency":"VEF","flag":"U+1F1FB 
U+1F1EA","phone_national_regex":"^[68]00d{7}|(?:[24]d|[59]0)d{8}$","active":1}]\', 
\'7fb39a7e-a6de-488b-9564-9bd853b598ec\', \'USD\', 
\'2022-03-28T18:47:10.865801+00:00\'::timestamptz, 
\'2022-03-28T18:47:10.865870+00:00\'::timestamptz, 
\'2022-03-28T18:47:10.865913+00:00\'::timestamptz, NULL, false, false, 
\'2022-03-28T00:00:00-06:37\'::timestamptz, 
\'2022-04-27T23:59:59.99-06:37\'::timestamptz, false, 1, 1) RETURNING 
"user_program"."id"', 'time': '0.267'}

the timezone part is -06:37 should be only -06.
Plase tell me how to fix that, if I need to change the TIME_ZONE or something.

Regards, Andres.

--
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/1999ec1e-9170-432e-adc0-71cab3dece6an%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/9f518ac9-3b8e-5bc5-fae2-c65ebd00d6c6%40antonischristofides.com.


Difference in datetime with timezone

2022-03-28 Thread Andrés Alvarez
I need to save some fields in my database in the format YYY-MM-MM 
00:00:00+00. So I decide to do this:
field_to_save = datetime.combine(date_to_save, time.min, 
pytz.timezone(TIME_ZONE))
in settings.py I have:
TIME_ZONE = 'America/Mexico_City'
USE_I18N = True
USE_L10N = True
USE_TZ = True

My model:
class Program(models.Model):
objects = models.Manager()
objects_custom = ProgramManager()
class Meta:
ordering = ['id']
# ... others fields
start_at = models.DateTimeField(null=True)
finish_at = models.DateTimeField(null=True)

Here are my values to create the register:
OrderedDict([('has_individual_budget', False), ('name', 'plan test create 
program start_at datetime'), ('program_budget', '0'), ('uuid4', 
'd6effacf-3c19-48db-ab06-5af1d97df599'), ('country_list', 
'[{"id":239,"name":"Venezuela","iso_code2":"VE","iso_code3":"VEN","phone_prefix":58,"currency":"VEF","flag":"U+1F1FB
 
U+1F1EA","phone_national_regex":"^[68]00d{7}|(?:[24]d|[59]0)d{8}$","active":1}]'),
 
('method_payment', '7fb39a7e-a6de-488b-9564-9bd853b598ec'), ('currency', 
'USD'), ('is_saved', False), ('start_at', datetime.datetime(2022, 3, 28, 0, 
0, tzinfo=)), 
('finish_at', datetime.datetime(2022, 4, 27, 23, 59, 59, 99, 
tzinfo=)), 
('company', ), ('card_provider', 
), ('payment_provider', )])
as you can see the field 'start_at' is the datetime that I want to store in 
the database, but when I look the insert query:
{'sql': 'INSERT INTO "user_program" ("name", "program_budget", 
"company_id", "active", "uuid4", "country_list", "method_payment", 
"currency", "create_at", "discharge_program", "updated_at", "deleted_at", 
"is_saved", "is_suspended", "start_at", "finish_at", 
"has_individual_budget", "card_provider_id", "payment_provider_id") VALUES 
(\'plan test create program start_at datetime\', \'0\', 247, true, 
\'d6effacf-3c19-48db-ab06-5af1d97df599\', 
\'[{"id":239,"name":"Venezuela","iso_code2":"VE","iso_code3":"VEN","phone_prefix":58,"currency":"VEF","flag":"U+1F1FB
 
U+1F1EA","phone_national_regex":"^[68]00d{7}|(?:[24]d|[59]0)d{8}$","active":1}]\',
 
\'7fb39a7e-a6de-488b-9564-9bd853b598ec\', \'USD\', 
\'2022-03-28T18:47:10.865801+00:00\'::timestamptz, 
\'2022-03-28T18:47:10.865870+00:00\'::timestamptz, 
\'2022-03-28T18:47:10.865913+00:00\'::timestamptz, NULL, false, false, 
\'2022-03-28T00:00:00-06:37\'::timestamptz, 
\'2022-04-27T23:59:59.99-06:37\'::timestamptz, false, 1, 1) RETURNING 
"user_program"."id"', 'time': '0.267'}
the timezone part is -06:37 should be only -06.
Plase tell me how to fix that, if I need to change the TIME_ZONE or 
something.

Regards, Andres.

-- 
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/1999ec1e-9170-432e-adc0-71cab3dece6an%40googlegroups.com.


Re: Vue js

2022-03-28 Thread Gobi Dasu
I'd recommend talking to Adeoluwa, Frank, and Muhwezi from these Vue
developers from ldtalent.org/client/select_engineers/Vue.js/

I've enjoyed working with them.

Regards,
Gobi

On Mon, Mar 28, 2022, 00:28 Let's Get Going  wrote:

> Any vue js expert here?
> I need some help.
>
> --
> 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/CAEvQWLN6WvNTOVjvMUMJE%2BwYkwguPxtCYXZvQtzzAoj-ZAQCzg%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/CAMk8evmCxV1zEKkqhY23_PKybdu8RSfF2zEu-mkNcGFWsEP1jw%40mail.gmail.com.


Set value automatically to input field

2022-03-28 Thread KOUASSI JACOB KRA
Hello all,
I begin with django and i'm trying set calculate value to a field in django 
admin.
I have 3 fields : quantity, price and total_httc. 
what I want is that after entering the values ​​of quantity  and price the 
total_httc is filled in automatically. 
total_httc = quantity * price.

-- 
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/991d54df-b5a8-4bf1-9673-c6af14d83ea6n%40googlegroups.com.


Re: runserver not working

2022-03-28 Thread Abinash Mandal
Dear sir,
Recently i have faced the same problem , what i did, i close
those apps and uninstall completely (vscode and python) remember to
uninstall vs you have to delete the extension files from app data which is
hidden , and after delete i restart the pc , then again install , is solved
out.

Another solution I can give that ,just find the path in vs code + sign i.e
that path is in the python file and select the env, it will also solve


On Tue, Mar 22, 2022 at 10:37 AM 'Delvin Alexander' via Django users <
django-users@googlegroups.com> wrote:

> would anyone know why my "manage.py runserver" is not working?
>
> Every time i try running it on the command prompt, i get relocated to my
> visual studio of manage.py file that states this:
>
> #*!/usr/bin/env python*
> *"""Django's command-line utility for administrative tasks."""*
> *import os*
> *import sys*
>
>
> *def main():*
> *"""Run administrative tasks."""*
> *os.environ.setdefault('DJANGO_SETTINGS_MODULE',
> 'django_project.settings')*
> *try:*
> *from django.core.management import execute_from_command_line*
> *except ImportError as exc:*
> *raise ImportError(*
> *"Couldn't import Django. Are you sure it's installed and "*
> *"available on your PYTHONPATH environment variable? Did you "*
> *"forget to activate a virtual environment?"*
> *) from exc*
> *execute_from_command_line(sys.argv)*
>
>
> *if __name__ == '__main__':*
> *main()*
>
>
> A step in the right direction will be super helpful for 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/69291c68-61e7-4557-8175-7b705bcfcbb0n%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/CAKpnBLeX40aqM4KKWaNSGG-paXO%2BXaS8V7mG1X%2Bo%2BNu%2BcYF9QA%40mail.gmail.com.


Re: runserver not working

2022-03-28 Thread Abinash Mandal
https://stackoverflow.com/questions/58661812/django-python-manage-py-runserver-not-working

On Tue, Mar 22, 2022 at 10:37 AM 'Delvin Alexander' via Django users <
django-users@googlegroups.com> wrote:

> would anyone know why my "manage.py runserver" is not working?
>
> Every time i try running it on the command prompt, i get relocated to my
> visual studio of manage.py file that states this:
>
> #*!/usr/bin/env python*
> *"""Django's command-line utility for administrative tasks."""*
> *import os*
> *import sys*
>
>
> *def main():*
> *"""Run administrative tasks."""*
> *os.environ.setdefault('DJANGO_SETTINGS_MODULE',
> 'django_project.settings')*
> *try:*
> *from django.core.management import execute_from_command_line*
> *except ImportError as exc:*
> *raise ImportError(*
> *"Couldn't import Django. Are you sure it's installed and "*
> *"available on your PYTHONPATH environment variable? Did you "*
> *"forget to activate a virtual environment?"*
> *) from exc*
> *execute_from_command_line(sys.argv)*
>
>
> *if __name__ == '__main__':*
> *main()*
>
>
> A step in the right direction will be super helpful for 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/69291c68-61e7-4557-8175-7b705bcfcbb0n%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/CAKpnBLdRBu-qo%3DbqVAzaH9EDJoDdHTZitCSFh3BNPkApQXth6A%40mail.gmail.com.


Favicon.ico error!

2022-03-28 Thread Md Anzar
Hi, all. I am try to include favicon file in website logo but getting image 
in body of the page.[image: Screenshot from 2022-03-28 11-08-12.png]

Please give suggestion.

-- 
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/bfe8d27b-7f88-4c72-9f9f-9b29f7ccfa35n%40googlegroups.com.


Re: Stuck

2022-03-28 Thread rahul sharma
Cd comand and app name..

On Mon, Mar 28, 2022, 11:57 Samapika Nayak 
wrote:

> you need to configure the media files in settings.py
> MEDIA_URL = "/media/"
> MEDIA_ROOT = BASE_DIR / "media"
> also need to configure it in project level urls.py
>
> if settings.DEBUG:
> urlpatterns += static(settings.MEDIA_URL,
> document_root=settings.MEDIA_ROOT)
>
> On Mon, Mar 28, 2022 at 10:04 AM 'Delvin Alexander' via Django users <
> django-users@googlegroups.com> wrote:
>
>> Hello everyone,
>>
>> I am trying to register a new user by watching the Django tutorial. I
>> have created the new user but upon attempting to log the new user in I get
>> an,
>>
>> *"FileNotFoundError at /login/[Errno 2] No such file or directory:
>> 'C:\\Users\\delvi\\django_project\\media\\default.jpg'"*
>>
>> But on my visual code it tells me this, "Exception has occurred:
>> ImproperlyConfigured
>>
>>-
>>
>> *Requested setting INSTALLED_APPS, but settings are not configured. You
>> must either define the environment variable DJANGO_SETTINGS_MODULE or call
>> settings.configure() before accessing settings.*
>> * File "C:\Users\delvi\django_project\users\models.py", line 2, in
>>  from django.contrib.auth.models import User"*
>>
>>
>> Here is my model.py file:
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from PIL import Image
>> import os
>> from django.core.asgi import get_asgi_application
>>
>> class Profile(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> image = models.ImageField(default='default.jpg',
>> upload_to='profile_pics')
>>
>> def __str__(self):
>> return f'{self.user.username} Profile'
>>
>> def save(self, *args, **kwargs):
>> super(Profile, self).save(*args, **kwargs)
>>
>> img = Image.open(self.image.path)
>> file = open('media')
>>
>> if img.height > 300 or img.width > 300:
>> output_size = (300, 300)
>> img.thumbnail(output_size)
>> img.save(self.image.path)
>> And here is my views.py file for the User folder:
>>
>> from django.shortcuts import render, redirect
>> from django.contrib import messages
>> from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
>> from django.contrib.auth.decorators import login_required
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(request, f'Your Account has been created you
>> are now able to log in {username}!')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'users/register.html', {'form': form})
>>
>> @login_required
>> def profile(request):
>> if request.method == 'POST':
>> u_form = UserUpdateForm(request.POST, instance=request.user)
>> p_form = ProfileUpdateForm(request.POST, request.FILES,
>> instance=request.user.profile)
>> if u_form.is_valid() and p_form.is_valid():
>> u_form.save()
>> p_form.save()
>> messages.success(request, f'Your Account has been updated!')
>> return redirect('profile')
>> else:
>> u_form = UserUpdateForm(instance=request.user)
>> p_form = ProfileUpdateForm(instance=request.user.profile)
>>
>> context = {
>> 'u_form': u_form,
>> 'p_form': p_form,
>> }
>>
>> return render(request, 'users/profile.html', context)
>> *Would anyone know the reason why i am getting two mistakes ?*
>>
>>
>> --
>> 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/e4caa9f7-3715-4486-9c8c-feca7ad31b2an%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/CAJG1qUKb2Ar9V-YnTUHRBW6CcgkdSOaQR4Tdm8f79_Ajc2V7pw%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...@google

Vue js

2022-03-28 Thread Let's Get Going
Any vue js expert here?
I need some help.

-- 
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/CAEvQWLN6WvNTOVjvMUMJE%2BwYkwguPxtCYXZvQtzzAoj-ZAQCzg%40mail.gmail.com.


Re: Stuck

2022-03-28 Thread Kelvin Sajere
You don’t have default.jpg in your media folder. Add jpg image named
default in the media folder.

On Mon, Mar 28, 2022 at 5:34 AM 'Delvin Alexander' via Django users <
django-users@googlegroups.com> wrote:

> Hello everyone,
>
> I am trying to register a new user by watching the Django tutorial. I have
> created the new user but upon attempting to log the new user in I get an,
>
> *"FileNotFoundError at /login/[Errno 2] No such file or directory:
> 'C:\\Users\\delvi\\django_project\\media\\default.jpg'"*
>
> But on my visual code it tells me this, "Exception has occurred:
> ImproperlyConfigured
>
>-
>
> *Requested setting INSTALLED_APPS, but settings are not configured. You
> must either define the environment variable DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.*
> * File "C:\Users\delvi\django_project\users\models.py", line 2, in
>  from django.contrib.auth.models import User"*
>
>
> Here is my model.py file:
>
> from django.db import models
> from django.contrib.auth.models import User
> from PIL import Image
> import os
> from django.core.asgi import get_asgi_application
>
> class Profile(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> image = models.ImageField(default='default.jpg',
> upload_to='profile_pics')
>
> def __str__(self):
> return f'{self.user.username} Profile'
>
> def save(self, *args, **kwargs):
> super(Profile, self).save(*args, **kwargs)
>
> img = Image.open(self.image.path)
> file = open('media')
>
> if img.height > 300 or img.width > 300:
> output_size = (300, 300)
> img.thumbnail(output_size)
> img.save(self.image.path)
> And here is my views.py file for the User folder:
>
> from django.shortcuts import render, redirect
> from django.contrib import messages
> from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
> from django.contrib.auth.decorators import login_required
>
>
> def register(request):
> if request.method == 'POST':
> form = UserRegisterForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(request, f'Your Account has been created you
> are now able to log in {username}!')
> return redirect('login')
> else:
> form = UserRegisterForm()
> return render(request, 'users/register.html', {'form': form})
>
> @login_required
> def profile(request):
> if request.method == 'POST':
> u_form = UserUpdateForm(request.POST, instance=request.user)
> p_form = ProfileUpdateForm(request.POST, request.FILES,
> instance=request.user.profile)
> if u_form.is_valid() and p_form.is_valid():
> u_form.save()
> p_form.save()
> messages.success(request, f'Your Account has been updated!')
> return redirect('profile')
> else:
> u_form = UserUpdateForm(instance=request.user)
> p_form = ProfileUpdateForm(instance=request.user.profile)
>
> context = {
> 'u_form': u_form,
> 'p_form': p_form,
> }
>
> return render(request, 'users/profile.html', context)
> *Would anyone know the reason why i am getting two mistakes ?*
>
>
> --
> 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/e4caa9f7-3715-4486-9c8c-feca7ad31b2an%40googlegroups.com
> 
> .
>
-- 
KeLLs

-- 
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/CADYqDX31ZOjfBJWVkA%2B0ZxZgiFCu5S0PvxM%3DDWVpA9Yc5GbHnA%40mail.gmail.com.