Re: CRUD Generator

2021-01-07 Thread Omkar Parab
You can build whatever you want, using Django!

On Fri, Jan 8, 2021, 11:13 AM Chandrashekhar Singh <
chandrashekhar...@gmail.com> wrote:

> Hello,
>
> Does anyone one know ? Is django is best framework for developing delivery
> applications?
>
> Thanks
>
> On Thu, Jan 7, 2021, 11:39 PM Noel Simela  wrote:
>
>> Good day,
>>
>> I have explored several crud generator packages.
>>
>> I am looking for an opinion on the best package to adopt that has been
>> maintained for the past few months,
>>
>> If you have experience in django crud generators.Please let me know the
>> one you have used, the pros and cons.
>>
>> Many 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/CAGBhr7ZO4skwE7UXvth2EvGv70fX1DrCGXek5FkbgWoEtnqPVQ%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/CADNvQ1P6sDaGJT-toLSyU6p0jzGQ-GOJpx59Hw%3DquUcgnYW2%3Dw%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/CAJY8mfzmx1dfh55cLxdYJ29%2BBqVM%3Dvpp2PmLm865ryBRoN4LAA%40mail.gmail.com.


Re: CRUD Generator

2021-01-07 Thread Chandrashekhar Singh
Hello,

Does anyone one know ? Is django is best framework for developing delivery
applications?

Thanks

On Thu, Jan 7, 2021, 11:39 PM Noel Simela  wrote:

> Good day,
>
> I have explored several crud generator packages.
>
> I am looking for an opinion on the best package to adopt that has been
> maintained for the past few months,
>
> If you have experience in django crud generators.Please let me know the
> one you have used, the pros and cons.
>
> Many 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/CAGBhr7ZO4skwE7UXvth2EvGv70fX1DrCGXek5FkbgWoEtnqPVQ%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/CADNvQ1P6sDaGJT-toLSyU6p0jzGQ-GOJpx59Hw%3DquUcgnYW2%3Dw%40mail.gmail.com.


CRUD Generator

2021-01-07 Thread Noel Simela
Good day,

I have explored several crud generator packages.

I am looking for an opinion on the best package to adopt that has been
maintained for the past few months,

If you have experience in django crud generators.Please let me know the one
you have used, the pros and cons.

Many 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/CAGBhr7ZO4skwE7UXvth2EvGv70fX1DrCGXek5FkbgWoEtnqPVQ%40mail.gmail.com.


RE: Cache pages for fast loading

2021-01-07 Thread elon musk
Hi iis belongs to Microsoft  Sent from Mail for Windows 10 From: Dave ClevengerSent: Friday, January 8, 2021 7:54 AMTo: django-users@googlegroups.comSubject: Re: Cache pages for fast loading I have to use IIS at my job. I don't think redis is available on Windows. I use memcached which is similar to redis and can be run as a windows service and fully supported by Django's cache backend. If you absolutely want to use redis, then you'll probably want to spin up a Linux instance and run redis from there.On Thu, Jan 7, 2021, 10:24 AM Eugene TUYIZERE  wrote:No I only use IIS On 7 Jan 2021, at 17:18, gabriela...@gmail.com  wrote:Eugene:is IIS a Microsoft server ? Have you tray this with other server? for example, APACHE. There are a lot of hosting they give host service. El jueves, 7 de enero de 2021 a las 12:10:19 UTC-3, eugenet...@gmail.com escribió:Dear team, I deployed a django application on windows server with IIS web server. But the app is slow and I want to implement django redis for web page caching. Please assit how i can do this. 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/b1ffa15e-c3f3-4b2c-8794-0f661f93bb08n%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/6BC9EABF-05EB-4F0E-BB74-926FC7E3465C%40gmail.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/CADR4itJgHT6PREYNLcVJ%3DNL6eLGqqDRaJ2O_jyaoBqfEpZ%2BXvQ%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/C6F0A7F9-0AB5-4BEC-9062-470B94B86BE7%40hxcore.ol.


Re: Cache pages for fast loading

2021-01-07 Thread Dave Clevenger
I have to use IIS at my job. I don't think redis is available on Windows. I
use memcached which is similar to redis and can be run as a windows service
and fully supported by Django's cache backend.

