I have a react function that calculates the ETD and i have same function in django but it is giving me a different value

2023-08-14 Thread Helly Modi
ETDtime( props.equipment.performed, props.equipment.standard_seconds, 
props.equipment.paused_seconds ) calulate ETD = start time + standard 
seconds +total puash export function ETDtime(date, standard_seconds, 
pause_seconds) { if (date) { let getdate = new Date(date); let 
get_standard_seconds = Math.floor(standard_seconds % 60); let 
get_pause_seconds = Math.floor((pause_seconds / 1000) % 60); 
getdate.setSeconds( getdate.getSeconds() + get_standard_seconds + 
get_pause_seconds ); var newdate = new Date(getdate); newdate = new Date( 
new Date(date).getTime() + standard_seconds * 1000 + pause_seconds * 1000 
); var get_date = newdate.getDate(); return ( (get_date >= 10 ? get_date : 
'0' + get_date) + '-' + (newdate.getMonth() + 1) + '-' + 
newdate.getFullYear() + ' ' + (newdate.getHours() >= 10 ? 
newdate.getHours() : '0' + newdate.getHours()) + ':' + 
(newdate.getMinutes() >= 10 ? newdate.getMinutes() : '0' + 
newdate.getMinutes()) ); } else { return ''; } } now if i am converting 
same function in django i am not getting that same value 

import datetime
from datetime import datetime, timedelta

def ETDtime(date, standard_seconds, pause_seconds):
if date:
getdate = datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
get_standard_seconds = int(standard_seconds % 60)
get_pause_seconds = int((pause_seconds / 1000) % 60)
getdate += timedelta(seconds=get_standard_seconds + get_pause_seconds)
newdate = getdate + timedelta(seconds=standard_seconds + pause_seconds / 
1000)
get_date = newdate.day
return (
f'{get_date:02d}-'
f'{newdate.month:02d}-'
f'{newdate.year} '
f'{newdate.hour:02d}:'
f'{newdate.minute:02d}'
)
else:
return ''

# Given inputs
start_time = '2023-08-09 10:03:00'
paused_seconds = 30626
standard_seconds = 1200

# Calculate and print the output
output = ETDtime(start_time, standard_seconds, paused_seconds)
print(output)please help me what is wrong with my django function

-- 
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/356b437b-ab01-4f6c-821d-d7c3b86c8fe7n%40googlegroups.com.


Re: group by "project"

2023-05-25 Thread Helly Modi
TRY THIS
from django.db.models import Count

def list(self, request, *args, **kwargs):
project_id = self.request.query_params.get('project_id')
if project_id:
queryset = RegistrationDatesSlots.objects.values('project', 
'date').annotate(count=Count('project')).filter(project=project_id)
else:
queryset = RegistrationDatesSlots.objects.values('project', 'date')

serialized_data = []
for item in queryset:
serialized_item = {
'date': item['date'],
'project': item['project']
}
serialized_data.append(serialized_item)
return Response(serialized_data)

On Thursday, May 25, 2023 at 7:05:38 AM UTC+5:30 Muhammad Juwaini Abdul 
Rahman wrote:

> Do you realize what 'Count' do?
>
> On Thu, 25 May 2023 at 09:20, 'Mohamed Yahiya Shajahan' via Django users <
> django...@googlegroups.com> wrote:
>
>> def list(self, request, *args, **kwargs):
>> project_id = self.request.query_params.get('project_id')
>> if project_id:
>> queryset = RegistrationDatesSlots.objects.values('date').
>> annotate(project=Count('project')).filter(project=project_id)
>> # queryset = 
>> RegistrationDatesSlots.objects.filter(project=project_id).query.group_by=['project']
>> else:
>> queryset = RegistrationDatesSlots.objects.all().values(
>> 'project', 'date')
>>
>> serialized_data = []
>> for item in queryset:
>> serialized_item = {
>> 'date': item['date'],
>> 'project': item['project']
>> }
>> serialized_data.append(serialized_item)
>> return Response(serialized_data)
>>
>>
>> this is my views i want to group by "project" but shows only one record,
>> i know there are multiple records there 
>>
>>
>>
>>  The content of this email is confidential and intended for the 
>> recipient specified in message only. It is strictly forbidden to share any 
>> part of this message with any third party, without a written consent of the 
>> sender. If you received this message by mistake, please reply to this 
>> message and follow with its deletion, so that we can ensure such a mistake 
>> does not occur in the future.
>>
>> SAVE PAPER | Good for your planet | Good for your Business
>>
>> -- 
>> 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/016aad73-74fc-49c3-80e7-c8d68ea0a6ddn%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/28b321b8-4e3b-4fee-a94b-177ab1ba76f0n%40googlegroups.com.


