Debug Django Test-cases

2022-02-25 Thread HEMENDRA SINGH HADA
Hi Team,

I am writing some django test-cases, there are multiple test-cases are 
failing inside view or models, but I am not getting exact root cause for 
those failure, 

Could you please suggest me any tool which is used to debug the django unit 
test cases, Also if you can share my some good document to write test-cases.

Thanks in advance !!!

 

-- 
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/11209f55-3ef0-4b96-b384-93d9c2fa9531n%40googlegroups.com.


Too many SQL variable

2019-02-18 Thread HEMENDRA SINGH HADA
Hi All,
In my current project we are using sqlite3, When I am fetching data from 
sqlite3 db tables and counting the query-set length it is giving me error 
"Too many SQL query" when the length is more than 999. till 999 its working 
fine, Please suggest some quick fix for this,

Thanks in Advance 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11911c44-ea93-443e-87aa-05e34b0dcc08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Too many SQL variable

2019-02-18 Thread HEMENDRA SINGH HADA
Hi,

Could you give me some quick fix, I am using django currently, or could be 
please suggest me how to take the parent table data with prefetch related 
filter. 

Thanks 

On Monday, February 18, 2019 at 6:21:33 PM UTC+5:30, Sebastian Henschel 
wrote:
>
> Heya, 
>
> Am 18.02.19 um 10:52 schrieb HEMENDRA SINGH HADA: 
>
> > In my current project we are using sqlite3, When I am fetching data from 
> > sqlite3 db tables and counting the query-set length it is giving me 
> error 
> > "Too many SQL query" when the length is more than 999. till 999 its 
> working 
> > fine, Please suggest some quick fix for this, 
>
> The first questions which comes to my mind is, if you can rework your 
> queries? 
> Otherwise, i am not using sqlite3, but just found this, from 
> https://www.sqlite.org/limits.html : 
>
> - 
>
> Maximum Number Of Host Parameters In A Single SQL Statement 
>
> A host parameter is a place-holder in an SQL statement that is filled in 
> using one of the sqlite3_bind_() interfaces. Many SQL programmers 
> are familiar with using a question mark ("?") as a host parameter. 
> SQLite also supports named host parameters prefaced by ":", "$", or "@" 
> and numbered host parameters of the form "?123". 
>
> Each host parameter in an SQLite statement is assigned a number. The 
> numbers normally begin with 1 and increase by one with each new 
> parameter. However, when the "?123" form is used, the host parameter 
> number is the number that follows the question mark. 
>
> SQLite allocates space to hold all host parameters between 1 and the 
> largest host parameter number used. Hence, an SQL statement that 
> contains a host parameter like ?10 would require gigabytes of 
> storage. This could easily overwhelm the resources of the host machine. 
> To prevent excessive memory allocations, the maximum value of a host 
> parameter number is SQLITE_MAX_VARIABLE_NUMBER, which defaults to 999. 
>
> The maximum host parameter number can be lowered at run-time using the 
> sqlite3_limit(db,SQLITE_LIMIT_VARIABLE_NUMBER,size) interface. 
>
> --- 
>
> Maybe you can put a call to this interface into a startup script 
> somewhere? 
>
> Cheers, 
> -- 
> Sebastian Henschel 
> Softwareentwickler Passivhaus Institut 
> http://passiv.de 
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72462981-45e8-410c-ace7-1af9fd978d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Downgrade and Upgrade Django migration

2018-08-04 Thread HEMENDRA SINGH HADA
I have a django based application. In this we are providing backup and 
restore facility for user. DB which we are using is sqlite. So please 
suggest me how to migrate database accordingly - both downgrade and upgrade 
for sqlite. 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c103056c-a8e5-410d-adb3-b0d9bc5d1ac5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Downgrade and Upgrade Django migration

2018-08-04 Thread HEMENDRA SINGH HADA
Sorry for making requirement complex. My requirement is like I have
released first version of my app. After that we have change some table
attribute and also added some new tables in my app DB(sqlite). In this
sitution  I need both side compatibility(Downgrade and upgrade) for my
application.

On Sat, Aug 4, 2018 at 8:59 PM Andréas Kühne 
wrote:

> Hi,
>
> I don't really understand your requirements here. If you take a backup you
> will get the database exactly how the database is now. If you have made any
> changes to the database layout, you would be able to run migrations again
> to upgrade the database to the latest again. For this you can use the
> standard migrations in Django.
>
> The database stores the level of migrations the database has been migrated
> to - so you can reload a backup at any stage.
>
> Regards,
>
> Andréas
>
> 2018-08-04 16:23 GMT+02:00 HEMENDRA SINGH HADA 
> :
>
>> I have a django based application. In this we are providing backup and
>> restore facility for user. DB which we are using is sqlite. So please
>> suggest me how to migrate database accordingly - both downgrade and upgrade
>> for sqlite.
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/c103056c-a8e5-410d-adb3-b0d9bc5d1ac5%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/c103056c-a8e5-410d-adb3-b0d9bc5d1ac5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAK4qSCcPJ15gtsDmptp5vv4j4%3D_Q7CLDJq1Z5S5eUv1pqLrcow%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK4qSCcPJ15gtsDmptp5vv4j4%3D_Q7CLDJq1Z5S5eUv1pqLrcow%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACgU_Vj7LqC0Q2Gs7DrwY%3D62%3DySmJkiKE4TTGmptP3K1Q%3DOrkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


sqlite DB missed DEFAULT parameter from table definition

2018-08-06 Thread HEMENDRA SINGH HADA
Hi Team, 