If you absolutely want to use redis, then you'll probably want to spin up a
Linux instance and run redis from there.

On Thu, Jan 7, 2021, 10:24 AM Eugene TUYIZERE 
wrote:

> No I only use IIS
>
>
> On 7 Jan 2021, at 17:18, gabriela...@gmail.com 
> wrote:
>
> Eugene:
> is IIS a Microsoft server ? Have you tray this with other server? for
> example, APACHE. There are a lot of hosting they give host service.
>
> El jueves, 7 de enero de 2021 a las 12:10:19 UTC-3, eugenet...@gmail.com
> escribió:
>
>> Dear team,
>>
>> I deployed a django application on windows server with IIS web server.
>> But the app is slow and I want to implement django redis for web page
>> caching.
>>
>> Please assit how i can do this.
>>
>> 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/b1ffa15e-c3f3-4b2c-8794-0f661f93bb08n%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/6BC9EABF-05EB-4F0E-BB74-926FC7E3465C%40gmail.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/CADR4itJgHT6PREYNLcVJ%3DNL6eLGqqDRaJ2O_jyaoBqfEpZ%2BXvQ%40mail.gmail.com.


Re: Redirect one page to another on Django tremplate

2021-01-07 Thread pankaj palmate
can you elaborate it more means are you taking about Response?


On Thursday, January 7, 2021 at 10:48:33 PM UTC+5:30 amanmo...@gmail.com 
wrote:

> Hello Django Lover,
>
> I have a doubt how can we redirect one page to another on API response / 
> fetch response on Django template .
>

-- 
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/b96bed14-da97-4f0e-a9d5-a1b044f45dc7n%40googlegroups.com.


Redirect one page to another on Django tremplate

2021-01-07 Thread Aman Modi
Hello Django Lover,

I have a doubt how can we redirect one page to another on API response / 
fetch response on Django template .

-- 
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/40d0cdf1-9936-439d-9334-c1e54e063dcbn%40googlegroups.com.


Re: Conversion and import of a pre-existing database

2021-01-07 Thread gabriela...@gmail.com
Perhaps there is a utility program that can do that. Something like 
converter. Have you look in web foros  ?

El jueves, 7 de enero de 2021 a las 11:58:36 UTC-3, 
pe...@oneilinteractive.com escribió:

> Jérémy,
>
> It all depends on the Database which route to take. Is it one table, 
> multiple tab;es, what are the relationship?
>
> My plan of attack would be:
>
>1. Create all models in Django as you want them to be. Use the Django 
>standards to name your new fields [1]. 
>2. Let Django handle the field naming, unless you have a really good 
>reason to overwrite this behavior. Relationships are setup to other 
> models, 
>do not add _id to these fields, Django  
>3. Create the migrations to create the models in Postgres
>4. With Django in mind write your conversion. In other words, use the 
>Django ORM to write data to your new DB, while using RAW sql to read the 
>old DB. 
>5. Write the conversion as management command. 
>6. If you have multiple tables start filling the tables that do no 
>have any relationship to other tables first and work your way up. No FK 
>Tables-> Tables with one or more FK to an already existing table
>
>
> [1] - 
> https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style
>
>
> On 1/7/21 1:05 AM, Jérémy Garniaux wrote:
>
> Hi, 
>
> I'm working on my first Django project. Already read the tutorial but 
> following along it to be sure not to miss anything. 
>
> I've been asked to rebuild a pre-existing website. It's basic in 
> functionality: various users create complete descriptions of heritage items 
> in the admin area, and the public page display the description, mostly in 
> text format, sometimes with images too. The final user can navigate the 
> items on the public page. 
>
> The data model contains many different classes and variables - it's well 
> structured and doesn't need to change. 
>
> The data is stored into a MS SQL Server database. The new website will use 
> PostgreSQL, so I need to convert the MSQSQL database and import it into 
> PostgreSQL. I'm aware of inspectdb but I decided to manually write 
> models.py from the ground to get acquainted both with the data and with 
> django models. 
>
> What I'd like to know is: 
>
> - Should I work on the conversion and import of the MSSQL database into 
> PosgreSQL without thinking about Django at this stage? 
>
> - I read that Django will add "_id" at the end of the field names. Should 
> I worry about that? Or should I leave in PgSQL the same field names there 
> was in MSSQL? How should I name my variables in models.py then? 
>
> - Any other advice will be very welcome :) 
>
> Thanks a lot for your help, 
>
> Jeremy 
>
>
>

