I new to Django

2023-05-21 Thread khaled alshadbi
Hello friends
please help me to start from scratch... I want to build sales program using 
Python and 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/0d4c6fff-392a-4d1d-b0d3-ba80a0d54f18n%40googlegroups.com.


Re: I new to Django

2023-05-21 Thread 'Kasper Laudrup' via Django users

On 21/05/2023 16.26, khaled alshadbi wrote:

Hello friends
please help me to start from scratch... I want to build sales program 
using Python and Django




https://docs.djangoproject.com/en/4.2/intro/

Kind regards,
Kasper Laudrup

--
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/18ff3218-30a3-1b88-3553-2f5cefec5310%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Multiuser Login and Registration required

2023-05-21 Thread chen...@gmail.com
I need a tutorial from scratch on how new Users can register and login 
having different forms for HOD, Staff and Student. 

I need tutorial on Multiusers

Thank you

-- 
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/eba30d6c-8bcc-4642-a8a2-0ddcbaf6c8adn%40googlegroups.com.


Unable to write to database

2023-05-21 Thread William Nash (Bill)
I'm new to django and I'm trying to learn as I program a small website for 
my scuba diving business.   I'm running into a error that when I try to add 
a diver the database does not update.  When I goto 
http://localhost:8000/add_diver/add_diver/  I'm able to add a diver. 

My code is located at:  https://github.com/wrnash1/ascubadiving

Thanks for any help on this application.


Bill

-- 
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/05da25b5-3454-4b1b-a039-e37b08324936n%40googlegroups.com.


Re: Unable to write to database

2023-05-21 Thread Abdulrahman Abbas
Send your error message

On Sun, May 21, 2023, 18:54 William Nash (Bill)  wrote:

> I'm new to django and I'm trying to learn as I program a small website for
> my scuba diving business.   I'm running into a error that when I try to add
> a diver the database does not update.  When I goto
> http://localhost:8000/add_diver/add_diver/  I'm able to add a diver.
>
> My code is located at:  https://github.com/wrnash1/ascubadiving
>
> Thanks for any help on this application.
>
>
> Bill
>
> --
> 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/05da25b5-3454-4b1b-a039-e37b08324936n%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/CAGGqo0PJ7dHMtMFoGNZtHOVHXA4BnwugRcrnvepq1mB6mRiNMQ%40mail.gmail.com.


Re: Unable to write to database

2023-05-21 Thread William Nash (Bill)
I do not see any error messages.  

On Sunday, May 21, 2023 at 12:56:45 PM UTC-5 Abdulrahman Abbas wrote:

> Send your error message 
>
> On Sun, May 21, 2023, 18:54 William Nash (Bill)  wrote:
>
>> I'm new to django and I'm trying to learn as I program a small website 
>> for my scuba diving business.   I'm running into a error that when I try to 
>> add a diver the database does not update.  When I goto 
>> http://localhost:8000/add_diver/add_diver/  I'm able to add a diver. 
>>
>> My code is located at:  https://github.com/wrnash1/ascubadiving
>>
>> Thanks for any help on this application.
>>
>>
>> Bill
>>
>> -- 
>> 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/05da25b5-3454-4b1b-a039-e37b08324936n%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/20cc824f-bd17-44a7-a794-eaa1d6938f64n%40googlegroups.com.


Django Translation won't work

2023-05-21 Thread sebasti...@gmail.com
I use django translation. Normal works perfect but now i have a problem. 
All verbose name are in english in django code. I setting.py i have as 
second language DE configure. Then i have in models.py:

condition_link = models.ForeignKey(related, null=True, blank=True, 
default=None, on_delete=models.CASCADE,verbose_name=_('Condition'),
   related_name="condition_link")

in django.po in DE Language i don't find anything with 

msgid "Condition"

in form.py i have:

evalfield = self.Meta.model._meta.get_field('condition_link')
self.fields['condition_link'] = 
forms.MultipleChoiceField(choices=evalfield.choices,
widget=SelectMultiple(),
label=evalfield.verbose_name)

and i get in evalfield.verbose_name a translation which are don't exists in 
django.po file. I also delete django.mo file and make django-admin 
compilemessages --locale DE so .mo file is new created.

Same thing.

Then next problem on django translation i have a translation:

#: catalogue/models.py:81
msgid "Gender"
msgstr "Geschlecht"

in frontend msgstr Geschlecht are shown both in english and in german 
language...

99% other translation works right...

Have anyone a idea what it could be? This is absolut strange

-- 
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/09d0d1cb-875c-45ce-a9d8-716d7fe08175n%40googlegroups.com.


Re: Django Translation won't work

2023-05-21 Thread Sebastian Jung
I have delete complete django.po file and make new one and only make a
translation for Gender to Geschlecht and same thing happens that in
Englisch Language and in German Language both show Geschlecht...

Am So., 21. Mai 2023 um 20:36 Uhr schrieb sebasti...@gmail.com <
sebastian.ju...@gmail.com>:

> I use django translation. Normal works perfect but now i have a problem.
> All verbose name are in english in django code. I setting.py i have as
> second language DE configure. Then i have in models.py:
>
> condition_link = models.ForeignKey(related, null=True, blank=True,
> default=None, on_delete=models.CASCADE,verbose_name=_('Condition'),
>related_name="condition_link")
>
> in django.po in DE Language i don't find anything with
>
> msgid "Condition"
>
> in form.py i have:
>
> evalfield = self.Meta.model._meta.get_field('condition_link')
> self.fields['condition_link'] =
> forms.MultipleChoiceField(choices=evalfield.choices,
> widget=SelectMultiple(),
> label=evalfield.verbose_name)
>
> and i get in evalfield.verbose_name a translation which are don't exists
> in django.po file. I also delete django.mo file and make django-admin
> compilemessages --locale DE so .mo file is new created.
>
> Same thing.
>
> Then next problem on django translation i have a translation:
>
> #: catalogue/models.py:81
> msgid "Gender"
> msgstr "Geschlecht"
>
> in frontend msgstr Geschlecht are shown both in english and in german
> language...
>
> 99% other translation works right...
>
> Have anyone a idea what it could be? This is absolut strange
>
> --
> 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/09d0d1cb-875c-45ce-a9d8-716d7fe08175n%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/CAKGT9mx1tzDG8NnRKj0_-PyQy08zbKZdor6JrgBLqTy3z84ytg%40mail.gmail.com.


Re: Unable to write to database

2023-05-21 Thread Michael Edet
Did you install django???
And said you put py manage.py runserver


On Sun, 21 May 2023, 18:55 William Nash (Bill),  wrote:

> I'm new to django and I'm trying to learn as I program a small website for
> my scuba diving business.   I'm running into a error that when I try to add
> a diver the database does not update.  When I goto
> http://localhost:8000/add_diver/add_diver/  I'm able to add a diver.
>
> My code is located at:  https://github.com/wrnash1/ascubadiving
>
> Thanks for any help on this application.
>
>
> Bill
>
> --
> 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/05da25b5-3454-4b1b-a039-e37b08324936n%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/CACM0XWxR_agWmor7AdAQZ%2B%3DdUsGFasvnbVv_GzCSe29WjSfPDA%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 &postgresql
>> 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
>> 
>> .
>>
> --
> 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
> 
> .
>

-- 
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.


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 &postgresql
>>> 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
>>> 
>>> .
>>>
>> --
>> 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
>> 
>> .
>>
>

-- 
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 Brian Gitau
Try this i am not so sure though but trying isn't bad...kindly give me the
feedback after trying


from django.apps import apps
from django.db import connection, models
from rest_framework.response import Response
from rest_framework.views import APIView

FIELD_TYPE_MAPPING = {
'char': models.CharField,
'integer': models.IntegerField,
'boolean': models.BooleanField,
'email': models.EmailField,
# Add more field types here if needed
}

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 in FIELD_TYPE_MAPPING:
field_class =
FIELD_TYPE_MAPPING[field_type](max_length=max_length)
else:
raise ValueError(f"Invalid field type: {field_type}")

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 Mon, May 22, 2023 at 8:21 AM Helly Modi  wrote:

> 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 &postgresql
 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
 
 .

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To 

Re: dynamic django tables

2023-05-21 Thread Sebastian Jung
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 &postgresql 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
> 
> .
>

-- 
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/CAKGT9mzA8eYywCuvBCm45j0LpmYk6f%3DkQeN-8xyG2CmQkQy7dA%40mail.gmail.com.