My application using sqlite DB and in my model table class, I have define 
attributes like Below - 

class MyUser(AbstractBaseUser):
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True,
)
date_of_birth = models.DateField()
   * is_active = models.BooleanField(default=True)*
*is_admin = models.BooleanField(default=False)*

objects = MyUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['date_of_birth']


But we I see the same table in sqlite interface, it shows me table 
definition like this-

sqlite> .dump authapp_myuser
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "authapp_myuser" ("id" integer NOT NULL PRIMARY KEY 
AUTOINCREMENT, "password" varchar(128) NOT NULL, "last_login" datetime 
NULL, "email" varchar(255) NOT NULL UNIQUE, "date_of_birth" date NOT NULL, 
*"is_active" 
bool NOT NULL, "is_admin" bool NOT NULL*);
COMMIT;

If I am giving is_active field with default value *True*, Then why its not 
showing in *"is_active" bool NOT NULL.* 
 
This case is working fine when I insert any data from GUI application or 
Django admin page, If I try to insert something from sqlite interface, I 
need to pass that default value too. 

Please give some suggestion, Because I have requirment where I need to 
insert or update the table values from outside Django App.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f55d1c9f-a23d-45be-a372-3a77b42ff7cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: sqlite DB missed DEFAULT parameter from table definition

2018-08-06 Thread HEMENDRA SINGH HADA
Than How can I achieve my Goal with sqlite and Django ?? 
Do you have any solution for that ??


On Monday, August 6, 2018 at 10:49:29 PM UTC+5:30, HEMENDRA SINGH HADA 
wrote:
>
> Hi Team, 
>
> My application using sqlite DB and in my model table class, I have define 
> attributes like Below - 
>
> class MyUser(AbstractBaseUser):
> email = models.EmailField(
> verbose_name='email address',
> max_length=255,
> unique=True,
> )
> date_of_birth = models.DateField()
>* is_active = models.BooleanField(default=True)*
> *is_admin = models.BooleanField(default=False)*
>
> objects = MyUserManager()
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['date_of_birth']
>
>
> But we I see the same table in sqlite interface, it shows me table 
> definition like this-
>
> sqlite> .dump authapp_myuser
> PRAGMA foreign_keys=OFF;
> BEGIN TRANSACTION;
> CREATE TABLE "authapp_myuser" ("id" integer NOT NULL PRIMARY KEY 
> AUTOINCREMENT, "password" varchar(128) NOT NULL, "last_login" datetime 
> NULL, "email" varchar(255) NOT NULL UNIQUE, "date_of_birth" date NOT NULL, 
> *"is_active" 
> bool NOT NULL, "is_admin" bool NOT NULL*);
> COMMIT;
>
> If I am giving is_active field with default value *True*, Then why its 
> not showing in *"is_active" bool NOT NULL.* 
>  
> This case is working fine when I insert any data from GUI application or 
> Django admin page, If I try to insert something from sqlite interface, I 
> need to pass that default value too. 
>
> Please give some suggestion, Because I have requirment where I need to 
> insert or update the table values from outside Django App.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e4102182-823a-4633-8221-431eb358ca69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Apache runs wsgi module twice in case of public router ip and internal server ip ?

2018-08-17 Thread HEMENDRA SINGH HADA
We've below netwrok setup
Internal server ip : 192.168.153.20:443
Public router ip : 111.93.87.11:26060 

We've port forwarding in router : 111.93.87.11:26060 to 192.168.153.20:443

So when we first access 192.168.153.20:443(Internal server ip) it 
runs/execute django application ( First time )
Now when we access 111.93.87.11:26060 (Public router ip) - due to port 
forwarding it comes to internal server ip but as apache receives 
host:111.93.87.11:26060,apache execute/run whole django application second 
time.

So ulimately our application is being run two times for ip i.e internal ip 
and public router ip.
This is creating very critical issue.
*We need to run single instance for both internal and external IP. But it 
seems Apache parsing host name and running different instance for new 
external IP*

Apache configuration 
Listen 192.168.153.120:80
Listen localhost:80
Listen 192.168.153.120:443 ( Configuration in SSL file)


ServerName 192.168.153.120:443

WSGIDaemonProcess abcadmin 
python-path=/usr/local/abc/webservice/abcadmin/abcadmin:/usr/local/lib/python3.4/site-package
 
user=abc group=abc processes=1 threads=20 display-name=%{GROUP}
WSGIProcessGroup abcadmin
WSGIScriptAlias / /usr/local/abc/webservice/abcadmin/abcadmin/wsgi.py

Redirect / http://192.168.153.120:443


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bdbb7bf9-7bad-4202-8db9-2df68fd384f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to delete least recently used not expired django sessions?

2018-08-18 Thread HEMENDRA SINGH HADA
Hi,

I can suggest one thing it might be useful for you. For this you need to 
create one more attribute in session table like *last activity,* which will 
update every time when user is logged in and perform some action. Write one 
middle-ware which will check the activity of each user and update *last 
activity *field in request repose cycle.

I am not sure will this approach is acceptable for your current scenario.

Thanks,
Hemendra Singh


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61033f3d-18cd-4302-abfb-4e6614257e1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can we secure django python files for production release?

2018-11-15 Thread HEMENDRA SINGH HADA
As we know python is interpreted language and we've to give it in readable 
format ? But how we can secure those files for production release so 
customer can't change it or modify it ? As like in Bin in C++, jar in JAVA 
and .exe in .Net

https://stackoverflow.com/questions/53313395/how-can-we-secure-django-python-files-for-production-release

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/886b0ecc-f944-4088-b82a-945fc38a9fb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.