-- 
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/eb065ec4-7e90-4755-822a-5cdb63f17244n%40googlegroups.com.


Re: Cache pages for fast loading

2021-01-07 Thread Eugene TUYIZERE
No I only use IIS 


> On 7 Jan 2021, at 17:18, gabriela...@gmail.com  
> wrote:
> 
> Eugene:
> is IIS a Microsoft server ? Have you tray this with other server? for 
> example, APACHE. There are a lot of hosting they give host service.
> 
>> El jueves, 7 de enero de 2021 a las 12:10:19 UTC-3, eugenet...@gmail.com 
>> escribió:
>> Dear team, 
>> 
>> I deployed a django application on windows server with IIS web server. But 
>> the app is slow and I want to implement django redis for web page caching. 
>> 
>> Please assit how i can do this. 
>> 
>> 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/b1ffa15e-c3f3-4b2c-8794-0f661f93bb08n%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/6BC9EABF-05EB-4F0E-BB74-926FC7E3465C%40gmail.com.


Re: How to get request.user.username in django logger?

2021-01-07 Thread gabriela...@gmail.com
user = auth.authenticate(username=username, password=password)



El jueves, 7 de enero de 2021 a las 10:58:36 UTC-3, shailesh...@gmail.com 
escribió:

> Hello Everyone,
>
> Can you please check this question and help me what mistake I am doing.
>
>
> https://stackoverflow.com/questions/65613400/how-to-get-request-user-username-in-django-logger?noredirect=1#comment116006814_65613400
>

-- 
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/8b3f44dd-f051-4922-9efd-4e562431dac4n%40googlegroups.com.


Re: Cache pages for fast loading

2021-01-07 Thread gabriela...@gmail.com
Eugene:
is IIS a Microsoft server ? Have you tray this with other server? for 
example, APACHE. There are a lot of hosting they give host service.

El jueves, 7 de enero de 2021 a las 12:10:19 UTC-3, eugenet...@gmail.com 
escribió:

> Dear team, 
>
> I deployed a django application on windows server with IIS web server. But 
> the app is slow and I want to implement django redis for web page caching. 
>
> Please assit how i can do this.
>
> 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/b1ffa15e-c3f3-4b2c-8794-0f661f93bb08n%40googlegroups.com.


Cache pages for fast loading

2021-01-07 Thread Eugene TUYIZERE
Dear team, 

I deployed a django application on windows server with IIS web server. But the 
app is slow and I want to implement django redis for web page caching. 

Please assit how i can do this.

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/F2880DEF-ACBF-4F93-A9C5-A910F6F06242%40gmail.com.


Re: PostgreSQL Django Query

2021-01-07 Thread gabriela...@gmail.com
Sachin:
I don't understand the reason you bring 2 million records. Why you don't do 
that witht REACT? So there is not recharge the browser every time request 
data from server.

El jueves, 7 de enero de 2021 a las 11:13:23 UTC-3, sachin...@gmail.com 
escribió:

> I am using Python Django and PostgreSQL to build our report app.
>
> I am using below mention query to find some details. the query mention 
> below is running fine in PostgreSQL command line and giving result in 2 sc 
> for 2 million cards but when i i am try the same in Django application it 
> is taking too much of time and the web page is expired while running this 
> query.
>
> can anyone help how to make query faster in Django 
>
> rows = M_Assign.objects.raw(''' select C.id 
> ,M."merchant_name",C."MERCHANT_ID",S."store_id" 
> Owning_Store_ID ,S."store_name" Owning_Store_Name,F."franchisee_name" 
> Owning_Group,C."ACCOUNT_NUMBER",C."STORE_ID",C."GIFT_LIST_REF" FROM 
> vdaccount_card_assign C INNER JOIN vd_merchant_master M ON 
> C."MERCHANT_ID"=M."merchant_id" AND C."MERCHANT_ID"='003561002966107' INNER 
> JOIN vd_store_master S ON S."store_id"=C."GIFT_LIST_REF" OR 
> C."GIFT_LIST_REF"='' INNER JOIN vd_franchisee F ON 
> S."franchisee_id"=F."franchisee_id" ''')  
>