Re: chatbot project

2023-05-24 Thread Helly Modi
There is a playlist in django where you will learn to create chatbot.Here 
is the linkhttps://youtu.be/0QdvjF83x7A.check this.It will be great help to 
you.

On Thursday, May 25, 2023 at 6:51:21 AM UTC+5:30 Anish Kumar wrote:

> can some one help me with source code i am a final year student and i 
> resgistered my name for python django chatbot project but i am a fresher so 
> i am have some problem in django chatbot project

-- 
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/61ee59c8-1177-4f26-a117-a742b349485cn%40googlegroups.com.


Re: Dynamic Table

2023-05-24 Thread Helly Modi
worked on this option only .even tried dynamic django models but didn't 
work because of sustainable.if someone have the options or way to handle 
then please give


On Wednesday, May 24, 2023 at 11:06:23 AM UTC+5:30 Anh Nguyen wrote:

> Even your migrate works fine but you have to reload your runtime to apply 
> new codebase to de-encode data. So go back and find another solution.
>
> On Wed, 24 May 2023 at 12:22 Helly Modi  wrote:
>
>> I have to create dynamic table at runtime where user enters the details 
>> of table name,table column,table fields,constraints.take this input in 
>> backend and create table dynamically without creating schemas of tables as 
>> tables are created at runtime .first approach is that we will create one 
>> table where all the fields are mentioned where primary key,secondary 
>> key,unique,not niull and all the constraints are mentioned in horizontal 
>> column.now we have to create table 2 where user will select whild field id 
>> he want to select .suppose if user wants to create primary key then it will 
>> select field 1 in second table so it is refered from main table.and then 
>> table is created do you know how this works in django from backend side
>>
>> -- 
>> 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/24b3cec9-f614-4592-a1de-e69f2a71bc3fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/24b3cec9-f614-4592-a1de-e69f2a71bc3fn%40googlegroups.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/104d78f3-3aa0-4962-a640-d4a59eca717fn%40googlegroups.com.


Dynamic Table

2023-05-23 Thread Helly Modi
I have to create dynamic table at runtime where user enters the details of 
table name,table column,table fields,constraints.take this input in backend 
and create table dynamically without creating schemas of tables as tables 
are created at runtime .first approach is that we will create one table 
where all the fields are mentioned where primary key,secondary 
key,unique,not niull and all the constraints are mentioned in horizontal 
column.now we have to create table 2 where user will select whild field id 
he want to select .suppose if user wants to create primary key then it will 
select field 1 in second table so it is refered from main table.and then 
table is created do you know how this works in django from backend side

-- 
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/24b3cec9-f614-4592-a1de-e69f2a71bc3fn%40googlegroups.com.


Re: dynamic django tables

2023-05-22 Thread Helly Modi
I have to create api where user can select the column and type and other 
argument and it will create table in database in django.now here we can't 
use models .so we have to create tables dynamically at run time.so first i 
use django dynamic model in order to create table .it created table in 
database but when we try to do other operation such as getting all the 
details of table .it is not working.for fetching the data i have used Get 
method by providing table name from user in api but in the output it shows 
table does not exist even if table is present.sometime it shows table but 
sometime it desn't show.Is there any other approach.please help

from django.db import models, connection
from django.http import JsonResponse
from rest_framework.views import APIView
from rest_framework.response import Response
from django.apps import apps
from.serializers import CreateTableSerializer

FIELD_TYPE = {
'char': models.CharField,
'integer': models.IntegerField,
'boolean': models.BooleanField,
'email': models.EmailField,
'text': models.TextField,
'float': models.FloatField,
'file': models.FileField,
'date': models.DateTimeField
}