-- 
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/26fcec2b-94e4-4f42-b2e4-fdf2f881accen%40googlegroups.com.


Re: Conversion and import of a pre-existing database

2021-01-07 Thread 'Peter van der Does' via Django users
Jérémy,

It all depends on the Database which route to take. Is it one table,
multiple tab;es, what are the relationship?

My plan of attack would be:

 1. Create all models in Django as you want them to be. Use the Django
standards to name your new fields [1].
 2. Let Django handle the field naming, unless you have a really good
reason to overwrite this behavior. Relationships are setup to other
models, do not add _id to these fields, Django 
 3. Create the migrations to create the models in Postgres
 4. With Django in mind write your conversion. In other words, use the
Django ORM to write data to your new DB, while using RAW sql to read
the old DB.
 5. Write the conversion as management command.
 6. If you have multiple tables start filling the tables that do no have
any relationship to other tables first and work your way up. No FK
Tables-> Tables with one or more FK to an already existing table


[1] -
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style


On 1/7/21 1:05 AM, Jérémy Garniaux wrote:
> Hi,
>
> I'm working on my first Django project. Already read the tutorial but
> following along it to be sure not to miss anything.
>
> I've been asked to rebuild a pre-existing website. It's basic in
> functionality: various users create complete descriptions of heritage
> items in the admin area, and the public page display the description,
> mostly in text format, sometimes with images too. The final user can
> navigate the items on the public page.
>
> The data model contains many different classes and variables - it's
> well structured and doesn't need to change.
>
> The data is stored into a MS SQL Server database. The new website will
> use PostgreSQL, so I need to convert the MSQSQL database and import it
> into PostgreSQL. I'm aware of inspectdb but I decided to manually
> write models.py from the ground to get acquainted both with the data
> and with django models.
>
> What I'd like to know is:
>
> - Should I work on the conversion and import of the MSSQL database
> into PosgreSQL without thinking about Django at this stage?
>
> - I read that Django will add "_id" at the end of the field names.
> Should I worry about that? Or should I leave in PgSQL the same field
> names there was in MSSQL? How should I name my variables in models.py
> then?
>
> - Any other advice will be very welcome :)
>
> Thanks a lot for your help,
>
> Jeremy
>

-- 
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/8f0a8220-a05e-d81f-781c-c30c1f4ba0c2%40oneilinteractive.com.


Conversion and import of a pre-existing database

2021-01-07 Thread Jérémy Garniaux

Hi,

I'm working on my first Django project. Already read the tutorial but 
following along it to be sure not to miss anything.


I've been asked to rebuild a pre-existing website. It's basic in 
functionality: various users create complete descriptions of heritage 
items in the admin area, and the public page display the description, 
mostly in text format, sometimes with images too. The final user can 
navigate the items on the public page.


The data model contains many different classes and variables - it's well 
structured and doesn't need to change.


The data is stored into a MS SQL Server database. The new website will 
use PostgreSQL, so I need to convert the MSQSQL database and import it 
into PostgreSQL. I'm aware of inspectdb but I decided to manually write 
models.py from the ground to get acquainted both with the data and with 
django models.


What I'd like to know is:

- Should I work on the conversion and import of the MSSQL database into 
PosgreSQL without thinking about Django at this stage?


- I read that Django will add "_id" at the end of the field names. 
Should I worry about that? Or should I leave in PgSQL the same field 
names there was in MSSQL? How should I name my variables in models.py then?


- Any other advice will be very welcome :)

Thanks a lot for your help,

Jeremy

--
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/15c80b11-d2eb-f933-54cd-4ca066cf6ce3%40mapper.fr.


PostgreSQL Django Query

2021-01-07 Thread Sachin Kumar
I am using Python Django and PostgreSQL to build our report app.

I am using below mention query to find some details. the query mention 
below is running fine in PostgreSQL command line and giving result in 2 sc 
for 2 million cards but when i i am try the same in Django application it 
is taking too much of time and the web page is expired while running this 
query.

can anyone help how to make query faster in Django 

rows = M_Assign.objects.raw(''' select C.id 
,M."merchant_name",C."MERCHANT_ID",S."store_id" 
Owning_Store_ID ,S."store_name" Owning_Store_Name,F."franchisee_name" 
Owning_Group,C."ACCOUNT_NUMBER",C."STORE_ID",C."GIFT_LIST_REF" FROM 
vdaccount_card_assign C INNER JOIN vd_merchant_master M ON 
C."MERCHANT_ID"=M."merchant_id" AND C."MERCHANT_ID"='003561002966107' INNER 
JOIN vd_store_master S ON S."store_id"=C."GIFT_LIST_REF" OR 
C."GIFT_LIST_REF"='' INNER JOIN vd_franchisee F ON 
S."franchisee_id"=F."franchisee_id" ''')  

-- 
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/4a0669b5-5417-484d-b66d-c25dd83d2ebfn%40googlegroups.com.


How to get request.user.username in django logger?

2021-01-07 Thread Shailesh Yadav
Hello Everyone,

Can you please check this question and help me what mistake I am doing.

https://stackoverflow.com/questions/65613400/how-to-get-request-user-username-in-django-logger?noredirect=1#comment116006814_65613400

-- 
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/271b7890-ba69-422c-a5b9-155b2116330dn%40googlegroups.com.


Re: Two models one form, or use generic CreateView

2021-01-07 Thread _M_A_Y_A_N_K_
You could use InlineFormSet, which is designed specially to handle such
problems. Refer to the documentations here
https://docs.djangoproject.com/en/3.1/topics/forms/modelforms/#inline-formsets


Here you could provide the primary model (in your case it will be
CUstomUser), and the secondary model (which will be Address).
Something similar to below.


from django.forms import inlineformset_factoryCustomerFormSet =
inlineformset_factory(CustomUser, Address, fields=('email',
'firstname', ..  'address','zipcode',))

  Hope this helps.


Thanks & Regards,
-
Mayank Tripathi
"Do what you can, with what you have, where you are -by Theodore Roosevelt"
https://datascience.foundation/datascienceawards



On Tue, Jun 9, 2020 at 7:36 AM The Sha  wrote:

> Hi
>
> I hava a problem in django, i have to models one is a CustomUser Model and
> the other is a Address model.
>
> The problem is that when i create a generic CreateView for the Address
> model and use a pk: url the address form wont get the instance of the users
> PK for adding a new address.
>
> my models look like this, Even though i pass the PK in the URL the
> CreateView does not understand that i want to add a address to user with
> id: 42 in this example. How can i solve this problem?
>
>
>
>
>
>
>
> The URL
>  path('/address', views.AddressCreateView.as_view(),
> name='Address-add'),
>
>
> *This is my view*
> class AddressCreateView(CreateView):
> model = Address
> template_name = 'members/address_form.html'
> success_url = reverse_lazy('MemberIndex')
> fields = ('CustomUser', 'address', 'zip_code', 'city', 'state',
> 'active')
>
>
> *The model*
> class CustomUser(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(_('email address'), unique=True)
> personal_Id = models.CharField(max_length=12, blank=False)
> first_name = models.CharField(_('first name'), max_length=30, blank=
> True)
> middle_name = models.CharField('middle name', max_length=30, blank=
> True)
> last_name = models.CharField(_('last name'), max_length=30, blank=True
> )
> is_staff = models.BooleanField(default=False)
> is_active = models.BooleanField(default=True)
> date_joined = models.DateTimeField(default=timezone.now)
> avatar = models.ImageField(upload_to='images', blank=True)
>
> def __str__(self):
> return self.email
>
> def full_name(self):
> return '%s %s %s' % (self.first_name, self.middle_name, self
> .last_name)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = []
>
>
> objects = CustomUserManager()
>
> class Address(models.Model):
> CustomUser = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
> address = models.CharField(max_length=60, blank=False)
> zip_code = models.CharField(max_length=8, blank=False)
> city = models.CharField(max_length=30, blank=False)
> state = models.CharField(max_length=30, blank=False)
> active = models.BooleanField(name='active', default=True, editable=
> True)
> address_reg_date = models.DateTimeField(default=timezone.now)
> class Meta:
> verbose_name_plural = "Address"
>
> def __str__(self):
>  return self.address +', '+ str(self.zip_code) + ', ' + self.city
>
>
>
>
>
> --
> 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/d0d3596f-6c0e-4928-8e57-7eb5476821d3o%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/CALQo0B8n1%2B%3D9LzLBDdb-VeJjUc7vW92Cxjo4fc6bGzuPnHwRGw%40mail.gmail.com.


Re: Two models one form, or use generic CreateView

2021-01-07 Thread Farai M
Your code is fine but you will need to preload your form with the customer
which you want this can be done in the get method of that create view.Read
more about  use of DjangoModel form
https://docs.djangoproject.com/en/3.1/topics/forms/modelforms/
Then override the get() method  and respond with the form populated with
the customer details  .

Alternative use javascript to just take the  pk from your url

Alternatively  pass it as a separate argument in your context  by again
overriding the get() method.

Personally will do it right way using  model forms

On Tue, Jun 9, 2020 at 2:35 PM The Sha  wrote:

> Hi
>
> I hava a problem in django, i have to models one is a CustomUser Model and
> the other is a Address model.
>
> The problem is that when i create a generic CreateView for the Address
> model and use a pk: url the address form wont get the instance of the users
> PK for adding a new address.
>
> my models look like this, Even though i pass the PK in the URL the
> CreateView does not understand that i want to add a address to user with
> id: 42 in this example. How can i solve this problem?
>
>
>
>
>
>
>
> The URL
>  path('/address', views.AddressCreateView.as_view(),
> name='Address-add'),
>
>
> *This is my view*
> class AddressCreateView(CreateView):
> model = Address
> template_name = 'members/address_form.html'
> success_url = reverse_lazy('MemberIndex')
> fields = ('CustomUser', 'address', 'zip_code', 'city', 'state',
> 'active')
>
>
> *The model*
> class CustomUser(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(_('email address'), unique=True)
> personal_Id = models.CharField(max_length=12, blank=False)
> first_name = models.CharField(_('first name'), max_length=30, blank=
> True)
> middle_name = models.CharField('middle name', max_length=30, blank=
> True)
> last_name = models.CharField(_('last name'), max_length=30, blank=True
> )
> is_staff = models.BooleanField(default=False)
> is_active = models.BooleanField(default=True)
> date_joined = models.DateTimeField(default=timezone.now)
> avatar = models.ImageField(upload_to='images', blank=True)
>
> def __str__(self):
> return self.email
>
> def full_name(self):
> return '%s %s %s' % (self.first_name, self.middle_name, self
> .last_name)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = []
>
>
> objects = CustomUserManager()
>
> class Address(models.Model):
> CustomUser = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
> address = models.CharField(max_length=60, blank=False)
> zip_code = models.CharField(max_length=8, blank=False)
> city = models.CharField(max_length=30, blank=False)
> state = models.CharField(max_length=30, blank=False)
> active = models.BooleanField(name='active', default=True, editable=
> True)
> address_reg_date = models.DateTimeField(default=timezone.now)
> class Meta:
> verbose_name_plural = "Address"
>
> def __str__(self):
>  return self.address +', '+ str(self.zip_code) + ', ' + self.city
>
>
>
>
>
> --
> 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/d0d3596f-6c0e-4928-8e57-7eb5476821d3o%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/CAMeub5OaCoBaix2Y5igC3475K7Zxg5gfNHf4DAF01XUhvD2j8g%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-07 Thread Steven Mapes
Within Django Admin or somewhere else?
Are you using FileFields and trying to save to the models or are you just 
trying to POST multiple files?

On Thursday, 7 January 2021 at 12:25:10 UTC allaberdi...@gmail.com wrote:

>

-- 
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/ba3a4c6a-0788-457f-8e7d-576d612a7f61n%40googlegroups.com.


hello guys, how can I upload multiple images using single button? help me please

2021-01-07 Thread Chelsea Fan


-- 
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/CAJwZndca8SC7ifBzyW4ut%3DJXy-2E3RPPvq2tHrpCyxyqABQnzw%40mail.gmail.com.