class CreateTableAPIView(APIView):
def post(self, request):
serializer = CreateTableSerializer(data=request.data)
serializer.is_valid(raise_exception=True)

table_name = serializer.validated_data['table_name']
fields = serializer.validated_data['fields']
primary_key_field = serializer.validated_data.get('primary_key') # Retrieve 
the primary key field name

# Create a dynamic model class
dynamic_model_attrs = {'__module__': __name__}
dynamic_model_fields = {}

for field in fields:
field_name = field['name']
field_type = field['type']
max_length = field.get('max_length', 255)

if field_type in FIELD_TYPE:
field_class = FIELD_TYPE[field_type](max_length=max_length)
dynamic_model_fields[field_name] = field_class

if primary_key_field:
# Check if the specified primary key field exists in the fields list
if primary_key_field in dynamic_model_fields:
dynamic_model_fields[primary_key_field].primary_key = True
else:
return Response(f'The specified primary key field "{primary_key_field}" 
does not exist in the fields list.')

dynamic_model_attrs.update(dynamic_model_fields)
dynamic_model = type(table_name, (models.Model,), dynamic_model_attrs)

# Create the database table for the dynamic model
with connection.schema_editor() as schema_editor:
schema_editor.create_model(dynamic_model)

# Register the dynamic model with the app
apps.all_models['Tables'][table_name] = dynamic_model

return Response(f'Table "{table_name}" created successfully!')


class GetTableDataAPIView(APIView):
def get(self, request, table_name):
try:
# Get the dynamic model class
dynamic_model = apps.get_model('Tables', table_name)
print(table_name)
except LookupError:
return JsonResponse({'message': f'Table "{table_name}" does not exist.'}, 
status=404)

# Retrieve all data from the dynamic table
table_data = dynamic_model.objects.all().values()
print(table_data)

return JsonResponse({'table_name': table_name, 'data': list(table_data)})

On Monday, May 22, 2023 at 11:37:52 AM UTC+5:30 Sebastian Jung wrote:

Hello,

I take everytime a EAV implementation for this task. Hete a manual: 
https://django-eav2.readthedocs.io/en/latest/

I hope this helps you

Helly Modi  schrieb am Fr., 19. Mai 2023, 14:59:

How to create dynamic models in django rest framework?

Is there any chance to create dynamic models with APIs

 

Any examples please send me thanks in advance..

 

1) Requirement is need create table name and fields in frontend

2) we are  getting the data and store in to the db create db structure

3) get the table name and fields create table in backend  store 
to

4)this code don't update or add into the models 

5)store the data into the tables 

-- 

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/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d8d453a-0dbd-4b66-a8aa-fa78a3718febn%40googlegroups.com.


Re: dynamic django tables

2023-05-21 Thread Helly Modi
This is my code and it worked in creating tables but here django provides
26 fields and many relation how can i include all ? If else become too
complex .Is there any other way to do this

On Mon, May 22, 2023 at 10:49 AM Helly Modi  wrote:

> class CreateTableAPIView(APIView):
> def post(self, request):
> serializer = CreateTableSerializer(data=request.data)
> serializer.is_valid(raise_exception=True)
>
> table_name = serializer.validated_data['table_name']
> fields = serializer.validated_data['fields']
>
> # Create a dynamic model class
> dynamic_model_attrs = {'__module__': __name__}
> for field in fields:
> field_name=field['name']
> field_type=field['type']
> max_length=field.get('max_length',255)
>
> if field_type=='char':
> field_class=models.CharField(max_length=max_length)
> elif field_type== 'integer':
> field_class=models.IntegerField()
> elif field_type=='boolean':
> field_class=models.BooleanField()
> else:
> field_class=models.EmailField()
> dynamic_model_attrs[field_name]=field_class
>
>
> dynamic_model = type(table_name, (models.Model,), dynamic_model_attrs)
>
> # Create the database table for the dynamic model
> with connection.schema_editor() as schema_editor:
> schema_editor.create_model(dynamic_model)
>
> # Register the dynamic model with the app
> apps.all_models['dynamic_tables_app'][table_name] = dynamic_model
>
> return Response(f'Table "{table_name}" created successfully!')
>
>
> On Fri, May 19, 2023 at 6:40 PM Brian Gitau 
> wrote:
>
>> which code do you have or you want the code example explaining everything?
>>
>>
>> On Fri, May 19, 2023 at 3:59 PM Helly Modi  wrote:
>>
>>> How to create dynamic models in django rest framework?
>>>
>>> Is there any chance to create dynamic models with APIs
>>>
>>>
>>>
>>> Any examples please send me thanks in advance..
>>>
>>>
>>>
>>> 1) Requirement is need create table name and fields in frontend
>>>
>>> 2) we are  getting the data and store in to the db create db structure
>>>
>>> 3) get the table name and fields create table in backend 
>>> store to
>>>
>>> 4)this code don't update or add into the models
>>>
>>> 5)store the data into the tables
>>>
>>> --
>>> 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/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com?utm_medium=email_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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMJ3z%3D3Qn0n%2BHVefJg_B6R9RQABA88C4whqbn0g3ygo4k0gkMw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMJ3z%3D3Qn0n%2BHVefJg_B6R9RQABA88C4whqbn0g3ygo4k0gkMw%40mail.gmail.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO-ToNUai69i86uMD6-Z%2BSZha9DpjHSSbNFBGcwpf19N4eEtnw%40mail.gmail.com.


Re: dynamic django tables

2023-05-21 Thread Helly Modi
class CreateTableAPIView(APIView):
def post(self, request):
serializer = CreateTableSerializer(data=request.data)
serializer.is_valid(raise_exception=True)

table_name = serializer.validated_data['table_name']
fields = serializer.validated_data['fields']

# Create a dynamic model class
dynamic_model_attrs = {'__module__': __name__}
for field in fields:
field_name=field['name']
field_type=field['type']
max_length=field.get('max_length',255)

if field_type=='char':
field_class=models.CharField(max_length=max_length)
elif field_type== 'integer':
field_class=models.IntegerField()
elif field_type=='boolean':
field_class=models.BooleanField()
else:
field_class=models.EmailField()
dynamic_model_attrs[field_name]=field_class


dynamic_model = type(table_name, (models.Model,), dynamic_model_attrs)

# Create the database table for the dynamic model
with connection.schema_editor() as schema_editor:
schema_editor.create_model(dynamic_model)

# Register the dynamic model with the app
apps.all_models['dynamic_tables_app'][table_name] = dynamic_model

return Response(f'Table "{table_name}" created successfully!')


On Fri, May 19, 2023 at 6:40 PM Brian Gitau  wrote:

> which code do you have or you want the code example explaining everything?
>
>
> On Fri, May 19, 2023 at 3:59 PM Helly Modi  wrote:
>
>> How to create dynamic models in django rest framework?
>>
>> Is there any chance to create dynamic models with APIs
>>
>>
>>
>> Any examples please send me thanks in advance..
>>
>>
>>
>> 1) Requirement is need create table name and fields in frontend
>>
>> 2) we are  getting the data and store in to the db create db structure
>>
>> 3) get the table name and fields create table in backend 
>> store to
>>
>> 4)this code don't update or add into the models
>>
>> 5)store the data into the tables
>>
>> --
>> 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/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com?utm_medium=email_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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMJ3z%3D3Qn0n%2BHVefJg_B6R9RQABA88C4whqbn0g3ygo4k0gkMw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMJ3z%3D3Qn0n%2BHVefJg_B6R9RQABA88C4whqbn0g3ygo4k0gkMw%40mail.gmail.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO-ToNXbuBKUJ0uVeRSnUNv4NUFMPCT3bZ-y86zVMcVFa5oYrg%40mail.gmail.com.


dynamic django tables

2023-05-19 Thread Helly Modi


How to create dynamic models in django rest framework?

Is there any chance to create dynamic models with APIs

 

Any examples please send me thanks in advance..

 

1) Requirement is need create table name and fields in frontend

2) we are  getting the data and store in to the db create db structure

3) get the table name and fields create table in backend  store 
to

4)this code don't update or add into the models 

5)store the data into the tables 

-- 
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/72d09483-5129-43e1-bdbb-7b92969d97c4n%40googlegroups.com.