Re: Finding the last modified timestamp for a group of Models

2024-02-28 Thread Jason
https://docs.djangoproject.com/en/5.0/ref/applications/#django.apps.AppConfig.get_models

gets you an iterable of all models loaded
On Tuesday, February 27, 2024 at 8:53:32 AM UTC-5 Alex Guetsche wrote:

> I have an application which contains more than one Model, all descended 
> from an abstract one. All the operational Models have created and modified 
> fields 
> with datetime timestamps. [How] can I get the Django ORM to bring me the 
> last modified timestamp that will be the maximum of all createds and 
> modifieds of all Models? Right now I have to use itertools for a quite 
> convoluted expression over query sets of all the models involved.
>
> It seems quite an obvious use case, and it can be implemented in pure SQL 
> quite easily.
>

-- 
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/b138d163-29a3-4c45-a6fd-f0af6ef4d67bn%40googlegroups.com.


Re: Data model design questio: graph in database

2024-02-25 Thread Jason
Question about this, why focus on using a rdbms for this functionality vs 
using an actual graph db like neo4j with neomodel 
?

On Sunday, February 25, 2024 at 7:59:31 PM UTC-5 Mike Dewhirst wrote:

> Re-reading your question perhaps I was too brief in my earlier response. 
> Let me assume all your actual edges and vertices are objects of child 
> classes. I also assume  your base Edge and Vertex classes are abstract for 
> inheritance purposes only.
>
> It doesn't matter whether instances of edges and vertices are in lists. 
> You can call obj.which_class() on any object which has (inherited) that 
> method to determine whether an edge (or vertex) is type_1 or type_2 (using 
> our previous terminology)
>
> You cannot query the database using the return value from which_class() 
> because that operates on instances not at the database level. Therefore you 
> have to retrieve edges and vertices from the database with a query which 
> fetches related rows and then filter the results afterwards. Perhaps like 
> this ...
>
> vertex_src = result_of_vertex_finder(...)
> vertex_det = result_of_vertex_finder(...)
> if vertex_src and vertex_dst:
> edges_1 = Edge_type_1.objects.filter(src=vertex_src, dst=vertex_dst) 
> or []
> edges_2 = Edge_type_2.objects.filter(src=vertex_src, dst=vertex_dst) 
> or []
> all_edges = [edges_1].extend[edges_2]
>
> if all_edges:
> edges_type_1 = [edge for edge in all_edges if edge.which_class() == 
> "type 1"]
> edges_type_2 = [edge for edge in all_edges if edge.which_class() == 
> "type 2"]
>
> On the other hand, if you want to keep all edges in the same database 
> table it might be better/simpler to add a field 'type' to the table as you 
> were originally thinking.  
>
> Cheers
>
> Mike
>
>
>
> On Sunday, February 25, 2024 at 9:47:12 PM UTC+11 Sébastien Hinderer wrote:
>
>> Dear Mike, 
>>
>> I will definitely play aroudn with your nice suggestion, but I would like 
>> to share a concern I have. At this stage I am actually unsure how this 
>> will work. 
>>
>> Indeed, suppose a vertex is given as input and one tries to query the 
>> database about all the edges that originate from this vertex. The answer 
>> will be under the form of a list of edges, but those will be of class 
>> Edge and I assume that their type method will return the Edge class 
>> and not the class associated to the actual child. 
>>
>> Likewise, once given the list of edges, one has access to the list of 
>> vertices that are neiighbourgs of the original one, but under the form 
>> of a list of objects of the base class, Vertex, with still no way to find 
>> the type of the child object that has given rise to that Vertex one. 
>>
>> Am I perhaps missing something here? 
>>
>> Many thanks in advance and apologies for th likely naïve question, 
>>
>> Seb. 
>>
>

-- 
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/80e65b9b-154b-4dd1-aeba-46ec898560ben%40googlegroups.com.


Re: Question about `_meta` API's naming

2024-02-21 Thread Jason
https://forum.djangoproject.com/ would be a better place to ask, FYI.

as far as why keep private... lets flip it around.  Why make it public?  
what's the benefit of this change?

Having it private means that the API internals can change if necessary

On Tuesday, February 20, 2024 at 10:15:43 AM UTC-5 Gyeong Hoe Koo wrote:

> As the documentation says, Django's `_meta` API is core (
> https://docs.djangoproject.com/en/5.0/ref/models/meta/), but in my 
> knowledge, APIs that start with `_` are private. Table names, etc. are one 
> of the important APIs, and they seem to be pretty stable. Shouldn't we make 
> them public instead of hiding them as private? Any idea why they are kept 
> as `_meta`? I tried to search history on this decision but I cannot get any 
> clues.
>
> 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/a4f03954-c0f9-4a55-91f5-e531e3d66518n%40googlegroups.com.


Re: Django 4.2, PyPy and Postgres

2023-12-12 Thread Jason
sweet, glad this worked out, and hope the initial promise continues to hold 
true.

On Tuesday, December 12, 2023 at 12:58:11 PM UTC-5 Pete Doherty wrote:

> Interestingly, I can confirm that using Psycopg 3 *does *seem to work. I 
> only got it working a few minutes ago, so it has not been thoroughly tested 
> but my test suite passes, which is very encouraging.
>
> Thanks for the nudge, Jason.
>
> On Tuesday, December 12, 2023 at 10:51:29 AM UTC-5 Pete Doherty wrote:
>
>> I did try using psycopg2-binary and the app wouldn't start. I'll have to 
>> revisit to find what that exact error was. That's a good suggestion, 
>> though, as I did not try with the Python (i.e. non-binary) package. 
>>
>> Anyways, the consensus after a quick web search seemed to be to use 
>> psycopg2cffi when using PyPy. I'm open to any driver that'll work, though. 
>> This is just an experiment.
>>
>> On Monday, December 11, 2023 at 9:28:06 PM UTC-5 Jason wrote:
>>
>>> the last release of psycopg2cffi was January 2021
>>>
>>> pypy support for 3.10 came out Dec 2022
>>>
>>> Is there a reason you're on psycopg2cffi?  have you tried with regular 
>>> psycopg2?
>>>
>>> On Monday, December 11, 2023 at 3:19:11 PM UTC-5 Pete Doherty wrote:
>>>
>>>> I'm wondering if anyone is using Django 4.2, PyPy 3.10 and Postgres 15?
>>>>
>>>> I tried using psycopg2cffi==2.9.0 and it works up until a point but 
>>>> eventually fails with a series of errors relating to imports.
>>>>
>>>> After adding the compatibility layer to the top of my settings.py 
>>>> script using:
>>>>
>>>> > from psycopg2cffi import compat, errorcodes
>>>> > compat.register()
>>>>
>>>>
>>>> The first error I see is:
>>>>
>>>> > ImportError: cannot import name 'errors' from 'psycopg2cffi' 
>>>> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>>>>
>>>> I see the errors module in the psycopg2cffi repo and seem to be able to 
>>>> import it like so:
>>>>
>>>> > import psycopg2cffi
>>>> > from psycopg2cffi import compat, errorcodes
>>>> psycopg2cffi.errors = errorcodes
>>>>
>>>> I then see an error stating:
>>>>
>>>> > ImportError: cannot import name 'sql' from 'psycopg2cffi' 
>>>> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>>>>
>>>> While I see the sql.py module in the repo, it does not seem to be 
>>>> included in the built psycopg2cffi package. Trying to patch it in results 
>>>> in:
>>>>
>>>> > from psycopg2cffi import sql
>>>> > psycopg2cffi.sql = sql
>>>>
>>>> > ImportError: cannot import name 'sql' from 'psycopg2cffi' 
>>>> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>>>>
>>>> I tried copying sql.py into my locally installed package and that 
>>>> resulted yet another error:
>>>>
>>>> > ImportError: cannot import name 'PY3' from 'psycopg2cffi.compat' 
>>>> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/compat.py)
>>>>
>>>> So, before I go any further down this path, I wanted to see if anyone 
>>>> is using this setup, knows that it will definitely not work or has any 
>>>> suggestions about alternatives.
>>>>
>>>> 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/0391321a-7681-44ec-bf8e-68e16d03aa5an%40googlegroups.com.


Re: Django 4.2, PyPy and Postgres

2023-12-11 Thread Jason
the last release of psycopg2cffi was January 2021

pypy support for 3.10 came out Dec 2022

Is there a reason you're on psycopg2cffi?  have you tried with regular 
psycopg2?

On Monday, December 11, 2023 at 3:19:11 PM UTC-5 Pete Doherty wrote:

> I'm wondering if anyone is using Django 4.2, PyPy 3.10 and Postgres 15?
>
> I tried using psycopg2cffi==2.9.0 and it works up until a point but 
> eventually fails with a series of errors relating to imports.
>
> After adding the compatibility layer to the top of my settings.py script 
> using:
>
> > from psycopg2cffi import compat, errorcodes
> > compat.register()
>
>
> The first error I see is:
>
> > ImportError: cannot import name 'errors' from 'psycopg2cffi' 
> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>
> I see the errors module in the psycopg2cffi repo and seem to be able to 
> import it like so:
>
> > import psycopg2cffi
> > from psycopg2cffi import compat, errorcodes
> psycopg2cffi.errors = errorcodes
>
> I then see an error stating:
>
> > ImportError: cannot import name 'sql' from 'psycopg2cffi' 
> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>
> While I see the sql.py module in the repo, it does not seem to be included 
> in the built psycopg2cffi package. Trying to patch it in results in:
>
> > from psycopg2cffi import sql
> > psycopg2cffi.sql = sql
>
> > ImportError: cannot import name 'sql' from 'psycopg2cffi' 
> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/__init__.py)
>
> I tried copying sql.py into my locally installed package and that resulted 
> yet another error:
>
> > ImportError: cannot import name 'PY3' from 'psycopg2cffi.compat' 
> (/home/appuser/.local/lib/pypy3.10/site-packages/psycopg2cffi/compat.py)
>
> So, before I go any further down this path, I wanted to see if anyone is 
> using this setup, knows that it will definitely not work or has any 
> suggestions about alternatives.
>
> 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/705f19aa-4e6e-4690-b3c5-da28715fd61dn%40googlegroups.com.


Re: Dynamic Table

2023-05-24 Thread Jason
I hope you can understand the security implications of this and are 
knowledgeable on the places where you need to lock down access.  
On Wednesday, May 24, 2023 at 6:47:14 AM UTC-4 Helly Modi wrote:

> we have to create this project where user can enter all details of table 
> from frontend and table is created in backend so this idea was given where 
> these and have to work on this idea only.see image for better understanding.
>
> On Wed, May 24, 2023 at 4:10 PM Anh Nguyen  wrote:
>
>> So what is your problems and why do we need a dynamic table?
>>
>> On Wed, 24 May 2023 at 14:34 Helly Modi  wrote:
>>
>>> 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
>  
> 
> .
>
 -- 
>>> 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/104d78f3-3aa0-4962-a640-d4a59eca717fn%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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAKaoNbT0DsxHt_N6L%2B%2Bn-YV-KrGY%2BN8onNAymkOq2BxAVGO99Q%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/a0f96f17-8881-4bb4-9540-fe0d38594d63n%40googlegroups.com.


Re: Annotate and Subquery with 2 tables in 2 different databases

2023-04-20 Thread Jason
this won't work, you're doing things across two entire dbs.  So you'l have 
to implement all the logic in python to execute.

On Thursday, April 20, 2023 at 9:58:20 AM UTC-4 Mạnh ĐỖ wrote:

> I want to use annotate and subquery to join tables.
> Table1 in database1 and table2 in database2. But it's not work.
> I got the error:
>
>  QuerySet.annotate() received non-expression(s): database1.
>
> the code here:
> from django.db.models import Subquery, OuterRef, Count from app1.models 
> import Table1 from app2.models import Table2 subquery = Table2.objects.
> filter(table1_id=OuterRef('id')).values('table1_id').annotate(count=Count(
> 'id')).values('count') queryset = 
> Table1.objects.annotate(table2_count=Subquery(subquery, 
> output_field=models.IntegerField()), using='database1')
>
> Could anyone help me?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99dc653f-ad9e-445a-8d06-310f3351b66dn%40googlegroups.com.


Re: Migration running in shell, but no change in DB

2023-04-06 Thread Jason
you said you have a router.py file in your project?  put it in there.

On Thursday, April 6, 2023 at 10:50:15 AM UTC-4 Martin Heitmann wrote:

> Dear Jason
>
> db per project/app: Okay, I will keep that in mind for the future. I just 
> thought that it would be a cleaner way when each db and app would serve a 
> single purpose
>
> logging: I am sorry, but I have to ask again, where do I put that what you 
> wrote ( logger.info("db does not match db app name"), or raise 
> Exception("db does not match app name"))? Does this belong in the router.py 
> or migration file or another place?
> Best regards
> Martin
>
> On Wednesday, April 5, 2023 at 9:40:27 PM UTC+2 Jason wrote:
>
>> ahhh, no not at all.  One db per project, yes.  Application, no.  That's 
>> really expanding complexity. If you need that requirement, that's one 
>> thing, but its something you really should have an explicit requirement for 
>> before designing.
>>
>> As far as the second question, no not at all.  Just add logging there, or 
>> raise an exception
>>
>> ie, logger.info("db does not match db app name"), or raise Exception("db 
>> does not match app name")
>>
>> On Wednesday, April 5, 2023 at 12:45:01 PM UTC-4 Martin Heitmann wrote:
>>
>>> Dear Jason
>>>
>>> Thanks for all your effort.
>>>
>>> Yes, I have one db per application. Isn't that a way to keep the 
>>> databases clean and strictly focused on one purpose? Thought that that 
>>> would be a good idea. Regarding the router.py: It worked for quite a while, 
>>> but I am not sure if I made changes to it previous to the first occurence 
>>> of the problem. But should it not work when every router has an entry like 
>>> this:
>>>
>>> def allow_migrate(self, db, app_label, model_name=None, **hints):
>>> if app_label == 'app_name':
>>> return db == 'db_app_name'
>>> return None
>>>
>>> You wrote "What happens when you put some logging there, or raise an 
>>> exception on None/False? ". I would love to do that but I do not know, 
>>> where I must put that. I guess I must find some place in the code that 
>>> calls allow_migrate and check what the return value is, right?
>>>
>>> On Wednesday, April 5, 2023 at 12:54:58 PM UTC+2 Jason wrote:
>>>
>>>> so, for your original boolean migration, 
>>>>
>>>> https://code.djangoproject.com/ticket/470
>>>>
>>>> https://stackoverflow.com/questions/32280343/default-value-of-djangos-model-doesnt-appear-in-sql
>>>>
>>>> Adding a default value doesn't go to SQL, although there's work in the 
>>>> django ticket above.  So its inserted via app code and the original 
>>>> question might have been a red herring and the actual issue is your 
>>>> CreateModel is never applied.
>>>>
>>>> ouch, you have one db per application?  that could likely be it, when 
>>>> was this routing put in place?  Did it exist before the last working 
>>>> migration on this project?  Reason I ask, 
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *python3 manage.py sqlmigrate ObjPLW2 0037 --database=db_obj_plw2 
>>>> Create model Wartungsarbeit--CREATE TABLE `ObjPLW2_wartungsarbeit` (`id` 
>>>> integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `wa_titel` varchar(201) NOT 
>>>> NULL, `wa_beschreibung` longtext NOT NULL, `wa_turnus` integer UNSIGNED 
>>>> NOT 
>>>> NULL CHECK (`wa_turnus` >= 0), `wa_startdatum` date NOT NULL, 
>>>> `wa_erstelldatum` datetime(6) NOT NULL, `wa_bearbeitungsdatum` datetime(6) 
>>>> NOT NULL);*
>>>>
>>>> is vaid SQL and that's what django would send to your db.  So if its 
>>>> not being applied, the allow_migrate might be at cause here.  What happens 
>>>> when you put some logging there, or raise an exception on None/False?  The 
>>>> docs at 
>>>> https://docs.djangoproject.com/en/4.1/topics/db/multi-db/#allow_migrate
>>>>  state
>>>>
>>>>
>>>> *makemigrations always creates migrations for model changes, but if 
>>>> allow_migrate() returns False, any migration operations for the model_name 
>>>> will be silently skipped when running migrate on the db. *
>>>>
>>>>
>>>> On Wednesday, April 5, 2023 at 1:52:12 AM UTC-4 Martin Heitmann

Re: Migration running in shell, but no change in DB

2023-04-05 Thread Jason
ahhh, no not at all.  One db per project, yes.  Application, no.  That's 
really expanding complexity. If you need that requirement, that's one 
thing, but its something you really should have an explicit requirement for 
before designing.

As far as the second question, no not at all.  Just add logging there, or 
raise an exception

ie, logger.info("db does not match db app name"), or raise Exception("db 
does not match app name")

On Wednesday, April 5, 2023 at 12:45:01 PM UTC-4 Martin Heitmann wrote:

> Dear Jason
>
> Thanks for all your effort.
>
> Yes, I have one db per application. Isn't that a way to keep the databases 
> clean and strictly focused on one purpose? Thought that that would be a 
> good idea. Regarding the router.py: It worked for quite a while, but I am 
> not sure if I made changes to it previous to the first occurence of the 
> problem. But should it not work when every router has an entry like this:
>
> def allow_migrate(self, db, app_label, model_name=None, **hints):
> if app_label == 'app_name':
> return db == 'db_app_name'
> return None
>
> You wrote "What happens when you put some logging there, or raise an 
> exception on None/False? ". I would love to do that but I do not know, 
> where I must put that. I guess I must find some place in the code that 
> calls allow_migrate and check what the return value is, right?
>
> On Wednesday, April 5, 2023 at 12:54:58 PM UTC+2 Jason wrote:
>
>> so, for your original boolean migration, 
>>
>> https://code.djangoproject.com/ticket/470
>>
>> https://stackoverflow.com/questions/32280343/default-value-of-djangos-model-doesnt-appear-in-sql
>>
>> Adding a default value doesn't go to SQL, although there's work in the 
>> django ticket above.  So its inserted via app code and the original 
>> question might have been a red herring and the actual issue is your 
>> CreateModel is never applied.
>>
>> ouch, you have one db per application?  that could likely be it, when was 
>> this routing put in place?  Did it exist before the last working migration 
>> on this project?  Reason I ask, 
>>
>>
>>
>>
>>
>>
>>
>> *python3 manage.py sqlmigrate ObjPLW2 0037 --database=db_obj_plw2 
>> Create model Wartungsarbeit--CREATE TABLE `ObjPLW2_wartungsarbeit` (`id` 
>> integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `wa_titel` varchar(201) NOT 
>> NULL, `wa_beschreibung` longtext NOT NULL, `wa_turnus` integer UNSIGNED NOT 
>> NULL CHECK (`wa_turnus` >= 0), `wa_startdatum` date NOT NULL, 
>> `wa_erstelldatum` datetime(6) NOT NULL, `wa_bearbeitungsdatum` datetime(6) 
>> NOT NULL);*
>>
>> is vaid SQL and that's what django would send to your db.  So if its not 
>> being applied, the allow_migrate might be at cause here.  What happens when 
>> you put some logging there, or raise an exception on None/False?  The docs 
>> at 
>> https://docs.djangoproject.com/en/4.1/topics/db/multi-db/#allow_migrate
>>  state
>>
>>
>> *makemigrations always creates migrations for model changes, but if 
>> allow_migrate() returns False, any migration operations for the model_name 
>> will be silently skipped when running migrate on the db. *
>>
>>
>> On Wednesday, April 5, 2023 at 1:52:12 AM UTC-4 Martin Heitmann wrote:
>>
>>> Dear Jason
>>>
>>> Thanks for your reply. I am not absolulety sure what this question means 
>>> "What specifically was the changeset occurring and what isn't? ", but I try 
>>> to answer it the best way I can. I worked on the app quite a while ago and 
>>> back then everything seemed to work. As far as I can understand my own 
>>> steps back then I tried to alter only one field.
>>>
>>> extract from migrations file:
>>>  migrations.AlterField(
>>> model_name='waeschepaket',
>>> name='w_bezahlt',
>>> field=models.BooleanField(choices=[(False, 'Nein'), (True, 
>>> 'Ja')], default=False),
>>> ),
>>>
>>> Here is a small screenshot from phpmyadmin
>>> [image: field.png]
>>> I guess that if that field alteration would have worked than the default 
>>> value should be False or something else but not None.
>>>
>>> Then I guess that I forgot about it and just worked with app as it was 
>>> for more than a year and now I wanted to add a new model:
>>>
>>> operations = [
>>> migrations.CreateModel(
>>> name='Wartungsarbeit',
>&

Re: Migration running in shell, but no change in DB

2023-04-05 Thread Jason
so, for your original boolean migration, 

https://code.djangoproject.com/ticket/470
https://stackoverflow.com/questions/32280343/default-value-of-djangos-model-doesnt-appear-in-sql

Adding a default value doesn't go to SQL, although there's work in the 
django ticket above.  So its inserted via app code and the original 
question might have been a red herring and the actual issue is your 
CreateModel is never applied.

ouch, you have one db per application?  that could likely be it, when was 
this routing put in place?  Did it exist before the last working migration 
on this project?  Reason I ask, 







*python3 manage.py sqlmigrate ObjPLW2 0037 --database=db_obj_plw2 
Create model Wartungsarbeit--CREATE TABLE `ObjPLW2_wartungsarbeit` (`id` 
integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `wa_titel` varchar(201) NOT 
NULL, `wa_beschreibung` longtext NOT NULL, `wa_turnus` integer UNSIGNED NOT 
NULL CHECK (`wa_turnus` >= 0), `wa_startdatum` date NOT NULL, 
`wa_erstelldatum` datetime(6) NOT NULL, `wa_bearbeitungsdatum` datetime(6) 
NOT NULL);*

is vaid SQL and that's what django would send to your db.  So if its not 
being applied, the allow_migrate might be at cause here.  What happens when 
you put some logging there, or raise an exception on None/False?  The docs 
at https://docs.djangoproject.com/en/4.1/topics/db/multi-db/#allow_migrate
 state


*makemigrations always creates migrations for model changes, but if 
allow_migrate() returns False, any migration operations for the model_name 
will be silently skipped when running migrate on the db. *


On Wednesday, April 5, 2023 at 1:52:12 AM UTC-4 Martin Heitmann wrote:

> Dear Jason
>
> Thanks for your reply. I am not absolulety sure what this question means 
> "What specifically was the changeset occurring and what isn't? ", but I try 
> to answer it the best way I can. I worked on the app quite a while ago and 
> back then everything seemed to work. As far as I can understand my own 
> steps back then I tried to alter only one field.
>
> extract from migrations file:
>  migrations.AlterField(
> model_name='waeschepaket',
> name='w_bezahlt',
> field=models.BooleanField(choices=[(False, 'Nein'), (True, 
> 'Ja')], default=False),
> ),
>
> Here is a small screenshot from phpmyadmin
> [image: field.png]
> I guess that if that field alteration would have worked than the default 
> value should be False or something else but not None.
>
> Then I guess that I forgot about it and just worked with app as it was for 
> more than a year and now I wanted to add a new model:
>
> operations = [
> migrations.CreateModel(
> name='Wartungsarbeit',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('wa_titel', models.CharField(max_length=201)),
> ('wa_beschreibung', models.TextField()),
> ('wa_turnus', models.PositiveIntegerField(default=1)),
> ('wa_startdatum', 
> models.DateField(default=django.utils.timezone.now)),
> ('wa_erstelldatum', 
> models.DateTimeField(auto_now_add=True)),
> ('wa_bearbeitungsdatum', 
> models.DateTimeField(auto_now=True)),
> ],
> ),
>
> But this does not show up in any way. During the last weeks I have tried a 
> lot of things that I read on the web and I am afraid that I may have made a 
> mess. There were many instructions about inspectdb, --fake-initial, 
> removing the app-specific entries from the table django_migrations and so 
> on. But nothing of that worked. Now I am at a point where I merged the last 
> two, obviously not working migrations into one, which is currently the 37th 
> for this app.
>
> As I already have a lot of content in the database I don't want to loose 
> that and instead I search for a way to start fresh and get rid of that 
> error. And if possible I would like to know where that error originated. 
> But currently I am at my wits end. First I thought that it must have to do 
> with the database access, but then the app would not work and other content 
> could not be entered and changed and so on. I checked my privileges via 
> phpmyadmin. Everything is fine there, too. And of course the app is in 
> INSTALLED_APPS, otherwise it would not work as well. One more thing that I 
> am not sure of is the database routing. I have a router.py and there I have 
> pretty much the same entries for all apps. Looks similar to this:
>
> def allow_migrate(self, db, app_label, model_name=None, **hints):
> if app_label == 'app_name':
> return db == 'db_app_name'
> return None
>
> I don't know if this can be relevant

Re: Migration running in shell, but no change in DB

2023-04-04 Thread Jason
What specifically was the changeset occurring and what isn't?  Is the model 
being created in the db, or is it the field change that's not replicating?  
In your comments, you showed just one migration, but seems from additional 
comments you made, there are two or more?  What are they, specifically.  
And what is the model field change you're making?

As mentioned earlier,  django model field changes do not always equate to a 
migration for that model.  So django made a migration for your model, but 
might also be an empty/no op one for your field change
On Tuesday, April 4, 2023 at 2:53:22 AM UTC-4 Martin Heitmann wrote:

> Would you recommend using inspectdb?
>
> On Monday, April 3, 2023 at 1:58:55 PM UTC+2 Martin Heitmann wrote:
>
>> Dear Jason
>>
>> What could I do to get it back in sync? I tried several recommendations 
>> from the web, but perhaps the devil is in the details. If someone could 
>> tell me which steps I should take, I would gladly roll back the migrations 
>> and sync it again. And I would like to share the output. However, I have 
>> the existing database and may not loose the existing content.
>>
>> As it seems to me I wanted to change a field more than a year ago. 
>> Perhaps that did not work. I do not remember. And now I wanted to add a new 
>> model to the app.
>>
>> Best regards
>> Martin
>>
>> On Monday, April 3, 2023 at 12:59:50 PM UTC+2 Jason wrote:
>>
>>> this is all a pretty weird experience, I have to say.  One thing that is 
>>> suggesting to me that your migration history is.out of sync is that 
>>> migration you shared earlier is not what I would expect an addField 
>>> operation, not a CreateModel. 
>>>
>>> Also, django migrations are required when model changes, but not all 
>>> model changes require emitting SQL.  What exactly is the change you're 
>>> expecting to see? What field, what was it before, and what do you want it 
>>> to go to? 
>>>
>>> On Sunday, April 2, 2023 at 3:43:27 PM UTC-4 Martin Heitmann wrote:
>>>
>>>> A little PS: I logged in via phpmyadmin and saw that my user has all 
>>>> privileges. So this should not be the source of the problem.
>>>>
>>>> On Saturday, April 1, 2023 at 8:07:57 PM UTC+2 Martin Heitmann wrote:
>>>>
>>>>> I have a little update, but not a solution. Adding the database to 
>>>>> sqlmigrate will give me the SQL command, but nothing more:
>>>>>
>>>>> python3 manage.py sqlmigrate ObjPLW2 0037 --database=db_obj_plw2
>>>>>
>>>>> --
>>>>> -- Create model Wartungsarbeit
>>>>> --
>>>>> CREATE TABLE `ObjPLW2_wartungsarbeit` (`id` integer AUTO_INCREMENT NOT 
>>>>> NULL PRIMARY KEY, `wa_titel` varchar(201) NOT NULL, `wa_beschreibung` 
>>>>> longtext NOT NULL, `wa_turnus` integer UNSIGNED NOT NULL CHECK 
>>>>> (`wa_turnus` 
>>>>> >= 0), `wa_startdatum` date NOT NULL, `wa_erstelldatum` datetime(6) NOT 
>>>>> NULL, `wa_bearbeitungsdatum` datetime(6) NOT NULL);
>>>>>
>>>>> --
>>>>> -- Alter field w_bezahlt on waeschepaket
>>>>> --
>>>>>
>>>>> And for whatever reason it includes only the table creation and not 
>>>>> the change in the other field.
>>>>> On Saturday, April 1, 2023 at 7:46:51 PM UTC+2 Martin Heitmann wrote:
>>>>>
>>>>>> Dear Jason
>>>>>>
>>>>>> I went two migration steps back, then again I did makemigrations and 
>>>>>> then I went for sqlmigrate. This was the output:
>>>>>> python3 manage.py sqlmigrate ObjPLW2 0037
>>>>>> --
>>>>>> -- Create model Wartungsarbeit
>>>>>> --
>>>>>> --
>>>>>> -- Alter field w_bezahlt on waeschepaket
>>>>>> --
>>>>>> It does not include any SQL.
>>>>>>
>>>>>> Does anyone know where this is no SQL in the output?
>>>>>>
>>>>>> On Saturday, April 1, 2023 at 3:46:41 PM UTC+2 Martin Heitmann wrote:
>>>>>>
>>>>>>> Dear Jason
>>>>>>> Thanks for your reply. I will gladly do that. This is the latest 
>>>>>>> migration file:
>>>>>>>
>>>>>>> # Generated by Django 3.2.10 on 2023-04-01 13:45
>>>>>>>

Re: Migration running in shell, but no change in DB

2023-04-01 Thread Jason
part of getting effective help is sharing how you're doing things and the 
code.  for example, sharing the migration generated would be helpful. you 
do have the context of how and what is being executed, we don't, so sharing 
that with your original questions is a big part in getting effective help
On Saturday, April 1, 2023 at 4:08:06 AM UTC-4 Martin Heitmann wrote:

> The migrations do not show up in the django_mirations table. The problem 
> must occur earlier. 
> On Saturday, April 1, 2023 at 8:42:20 AM UTC+2 David Nugent wrote:
>
>> I would check in the django_migrations table to ensure that the migration 
>> has successfully been run.
>>
>>
>>
>> From: 'Martin Heitmann' via Django users 
>> Reply: django...@googlegroups.com 
>> Date: 31 March 2023 at 19:46:02
>> To: Django users 
>> Subject:  Migration running in shell, but no change in DB 
>>
>> Hello everyone
>>>
>>> I have a project with multiple apps in it. As database I use MariaDB. 
>>> Have not touched it for a while, but now I had to add a field to the models 
>>> of one app. makemigrations and migrate run without any indication of an 
>>> error. But no change occurs in the db. Tested it with an altered models.py 
>>> in another app and the result is the same. Do you have any advice how to 
>>> narrow this down?
>>>
>>> Best regards
>>> Martin
>>>
>> --
>>> 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/be9ef414-4b51-4072-a1b7-b7ba036016aan%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/c689793e-3795-46c1-b875-8f2068981357n%40googlegroups.com.


Re: django model method

2023-02-13 Thread Jason
there's alot to not like about the implementation here.  You're effectively 
hiding queries and db hits with those methods, since the naming does not 
give any indication that its a db hit.  So its really easy to forget that, 
and then after a while, you're wondering why your project is so slow and 
executing alot of unnecessary queries

for seen, likes and hotness counts, I'd rather denormalize  and have a 
count field for all those values.  Then either use a post-save signal to 
update the values, or use a recurring background task to regenerate the 
fields on an interval.

On Friday, February 10, 2023 at 9:02:16 AM UTC-5 Gabriel Araya Garcia wrote:

> Allways there is a way to improve the code, but  if that not run, then try 
> with CYTHON
>
> Gabriel Araya Garcia
> GMI - Desarrollo de Sistemas Informáticos
>
>
>
>
> El jue, 9 feb 2023 a las 10:09, Andréas Kühne () 
> escribió:
>
>> Not if you want it to be fast. Python itself is slow - so you should try 
>> to offload most of the computation on the database. So filtering would need 
>> to be done on database fields as well.
>>
>> Otherwise you would need to load all of the rows into memory and then do 
>> the filtering there.
>>
>> If you want to continue along the route you have taken now - you probably 
>> could solve it with annotated queries - something like this:
>>
>> https://stackoverflow.com/questions/1396264/how-to-sort-by-annotated-count-in-a-related-model-in-django
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den tors 9 feb. 2023 kl 13:21 skrev Chelsea Fan :
>>
>>> understood, is there any way to filter objects by method value?
>>>
>>> On Thu, Feb 9, 2023 at 4:42 PM Andréas Kühne  
>>> wrote:
>>>
 No.

 Ordering works by using the database to order the models. It therefore 
 needs to be a database field - otherwise the database can't order by the 
 field?

 Regards,

 Andréas


 Den tors 9 feb. 2023 kl 12:09 skrev Chelsea Fan >>> >:

> hello guys, Is it possible to use model method value to ordering model 
> objects in meta class?
>
> class Post(models.Model):
> title = models.CharField(max_length=255, verbose_name="ady")
> text = RichTextField(verbose_name="text")
> tagList = models.ManyToManyField(Tag, verbose_name="taglar", 
> related_query_name="tagList")
> image = models.ImageField(upload_to="postImage/", verbose_name=
> "surat")
> seen = models.ManyToManyField(UserId,verbose_name="görülen sany", 
> blank=True, related_name="gorulen")
> like = models.ManyToManyField(UserId,verbose_name="like sany", 
> blank=True)
> share = models.PositiveIntegerField(verbose_name="paýlaşylan sany", 
> null=True, blank=True, default="0")
> createdAt = models.DateTimeField(auto_now_add=True, 
> verbose_name="goşulan 
> güni")
>
> class Meta:
> verbose_name_plural="Makalalar"
> # ordering = ("-createdAt",)
> ordering = ["-hotness",]
>
> def __str__(self):
> return self.title
>
> def likes(self):
> return self.like.count()
>
> likes.short_description = "Like sany"
> likes.allow_tags = True
>
> def seens(self):
> return self.seen.count()
>
> seens.short_description = "Görülen sany"
> seens.allow_tags = True
>
> @property
> def hotness(self):
> return self.likes() + self.seens() + self.share
>
> -- 
> 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/CAJwZndfmes4g2KWUB3Fz6wNRORQ40Fxj_NYwYKWCF6DX96OVyg%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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/CAK4qSCfpaVQ1YXMbVae26RLgsYYBcLRMcpgQOEm9z3%2B6NpN5Ww%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...@googlegroups.com.
>>> To view this 

Re: Django .values() / SQL table fields wildcards

2023-02-04 Thread Jason
Seems to me case-when and conditional expressions[0] would be a better fit 
for you.  Django selects all the fields of the models, except when values 
and values_list are used to specify the fields.  however, those methods do 
not populate model instances, because why woould they?  they only have a 
partial set of model data anyway, and the project expects that if you 
return a model instance, all of its fields are accessible as a whole as 
defined in the class definition.

[0] 
https://docs.djangoproject.com/en/4.1/ref/models/conditional-expressions/

On Thursday, February 2, 2023 at 6:26:05 PM UTC-5 thomas...@gmail.com wrote:

> Hello everyone,
>
> I realize that it is a pretty exotic feature, but is there a way to =
> generate SQL from a query set so that the fields can be a wildcard, when =
> multiple joins exist.
>
> Given this query:
>
> SELECT *
> FROM table1 t1
> JOIN table2 t2 on t1.id = t2.t1_id
> JOIN table3 t3 on t2.id = t3.t2_id
> WHERE (...)
>
>
> How can I use Django to rewrite the select as `SELECT t1.*` for example?
>
> My use-case is a set of nested models with a foreign key relationship 
> (t1 has many t2 has many t3) and I would like to query t2 but return
> either t1, t2 or t3 instances depending on the cases (and presumably t1,
> t2 and t3 are serializable as models in the ORM)
>
> Is this possible? So far, I looked at `values` and `values_list` but 
> there doesn't seem to be a documented way to do this.
>
> Any help appreciated, I know this group is helpful,
>
> -- Thomas
>

-- 
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/6d05bf24-a402-4c5f-8167-a15d9362acefn%40googlegroups.com.


Re: MySQL table is missing ON DELETE CASCADE constraint

2023-01-24 Thread Jason
you can read through the comments the ticket for the reasons :)

On Monday, January 23, 2023 at 3:44:41 AM UTC-5 Dennis Tants wrote:

> Thanks for the answers. Still not sure why it would not implement ON 
> DELETE CASCADE in the DB itself. But whatever. 
>
> Regards,
> Dennis
>
>
> On 20/01/2023 20:15, Jason wrote:
>
>
> https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.CASCADE
>  
>
> > Django emulates the behavior of the SQL constraint ON DELETE CASCADE and 
> also deletes the object containing the ForeignKey.
>
> this is specified in the docs.  
>
> https://code.djangoproject.com/ticket/21961
> On Friday, January 20, 2023 at 10:44:48 AM UTC-5 bhuvn...@gmail.com wrote:
>
>> Hi dennis, 
>> You can open a ticket on the trac (https://code.djangoproject.com/query) 
>> for whatever issue you are facing.It will be easier to understand there.
>>
>> Regards
>> Bhuvnesh 
>>
>>
>> On Fri, Jan 20, 2023, 8:36 PM Dennis Tants  wrote:
>>
>>> Hey folks, 
>>>
>>> I recently came across what I think is a bug. Let me try to explain it 
>>> as detailed as possible. 
>>> Imagine I have two models, one is called Events, the other is called 
>>> EventAccounts. EventAccounts can't exist without an Event, so I added a 
>>> ForeignKey with the on_delete=models.CASCADE constraint to one field of 
>>> EventAccounts. Should I delete an event, the corresponding event accounts 
>>> will also be deleted. This works just fine when using Django itself (or the 
>>> admin pages). See my models.py. 
>>> models.py: 
>>>
>>> class Events(models.Model): 
>>>... 
>>>
>>> class EventAccounts(models.Model): 
>>>... 
>>>   account_event = models.ForeignKey(Events, on_delete=models.CASCADE) 
>>>... 
>>>
>>>
>>> Now one of my tasks is to cleanup the database every day to delete 
>>> events, which ended more than two weeks ago. I was thinking of creating a 
>>> cronjob to run raw SQL every day. When running this command: 
>>>
>>> DELETE FROM app_eventtool_events WHERE event_end_date < (NOW() - 
>>> INTERVAL 14 DAY); 
>>>
>>> I always get informed that there is an existing child and the events do 
>>> not get deleted. Which is why I had a look at the table constraints with: 
>>>
>>> SHOW CREATE TABLE app_eventtool_eventaccounts; 
>>>
>>> It seems that the ON DELETE CASCADE statement at the end is missing: 
>>>
>>> CONSTRAINT `app_eventtool_eventa_account_event_id_0ff3718a_fk_app_event` 
>>> FOREIGN KEY (`account_event_id`) REFERENCES `app_eventtool_events` 
>>> (`event_id`) 
>>>
>>> If I now delete the above constraint and add a selfmade one, it looks 
>>> like this: 
>>>
>>> ALTER TABLE app_eventtool_eventaccounts ADD CONSTRAINT 
>>> app_eventtool_events_account_event_id FOREIGN KEY (account_event_id) 
>>> REFERENCES app_eventtool_events (event_id) ON DELETE CASCADE ON UPDATE NO 
>>> ACTION; 
>>> CONSTRAINT `app_eventtool_events_account_event_id` FOREIGN KEY 
>>> (`account_event_id`) REFERENCES `app_eventtool_events` (`event_id`) ON 
>>> DELETE CASCADE ON UPDATE NO ACTION 
>>>
>>> As you can see, ON DELETE CASCADE is now present. Now I am also able to 
>>> delete the events with raw SQL as mentioned above. This is reproducible 
>>> when dropping and creating the database fully. Updating from version 4.0.6 
>>> to version 4.1.5 did not solve the problem. 
>>>
>>> Furthermore I started testing a bit with the on_delete statement in 
>>> models.py. I changed models.CASCADE to models.RESTRICT and created a new 
>>> migration. The migration file itself looks fine. But when trying to get the 
>>> raw SQL of the migration via: 
>>>
>>> python3 manage.py sqlmigrate app_eventtool 0002 
>>>
>>> it basically results in an empty migration: 
>>>
>>> -- 
>>> -- Alter field account_event on eventaccounts 
>>> -- 
>>> -- (no-op) 
>>>
>>>
>>> Maybe this is expected behaviour, but for me it seems like a bug. Can 
>>> anyone confirm/deny this? 
>>>
>>> Thanks in advance, 
>>> Dennis 
>>>
>> -- 
>>> 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 emai

Re: MySQL table is missing ON DELETE CASCADE constraint

2023-01-20 Thread Jason
https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.CASCADE

> Django emulates the behavior of the SQL constraint ON DELETE CASCADE and 
also deletes the object containing the ForeignKey.

this is specified in the docs.  

https://code.djangoproject.com/ticket/21961
On Friday, January 20, 2023 at 10:44:48 AM UTC-5 bhuvn...@gmail.com wrote:

> Hi dennis,
> You can open a ticket on the trac (https://code.djangoproject.com/query) 
> for whatever issue you are facing.It will be easier to understand there.
>
> Regards
> Bhuvnesh 
>
>
> On Fri, Jan 20, 2023, 8:36 PM Dennis Tants  wrote:
>
>> Hey folks, 
>>
>> I recently came across what I think is a bug. Let me try to explain it as 
>> detailed as possible. 
>> Imagine I have two models, one is called Events, the other is called 
>> EventAccounts. EventAccounts can't exist without an Event, so I added a 
>> ForeignKey with the on_delete=models.CASCADE constraint to one field of 
>> EventAccounts. Should I delete an event, the corresponding event accounts 
>> will also be deleted. This works just fine when using Django itself (or the 
>> admin pages). See my models.py. 
>> models.py: 
>>
>> class Events(models.Model): 
>>... 
>>
>> class EventAccounts(models.Model): 
>>... 
>>   account_event = models.ForeignKey(Events, on_delete=models.CASCADE) 
>>... 
>>
>>
>> Now one of my tasks is to cleanup the database every day to delete 
>> events, which ended more than two weeks ago. I was thinking of creating a 
>> cronjob to run raw SQL every day. When running this command: 
>>
>> DELETE FROM app_eventtool_events WHERE event_end_date < (NOW() - INTERVAL 
>> 14 DAY); 
>>
>> I always get informed that there is an existing child and the events do 
>> not get deleted. Which is why I had a look at the table constraints with: 
>>
>> SHOW CREATE TABLE app_eventtool_eventaccounts; 
>>
>> It seems that the ON DELETE CASCADE statement at the end is missing: 
>>
>> CONSTRAINT `app_eventtool_eventa_account_event_id_0ff3718a_fk_app_event` 
>> FOREIGN KEY (`account_event_id`) REFERENCES `app_eventtool_events` 
>> (`event_id`) 
>>
>> If I now delete the above constraint and add a selfmade one, it looks 
>> like this: 
>>
>> ALTER TABLE app_eventtool_eventaccounts ADD CONSTRAINT 
>> app_eventtool_events_account_event_id FOREIGN KEY (account_event_id) 
>> REFERENCES app_eventtool_events (event_id) ON DELETE CASCADE ON UPDATE NO 
>> ACTION; 
>> CONSTRAINT `app_eventtool_events_account_event_id` FOREIGN KEY 
>> (`account_event_id`) REFERENCES `app_eventtool_events` (`event_id`) ON 
>> DELETE CASCADE ON UPDATE NO ACTION 
>>
>> As you can see, ON DELETE CASCADE is now present. Now I am also able to 
>> delete the events with raw SQL as mentioned above. This is reproducible 
>> when dropping and creating the database fully. Updating from version 4.0.6 
>> to version 4.1.5 did not solve the problem. 
>>
>> Furthermore I started testing a bit with the on_delete statement in 
>> models.py. I changed models.CASCADE to models.RESTRICT and created a new 
>> migration. The migration file itself looks fine. But when trying to get the 
>> raw SQL of the migration via: 
>>
>> python3 manage.py sqlmigrate app_eventtool 0002 
>>
>> it basically results in an empty migration: 
>>
>> -- 
>> -- Alter field account_event on eventaccounts 
>> -- 
>> -- (no-op) 
>>
>>
>> Maybe this is expected behaviour, but for me it seems like a bug. Can 
>> anyone confirm/deny this? 
>>
>> Thanks in advance, 
>> Dennis 
>>
>> -- 
>> 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/cb989abd-cb08-8093-668a-03b756149be1%40uni-bremen.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/67684c77-0d05-4514-b675-abe6e0eb2b20n%40googlegroups.com.


Re: AttributeError: 'QuerySet' object has no attribute 'mime_type'

2023-01-19 Thread Jason
is `content` a queryset? 

On Thursday, January 19, 2023 at 8:21:39 AM UTC-5 monisha.s...@ideas2it.com 
wrote:

> @staticmethod
> def post(request, *args, **kwargs):
> constant = utils.send_grid_key
> sg = SendGridAPIClient(constant)
> subject = get_subject()
> content = get_content()
> message = Mail(
> from_email=From((utils.sender_mail, 'Hello')),
> to_emails=To('man...@gmail.com'),
> # to_emails=To(get_email()),
> subject=subject,
> html_content=content)
> response = sg.send(message)
> print(response.status_code)
> print(response.body)
> print(response.headers)
> return Response(response)
>
>
> Traceback (most recent call last):
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
>  
> line 55, in inner
> response = get_response(request)
>^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
>  
> line 197, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
>  
> line 54, in wrapped_view
> return view_func(*args, **kwargs)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
>  
> line 103, in view
> return self.dispatch(request, *args, **kwargs)
>^^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 509, in dispatch
> response = self.handle_exception(exc)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 469, in handle_exception
> self.raise_uncaught_exception(exc)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 480, in raise_uncaught_exception
> raise exc
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 506, in dispatch
> response = handler(request, *args, **kwargs)
>^
>   File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line 
> 140, in post
> message = Mail(
>   ^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
>  
> line 80, in __init__
> self.add_content(html_content, MimeType.html)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
>  
> line 734, in add_content
> if content.mime_type == MimeType.text:
>^
> AttributeError: 'QuerySet' object has no attribute 'mime_type'
> [19/Jan/2023 17:54:52] ERROR - Internal Server Error: /automation/user/mail
> Traceback (most recent call last):
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
>  
> line 55, in inner
> response = get_response(request)
>^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
>  
> line 197, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
>  
> line 54, in wrapped_view
> return view_func(*args, **kwargs)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
>  
> line 103, in view
> return self.dispatch(request, *args, **kwargs)
>^^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 509, in dispatch
> response = self.handle_exception(exc)
>^^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 469, in handle_exception
> self.raise_uncaught_exception(exc)
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 480, in raise_uncaught_exception
> raise exc
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
>  
> line 506, in dispatch
> response = handler(request, *args, **kwargs)
>^
>   File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line 
> 140, in post
> message = Mail(
>   ^
>   File 
> "C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
>  
> line 80, 

Re: How to fetch 10000 above record within second in django?

2023-01-18 Thread Jason
https://dev.mysql.com/doc/refman/8.0/en/using-explain.html is a good guide 
to showing how to use EXPLAIN to see what your query is running.

https://use-the-index-luke.com/ is a great introductory source for indexes

https://django-debug-toolbar.readthedocs.io/en/latest/ added to your 
project can show where your bottlenecks are.

On Tuesday, January 17, 2023 at 10:40:27 AM UTC-5 Clive Bruton wrote:

>
> On 17 Jan 2023, at 12:06, Ayanfeoluwa Koyinsola wrote:
>
> > You might now have to display all the data at once, see if you can 
> > use paginisation to reduce the numbers of queries
>
> I think this will only help if there are related lookups.
>
>
> -- Clive
>

-- 
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/8924df06-94f1-411f-9c54-4758028f274fn%40googlegroups.com.


Re: How to access the value of a field that failed validation

2023-01-03 Thread Jason
you'll need to implement custom validators to override the default 
`ValidationError` message for the fields.  some fields include this 
functionality by default, ie DecimalField (
https://github.com/django/django/blob/main/django/forms/fields.py#L419-L428), 
others don't

On Monday, January 2, 2023 at 4:00:23 PM UTC-5 Noel Duffy wrote:

> On 3/01/23 02:21, Alex Sonar wrote:
> > Hi Noel!
> > Have you looked at the problem in context CSRF Protection?
> > Please check it out
> > 
> > - How to use Django’s CSRF protection
> > https://docs.djangoproject.com/en/4.1/howto/csrf/
> > 
> > It might be as a solution...
>
> I don't see how this helps. I want to access a field value even if the 
> call to form.is_valid fails. CSRF protection, which is on by default, 
> doesn't affect this in any way that I can see.
>
>
>
>

-- 
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/2e199d72-7696-4ce8-86f3-7e73d77024b1n%40googlegroups.com.


Re: Apache2 hates my Django deployment method

2022-12-11 Thread Jason
https://serverfault.com/questions/1058677/apache-2-4-37-reload-causes-error-scoreboard-is-full-not-at-maxrequestworkers
 

and 

https://serverfault.com/questions/1084635/apache-mpm-workers-stuck-in-g-gracefully-finishing-growing-scoreboard-is-fu

seems reloading is problematic because

>When you gracefully reload Apache, you're terminating the containing 
process. What is happening here is Apache is making each thread wait until 
all the threads in the containing process have completed prior to 
restarting the container PID.

> So, in you're case, you've got a single thread contained in all the 
processes in that list that is still busy or stuck somehow.



On Sunday, December 11, 2022 at 5:45:40 PM UTC-5 Mike Dewhirst wrote:

> On 12/12/2022 1:33 am, Jason wrote:
>
> AFAIK, restarting apache process on deployment is standard, is there a 
> reason you don't want to do that?
>
>
> With Ubuntu 2020.04 and the version of Apache which came with that, reload 
> worked fine and I always thought that was the right way to redeploy. 
>
> The newer version of Apache or probably more particularly the newer 
> mpm-event module had a bug whereby ...
>
> [Sun Dec 11 02:09:18.196035 2022] [mpm_event:error] [pid 893:tid 
> 139808992921472] AH03490: scoreboard is full, not at 
> MaxRequestWorkers.Increase ServerLimit.
>
> ... and that consumed resources until Apache crashed. Hence my questions 
> on the Apache list which resulted in adjusted mpm-event config recommended 
> by gurus.
>
> Currently, reloading triggers the above error about once per second.
>
> Then issuing a restart generates ...
>
> [Sun Dec 11 02:15:28.478942 2022] [mpm_event:notice] [pid 893:tid 
> 139808992921472] AH00492: caught SIGWINCH, shutting down gracefully
> [Sun Dec 11 02:15:31.840212 2022] [core:warn] [pid 893:tid 
> 139808992921472] AH00045: child process 909 still did not exit, sending a 
> SIGTERM
>
> ... and that [core:warn] message repeats for the same pid but a bunch of 
> different child processes for however many there are until it changes to a 
> [core:error] for the same bunch ...
>
> [Sun Dec 11 02:15:37.883824 2022] [core:error] [pid 893:tid 
> 139808992921472] AH00046: child process 7868 still did not exit, sending a 
> SIGKILL
> [Sun Dec 11 02:15:50.816477 2022] [mpm_event:notice] [pid 45163:tid 
> 140392171792256] AH00489: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 
> mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations
>
> ... until Apache restarts.
>
> So I reckon there is something wrong.
>
> I now restart Apache on redeployment but it still goes through the 
> [core:warn] and [core:error] before restarting if I have done a reload.
>
> I guess I'll give up reloading.
>
> Thanks for responding
>
> Cheers
>
> Mike
>
>
>
> Templates are picked up because they're not evaluated and compiled, rather 
> they're processed dynamically so any changes there do not require a restart.
>
> On Saturday, December 10, 2022 at 9:34:42 PM UTC-5 Mike Dewhirst wrote:
>
>> Server Version: Apache/2.4.52 (Ubuntu 2022.04) OpenSSL/3.0.2 
>> mod_wsgi/4.9.0 Python/3.10 Server MPM: event Server Built: 
>> 2022-09-30T04:09:50 Apache *seems* to hang onto something and eventually 
>> crashes after I reload it after deploying a Python file.
>>
>> That is either scripted (delete site and re-export from repo) or drag and 
>> drop a py file using Filezilla on Windows.
>>
>> It *seems* ok if I redeploy html templates.
>>
>> I have asked on the Apache mailing list and the consensus seems to be 
>> that something is "hogging" the mpm-event workers and I have to figure out 
>> what and solve that.
>>
>> The only solution I have is to restart Apache.
>>
>> I have to think this is happening in other projects so I'm wondering if 
>> anyone has solved this?
>>
>> Thanks for any feedback
>>
>> Mike
>>
>> -- 
>> Signed email is an absolute defence against phishing. This email has
>> been signed with my private key. If you import my public key you can
>> automatically decrypt my signature and be sure it came from me. Just
>> ask and I'll send it to you. Your email software can handle signing.
>>
>> -- 
> 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/8853bc85-97fb-48d7-af94-0807f777c0fan%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/8853bc85-97fb

Re: Apache2 hates my Django deployment method

2022-12-11 Thread Jason
AFAIK, restarting apache process on deployment is standard, is there a 
reason you don't want to do that?

Templates are picked up because they're not evaluated and compiled, rather 
they're processed dynamically so any changes there do not require a restart.

On Saturday, December 10, 2022 at 9:34:42 PM UTC-5 Mike Dewhirst wrote:

> Server Version: Apache/2.4.52 (Ubuntu 2022.04) OpenSSL/3.0.2 
> mod_wsgi/4.9.0 Python/3.10 Server MPM: event Server Built: 
> 2022-09-30T04:09:50 Apache *seems* to hang onto something and eventually 
> crashes after I reload it after deploying a Python file.
>
> That is either scripted (delete site and re-export from repo) or drag and 
> drop a py file using Filezilla on Windows.
>
> It *seems* ok if I redeploy html templates.
>
> I have asked on the Apache mailing list and the consensus seems to be that 
> something is "hogging" the mpm-event workers and I have to figure out what 
> and solve that.
>
> The only solution I have is to restart Apache.
>
> I have to think this is happening in other projects so I'm wondering if 
> anyone has solved this?
>
> Thanks for any feedback
>
> Mike
>
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
>

-- 
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/8853bc85-97fb-48d7-af94-0807f777c0fan%40googlegroups.com.


Re: Need to Replace django default I'd with UUID field

2022-11-22 Thread Jason
why?

use uuid for public resource access, and internal int/bigint for primary 
keys.  that works well with the index structure and doesn't leak sequential 
information out by URLs.

in other words, a resource is accessed via 
`somesite.com/some-resource/

internally, you do a lookup like 

SomeModel.objects.filter(uuid =  When you use SQL System like Postgres and you have Version 13+ then you 
> can use gen_random_uuid() to create a uuid. I would make it following: 
> Delete all constraint that checks that id is int and also checks if 
> foreignkey exists in related table.
>
> I would create a Postgres Function with a cursor on your table. Then 
> iterate over table get id. Create new uuid. If relation exists to another 
> tables exists then you must first update relations table with new uuid and 
> then update in original db.
>
> This is my idea but i dont have such a function. This you must write self. 
> But this isn't too much complex.
>
> Good luck
>
> Am Di., 22. Nov. 2022 um 19:55 Uhr schrieb Rajesh Kumar <
> rjcse...@gmail.com>:
>
>> Hi everyone!
>> Hope everyone is doing well...
>>
>> Actually I have 100+ existing data in my database with default I'd field 
>> of django 
>> Now I need to replace that default I'd to UUID.
>>
>> How I can do  this without loosing any records of my database.
>>
>> If anyone can give me suggestions that would be great.
>>
>> Thanks
>> Rajesh Kumar 
>>
>> -- 
>>
> 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/CAKNDe%3D%3DEa0ZagzpZ-Y_bXKrCi3ZHdG_PNr5%3DgxeJCTbKdM_tdA%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/88569393-9a9b-4590-b008-313a663c385fn%40googlegroups.com.


Re: Need to Replace django default I'd with UUID field

2022-11-22 Thread Jason Turner
I would just add another column that holds the UUID value instead of
changing the default ID.

On Tue, Nov 22, 2022, 12:55 PM Rajesh Kumar  wrote:

> Hi everyone!
> Hope everyone is doing well...
>
> Actually I have 100+ existing data in my database with default I'd field
> of django
> Now I need to replace that default I'd to UUID.
>
> How I can do  this without loosing any records of my database.
>
> If anyone can give me suggestions that would be great.
>
> Thanks
> Rajesh Kumar
>
> --
> 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/CAKNDe%3D%3DEa0ZagzpZ-Y_bXKrCi3ZHdG_PNr5%3DgxeJCTbKdM_tdA%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/CADoyC17Ar%2B5aHx2GHCdqTuHJagbJx6%3DFzj9zHP19-4-E1j6Pew%40mail.gmail.com.


Re: serving 206 Byte-Range during development

2022-09-05 Thread Jason
use gunicorn or uwsgi with autoreload

https://docs.gunicorn.org/en/latest/settings.html?highlight=reload#reload
https://uwsgi-docs.readthedocs.io/en/latest/Snippets.html?highlight=autoreload#python-auto-reloading-development-only


On Monday, September 5, 2022 at 5:22:01 AM UTC-4 vjwork wrote:

> I'm embedding jbrowse2 
> in
>  
> a django site, but during development I get the following error
>
> Error: HTTP 200 (OK) when fetching /static/jbrowse/assembly/genome.fasta 
> bytes 0-15871 (should be 206 for range requests)
>
> Turns out the default django dev server cannot handle streaming requests. 
> What would be a good solution to serve the steams during development? 
>

-- 
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/880bd712-ce91-405c-8768-df78f7f53cc3n%40googlegroups.com.


Re: Understanding schema editor()

2022-08-19 Thread Jason
Documentation for add field 


implementation of add_field 


postgres schema editor 


schema editor is only exeucted in migrate, not making migrations.

On Thursday, August 18, 2022 at 8:39:02 PM UTC-4 subtitle indo wrote:

> Hi 
>
> On Wed, Aug 17, 2022 at 3:51 PM Alucor Rpa  wrote:
>
>> Hi,
>> We are trying to understand the schema editor and how new fields are 
>> added to the tables when running makemigrations and migrate commands. Can 
>> you please help me with some materials or links to understand this?
>>
>> Thanks
>> Sherlin.
>>
>> -- 
>> 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/a383abc7-959e-4c76-b34e-04f37a98b964n%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/b0ebe8b2-83f7-4b79-b407-c2c131231929n%40googlegroups.com.


Re: DRF question

2022-07-23 Thread Jason
sure, it can be used to extend, but you're also equating template-based 
responses with restful.  those are pretty differnet paradigims, so you do 
need to account for the different use cases.  there's a reason why DRF is a 
separate package built on top of django, and not in core.  because its a 
pretty significant retrofit.

You can absolutely do regular django and DRF in a same project, it just 
seems that your expecting "extensibility" to be a seamless one to one 
transfer, and that isn't the case.

Also, i think you aren't considering ways to architect this structure.  ie, 
have `api/v1/user` deal with HTTP verbs, while having `/user` deal with 
legacy django.  One deals with a DRF endpoint, whther apiview, generic, or 
viewset. your choice.  the second deals with a model form.  you can then 
determine what is the shared functionality between the two that is outside 
the frameworks, and then have your separate handlers call that thing as 
part of their flow.

On Saturday, July 23, 2022 at 1:04:52 PM UTC-4 ram.mu...@gmail.com wrote:

> Hi Jason,
>
> Thank you for your email. I expected DRF could be an extensible feature 
> rather than forcing to change existing implementation. Extensibility 
> practice happens in many open source and enterprise projects. That is why 
> I'm shocked to learn this. 
>
> Best regards,
> ~Ram
>
>
>
> On Sat, Jul 23, 2022 at 4:56 AM Jason  wrote:
>
>> Ram, what did you expect, to be honest?  Going from forms to rest are two 
>> different implementation details for the same concept.  When you do such 
>> things, you need to evaluate whether the tradeoffs are worth it.
>>
>>
>> On Saturday, July 23, 2022 at 1:30:43 AM UTC-4 ram.mu...@gmail.com wrote:
>>
>>> Hi Thomas & Julio,
>>>
>>> Thank you for your answers, but we are shocked to learn that our user 
>>> registration functionality has to be rewritten again to create REST APIs. 
>>> That means whatever Apps that we developed on User registration have to be 
>>> modified too and this further means that we will have to redevelop our 
>>> whole Apps (6 of them). I still can not believe this? 
>>>
>>> I hope someone has a clue about this problem and I'm wondering 
>>> whether anyone ran into this situation as us.
>>>
>>> Best regards,
>>> ~Ram
>>>
>>>
>>> On Wed, Jul 20, 2022 at 10:44 PM Julio Cojom  
>>> wrote:
>>>
>>>> Hi Ram,
>>>>
>>>> Aditional to all the suggestions, please keep in mind django-filters as 
>>>> they are important to filter data in your api requests 
>>>>
>>>> Regards,
>>>>
>>>> Julio Cojom
>>>>
>>>> El mié, 20 jul 2022 a las 20:37, Michael Thomas (<
>>>> michael.t...@gmail.com>) escribió:
>>>>
>>>>> There's no reason at all that DRF can't be used to do this. Just don't 
>>>>> use a viewset, as it's not the right fit for this type of thing.
>>>>> Read through the code for how your current system works, then 
>>>>> re-implement the relevant parts as DRF ApiView's.
>>>>>
>>>>> On Thu, Jul 21, 2022 at 8:43 AM Ram  wrote:
>>>>>
>>>>>> Thank you all for quick suggestions. 
>>>>>>
>>>>>> We are stuck with implementing the first API, which is login 
>>>>>> endpoint. That means since we already developed user registration 
>>>>>> functionality before without DRF, there seems no way to create a login 
>>>>>> endpoint so that an existing registered user can login using REST API 
>>>>>> and 
>>>>>> access his/her respective data . All we are finding on the web is to 
>>>>>> create 
>>>>>> an Abstract user using DRF which requires to change the existing user 
>>>>>> registration implementation. So I'm wondering whether there is any way 
>>>>>> to 
>>>>>> remedify this or are we missing something?
>>>>>>
>>>>>> Best regards,
>>>>>> ~Ram
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Jul 19, 2022 at 6:30 PM Hella thor  
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Ram
>>>>>>> 您可以在原来项目的基础上创建新的APP来单独给移动应用程序来使用,并在整体项目完成以后研究是不是需要DRF来兼容。
>>>>>>>
>>>>>>> Lalit Suthar  于2022年7月19日周二 19:04写道:
>>>>>>>
>>>>>>>> I would also suggest ke

Re: DRF question

2022-07-23 Thread Jason
Ram, what did you expect, to be honest?  Going from forms to rest are two 
different implementation details for the same concept.  When you do such 
things, you need to evaluate whether the tradeoffs are worth it.


On Saturday, July 23, 2022 at 1:30:43 AM UTC-4 ram.mu...@gmail.com wrote:

> Hi Thomas & Julio,
>
> Thank you for your answers, but we are shocked to learn that our user 
> registration functionality has to be rewritten again to create REST APIs. 
> That means whatever Apps that we developed on User registration have to be 
> modified too and this further means that we will have to redevelop our 
> whole Apps (6 of them). I still can not believe this? 
>
> I hope someone has a clue about this problem and I'm wondering 
> whether anyone ran into this situation as us.
>
> Best regards,
> ~Ram
>
>
> On Wed, Jul 20, 2022 at 10:44 PM Julio Cojom  wrote:
>
>> Hi Ram,
>>
>> Aditional to all the suggestions, please keep in mind django-filters as 
>> they are important to filter data in your api requests 
>>
>> Regards,
>>
>> Julio Cojom
>>
>> El mié, 20 jul 2022 a las 20:37, Michael Thomas () 
>> escribió:
>>
>>> There's no reason at all that DRF can't be used to do this. Just don't 
>>> use a viewset, as it's not the right fit for this type of thing.
>>> Read through the code for how your current system works, then 
>>> re-implement the relevant parts as DRF ApiView's.
>>>
>>> On Thu, Jul 21, 2022 at 8:43 AM Ram  wrote:
>>>
 Thank you all for quick suggestions. 

 We are stuck with implementing the first API, which is login endpoint. 
 That means since we already developed user registration functionality 
 before without DRF, there seems no way to create a login endpoint so that 
 an existing registered user can login using REST API and access his/her 
 respective data . All we are finding on the web is to create an Abstract 
 user using DRF which requires to change the existing user registration 
 implementation. So I'm wondering whether there is any way to remedify this 
 or are we missing something?

 Best regards,
 ~Ram



 On Tue, Jul 19, 2022 at 6:30 PM Hella thor  
 wrote:

> Hi Ram
> 您可以在原来项目的基础上创建新的APP来单独给移动应用程序来使用,并在整体项目完成以后研究是不是需要DRF来兼容。
>
> Lalit Suthar  于2022年7月19日周二 19:04写道:
>
>> I would also suggest keeping Django views as it is and writing new 
>> views for your APIs 
>> maybe you can create another file named apiviews.py and then write 
>> new APIs with help of your present views
>> refer: https://www.django-rest-framework.org/api-guide/views/
>>
>> On Tue, 19 Jul 2022 at 06:38, Nikhil Chawla  
>> wrote:
>>
>>> Don't clutter the django views with DRF requests. Keep them 
>>> separate, available at, say `api` endpoints.
>>>
>>> On Tue, 19 Jul 2022, 06:17 Michael Thomas,  
>>> wrote:
>>>
 Hey Ram,

 I'm afraid no one can answer your questions without knowing your 
 code, how it works, or anything else...

 Broadly speaking, here's how we approached a similar scenario:

 1) Created one or more Serializer for each model that required 
 interaction via API. Some models required more than one, as they were 
 either too large for list() operations, or required a simpler 
 representation when nested into another Serializer, etc..
 2) Created custom permissions to check if users were allowed to 
 perform the action(s) they were trying to make
 3) Created ViewSets using the permissions and serializers mentioned 
 above, as well as any additional actions that didn't fit within the 
 normal 
 REST verbs
 4) Created a router and registered the viewsets with it
 5) Added the router's urls into the projects url configuration

 I hope that's useful :)

 Kind Regards,
 Michael Thomas  

 On Tue, Jul 19, 2022 at 7:21 AM Ram  wrote:

> Hi,
>
> We completed coding all the features without DRF for our web site 
> and now we are planning to develop a mobile app for the same website 
> by 
> keeping the web site as it is and develop a mobile app using Flutter. 
>
> Based on our understanding, we have do the following in the 
> current code for adding REST APIs
>
>
>1. We have to create serializers.py for each model in each App 
>that we have
>2. We need to add a few lines of code in views.py
>3. We think we don't have to modify the UI template by using 
>json response from DRF ( Is this really necessary because we are 
> not 
>changing anything in the website UI)
>
> Please correct me if I'm wrong about the above 3 points or do we 
> need to do any 

Re: Does Django care about max_query_params? [feature request]

2022-07-05 Thread Jason
https://github.com/googleapis/python-spanner-django/pull/774

seems like an open PR is addressing this.



On Tuesday, July 5, 2022 at 6:13:32 AM UTC-4 gurov...@gmail.com wrote:

> It's Cloud Spanner. We're using `django_spanner` as a 3rd party connector: 
> https://github.com/googleapis/python-spanner-django
>
> On Tuesday, June 28, 2022 at 11:36:08 AM UTC+4 Jason wrote:
>
>>
>> What db are you using? This might also be an issue for your db connector 
>> lib 
>> On Monday, June 27, 2022 at 10:49:40 AM UTC-4 gurov...@gmail.com wrote:
>>
>>> Hi, all!
>>>
>>> Gotta problem with the number of query params. We're using a backend, 
>>> which connects to a cloud database, and at some point we suddenly started 
>>> getting such an error:
>>>
>>> *Number of parameters in query exceeds the maximum allowed limit of 950*
>>>
>>> Appearing on this step:
>>>
>>>
>>> *django/django/contrib/auth/management/__init__.py", line 83, in 
>>> create_permissionsPermission.objects.using(using).bulk_create(perms)*
>>>
>>> 950 query params is the max number for our backend, and we set the 
>>> *DatabaseFeatures.max_query_params 
>>> *to 900. Still, it looks like Django doesn't care.
>>>
>>> Because of this all of our tests stopped working, bringing a lot of 
>>> inconveniences during development. Seems to me that it should be fixed on 
>>> Django side, centralized, 'cause it's unlikely we're the only who met and 
>>> will meet the problem in future.
>>>
>>>

-- 
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/7774a7ba-cef3-4b1a-95f3-a5759ad7ca50n%40googlegroups.com.


Re: upgrading from 1.11 and ran into builtin permission clash

2022-07-01 Thread Jason
Joel Goldstick, would definitely not recommend doing an all in one update.  
That'd be like going from windows XP to 10 in one go.  For personal 
projects, you could do it, but would side-eye any professional who 
suggested doing this with a company or workplace project.

https://docs.djangoproject.com/en/4.0/releases/2.1/#model-view-permission is 
liekly the permission being hit.  OP, would it be possible for you to 
rename the original permission name in a migration in 1.11, and then move 
forward with the migration?


On Friday, July 1, 2022 at 9:35:31 AM UTC-4 mma...@gmail.com wrote:

> > What do I do about this? Clearly I should remove the permission I 
> created. How do I deal with the migration? Should I remove the permission 
> while I run the app as Django 1.11 before moving on to a 2.2 environment? 
>
> You could rename the current view_inventorychangelog record with a data 
> migration to avoid the constraint, upgrade to 2.2, and then move any 
> references to the old DB record to the new using a data migration.
>
> > Sorry, I can't answer your question. But, I am wondering why you are 
> > upgrading to a very out of date version of Django that is no longer 
> > supported. I think 3.2 is the oldest supported version. Why not 
> > upgrade to 4? 
>
> The options for uplifting severely out of date projects are to either 
> step-by-step migrate through older versions, or rewrite in the target 
> version.
>
> Cheers,
> Michael Manfre
>
>

-- 
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/29923fb3-d7d8-4206-91d8-765ed452e585n%40googlegroups.com.


Re: How to ignoring columns on model save

2022-06-28 Thread Jason
https://code.djangoproject.com/ticket/21454

there's an open ticket about this, some things might help you there.  But 
right now, there's no easy way to get around this

On Monday, June 27, 2022 at 5:36:50 AM UTC-4 ro...@tonic-solutions.com 
wrote:

> I have a model that is backed by a database table that contains a 
> read-only column that is maintained by the database using Postgresql's 
> Generated Columns (i.e. using GENERATED ALWAYS AS) - see 
> https://www.postgresql.org/docs/current/ddl-generated-columns.html.
>
> When Django saves the model, it tries to set the field, which throws 
> `django.db.utils.ProgrammingError: cannot insert into column "_search". 
> DETAIL: Column "_search" is a generated column.
>
> Is there any way to tell Django not to attempt to insert that field?
>
> From what I can tell `editable=False` doesn't prevent Django from trying 
> to save it - which makes sense for fields that aren't editable by users but 
> are calculated by the model class, e.g. in `save()`.
>
> I know I could set `something like `instance.save(update_fields=[field for 
> field in instance._meta.fields if field.name != "_search")` but it would 
> need to be set on every save for that model throughout the application, 
> which seems like a lot of technical debt and likely to trip up other 
> developers as they maintain the application.
>
> Is there anything that I can set on the field instance in the model to 
> tell Django that it is maintained by the database?
>
> If not, please can anyone suggest a way to add code to the model to make 
> it ignore the field when saving?
>
> Thanks
>
> Roger
>

-- 
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/0a24aa15-a3cd-4e72-90a0-76e0c62a4820n%40googlegroups.com.


Re: Does Django care about max_query_params? [feature request]

2022-06-28 Thread Jason

What db are you using? This might also be an issue for your db connector 
lib 
On Monday, June 27, 2022 at 10:49:40 AM UTC-4 gurov...@gmail.com wrote:

> Hi, all!
>
> Gotta problem with the number of query params. We're using a backend, 
> which connects to a cloud database, and at some point we suddenly started 
> getting such an error:
>
> *Number of parameters in query exceeds the maximum allowed limit of 950*
>
> Appearing on this step:
>
>
> *django/django/contrib/auth/management/__init__.py", line 83, in 
> create_permissionsPermission.objects.using(using).bulk_create(perms)*
>
> 950 query params is the max number for our backend, and we set the 
> *DatabaseFeatures.max_query_params 
> *to 900. Still, it looks like Django doesn't care.
>
> Because of this all of our tests stopped working, bringing a lot of 
> inconveniences during development. Seems to me that it should be fixed on 
> Django side, centralized, 'cause it's unlikely we're the only who met and 
> will meet the problem in future.
>
>

-- 
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/9c877978-70df-4452-b05d-63b98f551de3n%40googlegroups.com.


Re: Suggestion for prefetch_related() documentation

2022-06-24 Thread Jason

This is explicitly called out in the documentation 
at 
https://docs.djangoproject.com/en/4.0/topics/db/optimization/#understand-queryset-evaluation
On Thursday, June 23, 2022 at 1:17:50 PM UTC-4 laurent...@gmail.com wrote:

> Hello,
>
> I made a simple test to check the number of queries done :
>
> # First part
> order = Order.objects.get(id=2)  # one query
> items = list(order.items.all())  # one query
> items = list(order.items.all())  # one query
> items = list(order.items.all())  # one query
>
> # Second part
> order = Order.objects.prefetch_related("items").get(id=2)  # two 
> queries
> items = list(order.items.all())  # no query
> items = list(order.items.all())  # no query
> items = list(order.items.all())  # no query
>
> # Third part
> order = Order.objects.get(id=2)  # one query
> prefetch_related_objects([order], "items")  # one query
> items = list(order.items.all())  # no query
> items = list(order.items.all())  # no query
> items = list(order.items.all())  # no query
> prefetch_related_objects([order], "items")  # no more query
> prefetch_related_objects([order], "items")  # no more query
>
> I was surprised that there was 4 queries for the First part of the test 
> instead of 2 for the other parts, because I was expecting that .all() would 
> also fill the cache and not only use it.
> Maybe it is intended.
> I think that this test or something else explaining this point could 
> enhance the documentation on prefetch_related() and 
> prefetch_related_objects().
> I advised my colleagues to use prefetch_related_objects() when in doubt 
> whether the objects given have been already extended with prefetching.
>
> Best regards,
>  Laurent Lyaudet
>
>
>
>
>

-- 
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/01353b97-2b21-4d52-aab7-3046f93a5e1dn%40googlegroups.com.


Re: How replace "./manage.py < some_code.py" with "./some_code.py" for website scripts?

2022-06-06 Thread Jason
Why?  what's the purpose behind this?

On Monday, June 6, 2022 at 12:27:58 PM UTC-4 cseb...@gmail.com wrote:

> How replace "./manage.py < some_code.py" with "./some_code.py" for website 
> scripts?
>
> There seem to be a number of imports needed to make the 2nd version work.
>
> cs
>

-- 
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/72eaa595-0d6c-44d3-a612-4776b0624c6dn%40googlegroups.com.


Re: Best approach for audit logging in Django.

2022-06-03 Thread Jason
one good source when you have a question "is there anything in django that 
does X?" is to go to djangopackages.org.

https://djangopackages.org/grids/g/model-audit/, for example, is a list of 
packages for model auditing and history

On Friday, June 3, 2022 at 6:33:37 AM UTC-4 sencer...@gmail.com wrote:

> Hi,
>
> I've been planning to add audit logging to the project.
>
> But, I can not decide which approach is the best;
> Using signals or creating middleware?
>
> Project needs to being log events on change of model object with these 
> informations below:
>
> - If a record is inserted, updated and deleted:
>- who is taking this action (ForeignKey)
>- what is the action (Choice)
>- which applications model object affected (ContentType)
>- affected object (Generic relation)
>- current data in json format
>- previous data in json format
>
>
> Kind regards,
> Sencer HAMARAT
>
>

-- 
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/f5586723-4e6a-4ce6-93d9-b74cd277dc91n%40googlegroups.com.


Re: How can I work around the Django 3.2.10 cve release

2022-05-21 Thread Jason
https://docs.djangoproject.com/en/4.0/ref/urls/#django.urls.path

This was one of the additions in 2.0, and from what it seems like, you're 
not doing anything specific with regex that cannot be done with a path 
alternative.

ie, 

 re_path(r"invoice/(?P\d+)/$", billing_views.invoice_view, 
name="invoice_view"),

would be `path("invoice/", billing_views.invoice_view, 
name="invoice_view")

wonder if this works for you.

also, this might be worth opening a bug ticket about, since this seems like 
a regression.


On Saturday, May 21, 2022 at 7:56:55 AM UTC-4 dashlaksh...@gmail.com wrote:

> There are not a big bunch of differences. You can also upgrade the version 
> in production. 
>
> On Sat, 21 May, 2022, 15:10 Mike Dewhirst,  wrote:
>
>> I'm still on 3.2.x because it is a long term supported version and my 
>> project is in production. 
>>
>> Django 4.0 is really new with asgi replacing wsgi.
>>
>> I want more unit test coverage before upgrading.
>>
>> Cheers
>>
>> Mike
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Lakshyaraj Dash XI-D 25  
>> Date: 21/5/22 18:02 (GMT+10:00) 
>> To: django...@googlegroups.com 
>> Subject: Re: How can I work around the Django 3.2.10 cve release 
>>
>> Hey why don't you use django v4 for your projects? 
>>
>> On Fri, 20 May, 2022, 08:43 Mike Dewhirst,  wrote:
>>
>>> My billing (Stripe) mechanism is working right up until Django 3.2.9 - 
>>> which is where I'm stumped at the moment.
>>>
>>> Django 3.2.10 https://docs.djangoproject.com/en/3.2/releases/3.2.10/ 
>>> indicate a URL with a trailing newline can bypass
>>> upstream access control based on URL paths.
>>>
>>> Sadly, I am not aware of any such upstream access control.
>>>
>>> I have tried to repair it with fixid() within change_view() where 
>>> object_id occurs but that doesn't achieve anything.
>>>
>>> def fixid(txt):
>>>  try:
>>>  return str(txt).split("/")[0]
>>>  except ValueError:
>>>  pass
>>>  return txt
>>>
>>> How can I fix the following error and move forward to 3.2.13?
>>>
>>> Many thanks
>>>
>>> Mike
>>> - - - - - - - -
>>>
>>> Exception Type: ValueError at 
>>> /admin/chemical/chemical/29/change/payment/change/
>>> Exception Value: Field 'id' expected a number but got 
>>> '29/change/payment'.
>>>
>>> Environment:
>>>
>>> Request Method: GET
>>> Request URL: 
>>> http://localhost:8088/admin/chemical/chemical/29/change/payment/change/
>>>
>>> Django Version: 3.2.13
>>> Python Version: 3.8.3
>>> Installed Applications:
>>> ['filebrowser',
>>>   'django.contrib.auth',
>>>   'django.contrib.contenttypes',
>>>   'django.contrib.sessions',
>>>   'django.contrib.messages',
>>>   'django.contrib.admin',
>>>   'django.contrib.admindocs',
>>>   'django.contrib.staticfiles',
>>>   'django.contrib.sites',
>>>   'django.contrib.sitemaps',
>>>   'tinymce',
>>>   'billing',
>>>   'chemical',
>>>   'common',
>>>   'company',
>>>   'credit',
>>>   'refer',
>>>   'report']
>>> Installed Middleware:
>>> ['django.middleware.security.SecurityMiddleware',
>>>   'django.middleware.cache.UpdateCacheMiddleware',
>>>   'django.contrib.sessions.middleware.SessionMiddleware',
>>>   'django.middleware.locale.LocaleMiddleware',
>>>   'django.middleware.common.CommonMiddleware',
>>>   'django.middleware.csrf.CsrfViewMiddleware',
>>>   'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>   'django.contrib.messages.middleware.MessageMiddleware',
>>>   'django.contrib.admindocs.middleware.XViewMiddleware',
>>>   'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>>   'pwned_passwords_django.middleware.PwnedPasswordsMiddleware',
>>>   'django.middleware.cache.FetchFromCacheMiddleware']
>>>
>>>
>>>
>>> Traceback (most recent call last):
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py",
>>>  
>>>
>>> line 1823, in get_prep_value
>>>  return int(value)
>>>
>>> The above exception (invalid literal for int() with base 10: 
>>> '29/change/payment') was the direct cause of the following exception:
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
>>>  
>>>
>>> line 47, in inner
>>>  response = get_response(request)
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
>>>
>>> line 181, in _get_response
>>>  response = wrapped_callback(request, *callback_args, 
>>> **callback_kwargs)
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
>>>  
>>>
>>> line 616, in wrapper
>>>  return self.admin_site.admin_view(view)(*args, **kwargs)
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
>>> line 130, in _wrapped_view
>>>  response = view_func(request, *args, **kwargs)
>>>File 
>>> "D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py",
>>>  
>>>
>>> line 44, in _wrapped_view_func
>>>  response = 

Re: How can I work around the Django 3.2.10 cve release

2022-05-20 Thread Jason
are you using re_path for the url in question?

you can see the backport change here : 
https://github.com/django/django/commit/d4dcd5b9dd9e462fec8220e33e3e6c822b7e88a6

On Thursday, May 19, 2022 at 11:14:25 PM UTC-4 Mike Dewhirst wrote:

> My billing (Stripe) mechanism is working right up until Django 3.2.9 - 
> which is where I'm stumped at the moment.
>
> Django 3.2.10 https://docs.djangoproject.com/en/3.2/releases/3.2.10/ 
> indicate a URL with a trailing newline can bypass
> upstream access control based on URL paths.
>
> Sadly, I am not aware of any such upstream access control.
>
> I have tried to repair it with fixid() within change_view() where 
> object_id occurs but that doesn't achieve anything.
>
> def fixid(txt):
> try:
> return str(txt).split("/")[0]
> except ValueError:
> pass
> return txt
>
> How can I fix the following error and move forward to 3.2.13?
>
> Many thanks
>
> Mike
> - - - - - - - -
>
> Exception Type: ValueError at 
> /admin/chemical/chemical/29/change/payment/change/
> Exception Value: Field 'id' expected a number but got '29/change/payment'.
>
> Environment:
>
> Request Method: GET
> Request URL: 
> http://localhost:8088/admin/chemical/chemical/29/change/payment/change/
>
> Django Version: 3.2.13
> Python Version: 3.8.3
> Installed Applications:
> ['filebrowser',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.admin',
>  'django.contrib.admindocs',
>  'django.contrib.staticfiles',
>  'django.contrib.sites',
>  'django.contrib.sitemaps',
>  'tinymce',
>  'billing',
>  'chemical',
>  'common',
>  'company',
>  'credit',
>  'refer',
>  'report']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
>  'django.middleware.cache.UpdateCacheMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.locale.LocaleMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.contrib.admindocs.middleware.XViewMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>  'pwned_passwords_django.middleware.PwnedPasswordsMiddleware',
>  'django.middleware.cache.FetchFromCacheMiddleware']
>
>
>
> Traceback (most recent call last):
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py",
>  
>
> line 1823, in get_prep_value
> return int(value)
>
> The above exception (invalid literal for int() with base 10: 
> '29/change/payment') was the direct cause of the following exception:
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
>  
>
> line 47, in inner
> response = get_response(request)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
> line 181, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 616, in wrapper
> return self.admin_site.admin_view(view)(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 130, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
>
> line 44, in _wrapped_view_func
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
> line 232, in inner
> return view(request, *args, **kwargs)
>   File "D:\Users\mike\envs\xxai\aicis\chemical\admin.py", line 268, in 
> change_view
> chemical = Chemical.objects.get(id=object_id)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\manager.py", 
> line 85, in manager_method
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 424, in get
> clone = self._chain() if self.query.combinator else 
> self.filter(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 941, in filter
> return self._filter_or_exclude(False, args, kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 961, in _filter_or_exclude
> clone._filter_or_exclude_inplace(negate, args, kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 968, in _filter_or_exclude_inplace
> self._query.add_q(Q(*args, **kwargs))
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\sql\query.py", 
> line 1416, in add_q
> clause, _ = self._add_q(q_object, self.used_aliases)
>   File 
> 

Re: How to construct nested QuerySet with django ORM?

2022-05-15 Thread Jason
this is a big part of what DRF brings to the table that "traditional" 
django doesn't have.

https://www.django-rest-framework.org/api-guide/relations/



On Sunday, May 15, 2022 at 4:05:02 PM UTC-4 954i...@gmail.com wrote:

> It's too inconvenient to paste the code in the email, I'll just copy a 
> StackOverFlow link.
>
>
> https://stackoverflow.com/questions/72251670/how-to-construct-nested-queryset-with-django-orm
>
> Ignoring the `DRF` part, I want to construct an `object` like this, how to 
> do it?
>

-- 
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/c4b10fc3-9973-47dc-97fe-db2c92596a95n%40googlegroups.com.


Re: Django 3.0 -> 3.1 performance degradation

2022-05-07 Thread Jason
also would be helpful if you could give some examples.  All that is stated 
is "there's a significant slowdown", but nothing where or if there's been 
any tracing in place.  

Is this happening with db queries?  
serializing? 
rendering? 
are you using old packages which might have open/closed issues about 
performance?

On Friday, May 6, 2022 at 5:03:33 PM UTC-4 Jonatan Heyman wrote:

> Hi! And thanks for the reply!
>
> I've read the release notes but couldn't see anything that popped out as 
> the possible cause. But I'm going to give them another read. Currently, the 
> app is running fine on 3.0, and I haven't started debugging what might be 
> the cause. I started with a message to this list, hoping that this would 
> sound familiar to someone else :).
>
> Bisecting between 3.0 and 3.1 is a possibility, though it's time-consuming 
> since I have to rebuild the Docker image, deploy it to the staging server 
> and run the load test for a little while between each test.
>
> I'll post an update when I make any progress!
>
> Best,
> Jonatan
>
> On Thursday, May 5, 2022 at 2:37:06 PM UTC+2 Antonis Christofides wrote:
>
>> Hi! This is a very interesting problem, and I'm afraid I'm not qualified 
>> to answer it. What I'd like to point out is that, if I had done all the 
>> work that you seem to have done, I would be tempted to start bisecting in 
>> between versions 3 and 3.1 in order to find the exact commit that causes 
>> the problem.
>>
>> (However, in order to avoid that, I might also take a second look at the 
>> release notes, in case there was some information in there. And I might 
>> also ask in the developers mailing list—many of those who might know the 
>> answer don't read django-users.)
>>
>> It's possible it's a Django issue, but it's also possible it isn't. For 
>> example, it could be some error in your caches or templates or other 
>> configuration that happens to only manifest itself in Django>=3.1.
>>
>> In any case, I'm eager to learn how this plays out.
>>
>> Regards,
>>
>> Antonis
>>
>> On 04/05/2022 12.12, Jonatan Heyman wrote:
>>
>> Hi!
>>
>> I've recently upgraded an old Django app from Django 1.11 all the way up 
>> to Django 4.0. Even though the app is pretty large, the migration went 
>> smooth (or so I thought). However, when all tests passed and I deployed the 
>> app to production, I saw that the response time of the app took a 
>> significant hit (the response time for the 95th percentile went from about 
>> 300 ms to 900 ms, and the median from about 100 ms to 250 ms). I also saw 
>> that the server CPU load had increased significantly.
>>
>> I wrote some load tests and started downgrading Django. Now I've narrowed 
>> down the problem to appear when I upgrade from Django 3.0.x to Django 
>> 3.1.x, with no other significant changes to my app code.
>>
>> Is this something someone else has experienced, or does anyone know what 
>> might be going on?
>>
>> Are there any known changes that might increase CPU usage? In that case, 
>> I could throw more hardware at the problem.
>>
>> Any ideas, pointers or insights would be greatly appreciated!
>>
>> Best,
>> Jonatan
>>
>> -- 
>> 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/5f05c06c-bd22-417b-9688-20aca9632bcbn%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/c0712c2b-a796-4bbb-a20a-df31efa5ae8fn%40googlegroups.com.


Re: Filtering by custom UUIDField got broken with Django 3.2 upgrade

2022-05-05 Thread Jason
and curious why the change in this behavior vs using the db's native uuid 
type directly

On Thursday, May 5, 2022 at 7:27:02 AM UTC-4 Jason wrote:

> when you print the query executed, what is the difference between a 
> working query and the current one?
>
> On Wednesday, May 4, 2022 at 11:14:02 AM UTC-4 bmila...@gmail.com wrote:
>
>> Hello Django users,
>>
>> I've recently upgraded the Django version from 2.2 to 3.2 in a project at 
>> work. In this project, we've been using a custom version of UUIDField since 
>> version 1.x without issues. The purpose of this field is to persist the 
>> full UUIDs with dashes into the database (MySQL char(36)).
>>
>> import uuid
>>
>> from django.db import models
>>
>>
>> class UUIDField(models.UUIDField):
>> """
>> Overrides Django UUIDField to store full UUID's including dashes.
>> """
>> def __init__(self, verbose_name=None, **kwargs):
>> super().__init__(verbose_name, **kwargs)
>> self.max_length = 36
>>
>> def get_internal_type(self):
>> return "CharField"
>>
>> def get_db_prep_value(self, value, connection, prepared=False):
>> if value is None:
>> return None
>> if not isinstance(value, uuid.UUID):
>> try:
>> value = uuid.UUID(value)
>> except AttributeError:
>> raise TypeError(self.error_messages['invalid'] % 
>> {'value': value})
>>
>> if connection.features.has_native_uuid_field:
>> return value
>> return str(value)
>>
>> Now the problem introduced with 3.2 is that filtering by this field 
>> doesn't work properly. If I try to filter by a full UUID (with or without 
>> dashes) it returns an empty QuerySet. If I provide only one part of the 
>> UUID (i.e. one group of characters between the dashes) it works just fine.
>>
>> Python 3.6.9 (default, Mar 15 2022, 13:55:28)
>> [GCC 8.4.0] on linuxType "help", "copyright", "credits" or "license" for 
>> more information.
>> (InteractiveConsole)>>> from foobar.foo.models import Foo
>> >>>>>> Foo.objects.all()
>> ]>
>> >>>>>> Foo.objects.filter(id__icontains='34c46fe8-caf0-11ec-bdb9-482ae362a4c0')
>> 
>> >>>>>> Foo.objects.filter(id__icontains='34c46fe8-')
>> ]>
>> >>>>>> Foo.objects.filter(id__icontains='34c46fe8-c')
>> 
>> >>>
>>
>> Here's a little Github Gist 
>> <https://gist.github.com/milonoir/080ecfe1d0fa52df0a0c4a6ab265dde0> 
>> where I uploaded a simplified model.py and admin.py along with the 
>> UUIDField. This is what I used above in the python shell. Any help would be 
>> appreciated, I couldn't figure out how to fix it.
>>
>> (PS: I also raised this in StackOverflow 
>> <https://stackoverflow.com/questions/72101751/filtering-by-custom-uuidfield-got-broken-with-django-3-2-upgrade>
>>  
>> just in case you came across with it.)
>>
>> Cheers,
>> Milan
>>
>>
>>

-- 
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/1766da19-69ca-461f-8a50-908118f18d33n%40googlegroups.com.


Re: Filtering by custom UUIDField got broken with Django 3.2 upgrade

2022-05-05 Thread Jason
when you print the query executed, what is the difference between a working 
query and the current one?

On Wednesday, May 4, 2022 at 11:14:02 AM UTC-4 bmila...@gmail.com wrote:

> Hello Django users,
>
> I've recently upgraded the Django version from 2.2 to 3.2 in a project at 
> work. In this project, we've been using a custom version of UUIDField since 
> version 1.x without issues. The purpose of this field is to persist the 
> full UUIDs with dashes into the database (MySQL char(36)).
>
> import uuid
>
> from django.db import models
>
>
> class UUIDField(models.UUIDField):
> """
> Overrides Django UUIDField to store full UUID's including dashes.
> """
> def __init__(self, verbose_name=None, **kwargs):
> super().__init__(verbose_name, **kwargs)
> self.max_length = 36
>
> def get_internal_type(self):
> return "CharField"
>
> def get_db_prep_value(self, value, connection, prepared=False):
> if value is None:
> return None
> if not isinstance(value, uuid.UUID):
> try:
> value = uuid.UUID(value)
> except AttributeError:
> raise TypeError(self.error_messages['invalid'] % {'value': 
> value})
>
> if connection.features.has_native_uuid_field:
> return value
> return str(value)
>
> Now the problem introduced with 3.2 is that filtering by this field 
> doesn't work properly. If I try to filter by a full UUID (with or without 
> dashes) it returns an empty QuerySet. If I provide only one part of the 
> UUID (i.e. one group of characters between the dashes) it works just fine.
>
> Python 3.6.9 (default, Mar 15 2022, 13:55:28)
> [GCC 8.4.0] on linuxType "help", "copyright", "credits" or "license" for more 
> information.
> (InteractiveConsole)>>> from foobar.foo.models import Foo
> >> Foo.objects.all()
> ]>
> >> Foo.objects.filter(id__icontains='34c46fe8-caf0-11ec-bdb9-482ae362a4c0')
> 
> >> Foo.objects.filter(id__icontains='34c46fe8-')
> ]>
> >> Foo.objects.filter(id__icontains='34c46fe8-c')
> 
> >>>
>
> Here's a little Github Gist 
>  where 
> I uploaded a simplified model.py and admin.py along with the UUIDField. 
> This is what I used above in the python shell. Any help would be 
> appreciated, I couldn't figure out how to fix it.
>
> (PS: I also raised this in StackOverflow 
> 
>  
> just in case you came across with it.)
>
> Cheers,
> Milan
>
>
>

-- 
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/5b4045d3-9687-4388-8063-a3f4ffca1dc4n%40googlegroups.com.


Re: SMTPConnectError

2022-04-24 Thread Jason
how many emails are you sending out like this?

this really isn't a django or python issue, its a gmail/google concern and 
is tied to using this pretty heavily over other services (mailgun, 
sendgrid, etc)

On Saturday, April 23, 2022 at 7:26:09 PM UTC-4 otuwi...@gmail.com wrote:

> Hello guys,
> I get the following error when trying to send mails to users after a 
> successful registration on my app
> "raise SMTPConnectError(code, msg)
>
> Exception Type: SMTPConnectError at /register/
> Exception Value: (421, b'Server busy, too many connections')
>
> "
> Any idea on how to go about this
> my email settings configuration looks like this
> EMAIL_BACKEND =  'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_PORT= 587
> EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
> EMAIL_HOST_PASSWORD= os.environ.get('EMAIL_PASS')
> EMAIL_USE_TLS= True
>

-- 
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/f499a79a-16e7-43f7-86a9-bbefaa2c5b11n%40googlegroups.com.


Re: problem in reloading project files with UWSGI for Django app

2022-04-22 Thread Jason
restart uwsgi?

On Friday, April 22, 2022 at 6:59:28 AM UTC-4 agnese.c...@gmail.com wrote:

> Good morning, today i am facing some issues with my django app at 
> word-b.com.
> The backend is giving me 404 on a reste resource that i have just fixed.
> I have uploaded the files in production just now, thinking that the uwsgi 
> daemon would reload them on demand due to the interpreted nature of python.
> But at th moment the resource is unavailable.
> I have set the aureload on on the application.ini file and touched the 
> files, but i am still getting a 404.
> Can someone help me out?
> Thanks a lot.
> Agnese Camellini
>

-- 
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/9a227cb6-5b2b-49db-9761-4a9f31e42ca8n%40googlegroups.com.


Re: String Concatenate

2022-04-20 Thread Jason
https://tapadoo.com/what-every-programmer-should-know-about-phone-numbers/

might be useful

On Wednesday, April 20, 2022 at 1:44:38 PM UTC-4 shahee...@gmail.com wrote:

>
>
> On Wed, 20 Apr 2022, 11:05 Kasper Laudrup,  wrote:
>
>> On 20/04/2022 11.33, Ankit Chaurasia wrote:
>> > from django.db import models
>> > class Customer(models.Model):
>> >  name = models.CharField(max_length=20)
>> >  phone = models.IntegerField()
>> > I want to concatenate name + last digit of phone number.
>> >
>>
>> It makes no sense to store a phone number as an integer. A phone number 
>> is not something you can increment, decrement or do similar arithmetic 
>> operations with.
>>
>
> Not only that, but it is all too easy to lose the leading zeroes that are 
> often part of a phone number. Kasper is right: don't go there. (I won't 
> even mention about leading plus signs...) 
>
>
>> Just use a CharField or probably even better, a field dedicated to phone 
>> numbers:
>>
>> https://pypi.org/project/django-phonenumber-field/
>>
>> Using a more proper field type will make it simple to do the 
>> concatenation using standard Python.
>>
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/789404f7-e665-d102-1dee-406cbfcfe4cd%40stacktrace.dk
>> .
>>
>

-- 
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/ed6e1736-fa25-4432-92a0-826ff9a55735n%40googlegroups.com.


Re: Report to security@ bounced as "spam"

2022-03-26 Thread Jason
this might be good to report to 
https://groups.google.com/g/django-developers, both the security issue and 
spam reception.

If you sent the mail from the brainonfire.net domain, might be worth 
checking your spam configuration.  Spamhaus shows no issues, so curious why 
this happened.

On Wednesday, March 23, 2022 at 6:13:34 PM UTC-4 cor...@brainonfire.net 
wrote:

> I tried to send in a message to the security team at the email advertised 
> at https://docs.djangoproject.com/en/dev/internals/security/ but Google 
> rejected it:
>
> > Your email to group secu...@djangoproject.com was rejected due to spam 
> classification.
> > 
> > The owner of the group can choose to enable message moderation instead 
> of bouncing these emails.
>
> It's regarding a low-to-moderate severity issue in a common Django library.
>
> Could someone from the security group please reach out to me? Thank you.
>
>  - Tim McCormack
>
>

-- 
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/127161a8-e1b5-4d38-8f81-535015cd0b1en%40googlegroups.com.


Re: Recreation of foreign key constraints when changing type of referenced primary key

2022-03-22 Thread Jason
You might want to ask this at https://groups.google.com/g/django-developers, 
as that is where the framework devs have their discussions.  This is more 
of a users group, and I think you'll get a faster answer by posting there.

On Tuesday, March 22, 2022 at 6:20:41 AM UTC-4 Gregor Jerše wrote:

> Hi,
>
> I have a question regarding Django version 3.2.12.
>
> When I change the DEFAULT_AUTO_FIELD to BigAutoField and create 
> migrations, the foreign keys of auto-generated through tables are dropped. 
> This can be observed by running sqlmigrate which drops foreign key 
> relations 
> but never recreates them.
>
> I noticed this is already fixed in Django 4.0.3 (Refs #32743 -- Fixed 
> recreation of foreign key constraints when alter… · django/django@3d9040a 
> · 
> GitHub 1) but not in 3.2.x branch.
>
> Can I expect this commit will in time be applied to Django 3.2.x branch? I 
> would like to migrate to BigAutoField to be future-proof, but would prefer 
> not 
> to write migrations by hand.
>
> Regards,
> Gregor
>
>
>

-- 
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/014814fd-fe64-4eec-8f42-fe4387ab290dn%40googlegroups.com.


Re: What methods are available to determining display type & screen dimensions for dynamic formatting of Django templates.

2022-03-17 Thread Jason
It does seem like you're looking for something related to analytics, ie 
Google Analytics or one of the alternatives.
On Thursday, March 17, 2022 at 5:52:14 AM UTC-4 Django2021 wrote:

> Increasingly we are finding the need to have reactive Django templates, in 
> order to present cross platform Django forms and pages to not only desktop 
> users buy also tablet, and mobile phone users.
>
> We realize Bootstrap offers breakpoints as a means to control columns, 
> still we are looking for more direct ways of getting essential display 
> information including width, height, device type, and OS for taking control 
> of our own breakpoints where further customization is needed.
>
> Is there a best practice, mature or fully cross platform method recognized 
> by Django users for gathering essential display information as required for 
> reactive Django templates?
>
> And if not what are the most promising techniques other than Bootstrap for 
> Django developers in use for building reactive templates?
>
>
>
>
>
>
>

-- 
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/f7866f28-5c99-427b-a1f6-a7802c3953a5n%40googlegroups.com.


Re: The session doesn't seem to expire after the browser is closed

2022-03-10 Thread Jason
do you also set SESSION_COOKIE_AGE?

https://stackoverflow.com/questions/9267957/is-there-a-way-to-combine-behavior-of-session-expire-at-browser-close-and-sessio/9290334#9290334

On Tuesday, March 8, 2022 at 10:43:06 AM UTC-5 hamza...@gmail.com wrote:

> I'm trying to clear the expired sessions which are set to be expired after 
> the browser is closed but they don't seem to expire.
>
> [image: code.PNG]
> The output:
> get_expire_at_browser_close: True
> All sessions: (A QuerySet contains all the sessions including the ones 
> that are changed after the browser is closed)
>
>

-- 
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/29efa14f-8188-4838-abc1-c0d08f9c6ebdn%40googlegroups.com.


Re: What replaced is_ajax() is django 4

2022-02-24 Thread Jason

Reason why:
https://code.djangoproject.com/ticket/30997
https://groups.google.com/d/msg/django-developers/F8F5b1kEA34/FhqCmRw9BwAJ

Documentation in release notes:
https://docs.djangoproject.com/en/4.0/releases/3.1/#id2
On Thursday, February 24, 2022 at 2:09:13 AM UTC-5 ezra...@gmail.com wrote:

> Hello team.
> Am sending jquery requests in django 4 but I have just realised that 
> checking if the requests were from jquery using is_ajax and then perform 
> ajax related actions is not possible. What is replacing this, and why would 
> such a cool feature be removed.
>
> 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/4122cdac-1e7b-4032-ac51-894f80517982n%40googlegroups.com.


Re: UNIQUE constraint failed: matrixapp_bookplot.user_id

2022-02-05 Thread Jason
A bit of a hint about your db schema, do you want a user ID to be one to 
one with each book plot?  also, why is your primary key a string field?
On Saturday, February 5, 2022 at 10:43:05 AM UTC-5 armaan...@gmail.com 
wrote:

> Hello everyone, 
>
> when i am trying to add uuid primary key , I am getting this error UNIQUE 
> constraint failed: matrixapp_bookplot.user_id
>
> what is wrong here
>
> class BookPlot(models.Model):
> 
> ref_id = models.CharField(max_length=25)
> code = str(uuid.uuid4()).replace("-", "")[:4]
> user_id=models.CharField(primary_key=True,max_length=50, 
> default=code, editable=False)
> plot_number = models.CharField(max_length=25)
> Payable_amout = models.IntegerField(null=True, blank=True)
> Mnthly_Installment = models.IntegerField(null=True, blank=True)
> number_of_Installment = models.IntegerField()
> name = models.CharField(max_length=100)
> father_name = models.CharField(max_length=100)
> mobile_no = models.IntegerField()
> payment_mode = models.CharField(max_length=10)
> remarks = models.CharField(max_length=100)
> receipt = models.ImageField(upload_to = 'receipt/', null= True, 
> blank=True)
> 
> joinig_date=models.DateField(auto_now_add=True,null=True,blank=True)
>
>  
>
>
> def  bookplot(request):
> 
>   
> if request.method =="POST":
> ref_id = request.POST.get('ref_id')
>
> plot_number = request.POST.get('plot_number')
> amount = request.POST.get('amount')
> Mnthly_Installment = request.POST.get('Mnthly_installment')
> no_Installment = request.POST.get('no_Installment')
> name = request.POST.get('name')
> father_name = request.POST.get('father_name')
> mobile_number = request.POST.get('mobile_number')
> payment_mode = request.POST.get('payment_mode')
> remarks = request.POST.get('remarks')
> receipt = request.FILES.get('receipt')
> print(ref_id)
> book_plot = BookPlot(ref_id= ref_id,plot_number = plot_number, 
> Payable_amout = amount,Mnthly_Installment = Mnthly_Installment, 
> number_of_Installment = no_Installment, name = name,father_name = 
> father_name , mobile_no = mobile_number, payment_mode = payment_mode 
> ,remarks=remarks,receipt=receipt )
> book_plot.save()
>  
>

-- 
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/8e0d1acf-a7c2-4a6b-9b04-001856d47071n%40googlegroups.com.


Re: Potential bug: mysql-connector-python Django 3.2.11 and third-party packages that populate the Admin Site

2022-02-03 Thread Jason
can you observe the same behavior in previous versions of connector?  You 
listed two patch versions, makes me curious where in the 8.x version line 
this works.  Likely this is an issue with mysql-connector-python, but with 
it being an Oracle product, it doesn't have much internal visibility.  So 
could be helpful to downgrade versions till you get a working one.

On Wednesday, February 2, 2022 at 9:01:51 PM UTC-5 dashlaksh...@gmail.com 
wrote:

> Use only the mysqlclient package to populate your admin site with MySQL 
> database.
>
> You can watch this tutorial also : https://youtu.be/SNyCV8vOr-g
>
> On Thu, Feb 3, 2022, 06:19 Richard Mayebo  wrote:
>
>> Platform: Observed on Ubuntu 20.04
>>
>>
>>1. Install MySQL (Observed on 5.7 and 8.0)
>>2. Create a Virtual environment using venv, and activate it.
>>3. Install Django 3.2.11
>>4. Install mysql-connector-python (Observed on 8.0.26 and 8.0.28)
>>5. Install django-easy-audit and/or django-axes (both these third 
>>party packages populate the Django Admin Site, where the apparent bug 
>>manifests).
>>6. Create a superuser (python manage.py createsuperuser)
>>7. Start Django (python manage.py runserver)
>>8. Launch the Django Admin Site and log in with the superuser.
>>9. The pane on the left hand side will have links to objects created 
>>by django-easy-audit and/or django-axes, depending on what was installed.
>>10. Click on the "Request event" link under "Easy Audit Application" 
>>or "Access logs" under "Axes"
>>11. RESULT: 
>>
>> Template error: In template 
>> /home//.venv/lib/python3.8/site-packages/django/contrib/admin/templates/admin/base.html,
>>  
>> error at line 44
>>
>>'NoneType' object has no attribute 'day' [*OR  'NoneType' object has 
>> no attribute 'month'*] 
>>
>> This behaviour is observed on MySQL 5.7.37 and 8.0.26 using 
>> my-sql-connector 8.0.26 and 8.0.28.
>>
>> Replacing MySQL with SQLite or PostgreSQL 12 solves the issue. 
>>
>> Replacing the connector with mysqlclient-2.1.0 solves the issue. 
>>
>> This implies there is a bug in the interaction between third-party 
>> packages like django-easy-audit and django-axes, Django 3.2.11 and 
>> my-sql-connector 8.0.26 and 8.0.28.
>>
>> Has similar behaviour been observed by anyone else? In any case, how can 
>> this be brought to the attention of the development team?
>>
>> My apologies if this is the wrong forum for this post. I am new at this.
>> Regards,
>> Richard.
>>
>> -- 
>> 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/0a483673-3393-42f9-87a1-c4463c583d7dn%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/d3eda24e-ab25-406c-9992-3af6f98701c1n%40googlegroups.com.


Re: intermittent migration error

2022-01-26 Thread Jason

nice find!  I would open a django issue, repeating what you have here, so 
Mariusz can see and triage.
On Tuesday, January 25, 2022 at 2:10:18 PM UTC-5 Ben wrote:

> Hello,
>
> I ran into an intermittent migration issue on Django 4.x and PostgreSQL. 
> The migrations work fine on Django 3.2.x, but intermittently fail on 
> Django 4.x with the following exception:
>
> django.db.utils.ProgrammingError: constraint 
> "polls_questioncontribution_base_question_id_25bfb2a8_fk" for relation 
> "polls_questioncontribution" already exists
>
> I made a small demo repo to show the problem: 
> https://github.com/bcail/migration_error. I put the sqlmigrate output 
> from Django 3.2 and Django 4 in the repo, and it looks like Django 4 
> (sometimes) creates duplicate SQL statements.
>
> I also ran git bisect on the Django code, and it looks like the problem 
> starts showing up with this commit: 
>
> https://github.com/django/django/commit/3d9040a50b160f8b4bb580e09f4120d4979fe29e
> .
>
> Should I open a Django issue, or is there something else going on here?
>
> Thanks,
>
> -Ben
>

-- 
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/089e365d-b1a0-4d14-8440-2ac13f46e155n%40googlegroups.com.


Re: Reversing URLs across services

2022-01-22 Thread Jason

yes, this is answered at https://stackoverflow.com/a/32171651
On Saturday, January 22, 2022 at 8:07:09 AM UTC-5 Noemi Millman wrote:

> Hi folks --
>
> Let's say you have two different services with different views and 
> URLConfs; some shared modules/apps and some service-specific.  Is there a 
> way for Service A to reverse URLs served by Service B without having to 
> import all the dependencies that are necessary to execute Service B's views?
>
> thanks,
> -Noemi
>

-- 
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/a03e5a55-218f-4644-b27d-62ec2a247bb6n%40googlegroups.com.


Re: request.POST.getlist('xxx') only has one value in ajax request for many2many

2022-01-16 Thread Jason
https://code.djangoproject.com/ticket/1130

Essentially, this is expected behavior, and previous comment is correct.  
Need to loop through the items in the list

On Sunday, January 16, 2022 at 5:42:45 PM UTC-5 richy...@gmail.com wrote:

> You might want to loop through the list 
> Example:
> Lists = request.getlist('item')
> For list in Lists:
> .
>
>
> On Sun, Jan 16, 2022, 9:30 PM Campbell McKilligan  
> wrote:
>
>> Hi,
>>
>> Using Django 3.2 and Py 3.9
>>
>> I have an ajax request which submits multiple values for a field to an 
>> UpdateView.
>>
>> In the request dict body I see both values (in this case, for the 
>> pool_list column):
>>
>> '_body': 
>> b"csrfmiddlewaretoken=z...h&...=..._datetime==555&
>> *pool_list=507_list=499*&...
>>
>> Later in the request dict, I only see one of the values in the _post:
>> '_post': * 'pool_list': ['499'],*
>>
>> This means that in request.POST.getlist('pool_list'), I'm only getting 
>> one result in the list object.
>>
>> Any idea why it's only the last value being populated in the getlist?
>>
>> -- 
>> 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/bf3a5e3b-4e8c-4a73-8647-d494bedbdf90n%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/cfbd6e3f-4587-4aab-b751-8ae85a6f3479n%40googlegroups.com.


Re: dotenv - django-environ - etc

2021-12-28 Thread Jason
an env file is basically imported into your OS environment, so you can 
retrieve them with the same interface.  That means you can easily include 
that with your build environment, or inject in some other means.  Can't do 
that with settings.

Also, lets you keep one settings file, and use `os.environ.get()` anywhere 
you need to, which provides an identical interface.

On Tuesday, December 28, 2021 at 2:58:28 PM UTC-5 bnmng wrote:

> Hi everyone,
>
> I can't wrap my mind around why having my settings in a .env file is more 
> secure than having them in a local_settings.py file, or why one of the 
> various methods is better than another as long as you keep your local 
> settings out of your version control.  Any opinions?
>

-- 
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/b55a11a7-f219-4a24-a734-b55fdc255cf9n%40googlegroups.com.


Re: are migrations the same regardless of database type?

2021-12-28 Thread Jason
Not exactly.  Migrations try to be generalized across db types, but that 
doesn't mean that you can be using db-specific features in your models and 
ORM usage.  Thats one reason its highly, highly recommended to use the same 
database and version at all layers of your stack.

In other words, if you're using sqlite locally and postgres in deployment, 
you're opening yourself to the high probability of having to figure 
something out and finding out that its due to different features in the 
db.  

On Tuesday, December 28, 2021 at 10:42:56 AM UTC-5 lie...@punkt.de wrote:

> As far as I know, the migrations are "Python-Code" in themselves, only 
> defining which tables change in what way. Only when they are being 
> applied, this is turned into actual database code.
>
> But you can test this easily by creating migrations and look at them. Or 
> use e.g. a postgres docker container, if my memory is wrong.
>
> Cheers
>
> Lars
>
> Am 28.12.21 um 16:02 schrieb Anil Felipe Duggirala:
> > hello,
> > I running an app locally using an SQlite database (I have not been able 
> to set up postgresql locally). I am running the same app in Heroku, using 
> Postgresql.
> > If I run "makemigrations" locally, then push those migrations to Heroku 
> (which is using postgresql), will those migrations be applied correctly by 
> just doing "migrate" on Heroku.
> > Do the contents of migrations files depend on the database type that is 
> associated to the app when creating the migrations?
> > thank you,
> >
> > Anil F
> >
> -- 
> punkt.de GmbH
> Lars Liedtke
> .infrastructure
>
> Kaiserallee 13a 
> 76133 Karlsruhe
>
> Tel. +49 721 9109 500 <+49%20721%209109500>
> https://infrastructure.punkt.de
> in...@punkt.de
>
> AG Mannheim 108285
> Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
>
>

-- 
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/60d5140c-5126-4317-ac51-beef4030f08dn%40googlegroups.com.


Re: Why does sqlmigrate need a connection to an existing database?

2021-12-11 Thread Jason
https://github.com/django/django/blob/main/django/db/migrations/loader.py#L20-L40

the comment in the migration loader class probably explains your question.  
also, look at `collect_sql` at the bottom, and how its used at the end of 
sqlmigrate. specifically, it uses schema editor (
https://docs.djangoproject.com/en/3.2/ref/schema-editor/#module-django.db.backends.base.schema)
 
as a context manager to have the connection turn migration nodes to SQL.





On Friday, December 10, 2021 at 12:06:21 PM UTC-5 shmuel@partnerize.com 
wrote:

> Build graph has a specific separate path for `if self.connection is 
> None:`, so that shouldn't be an issue? 
> As far as atomicity, what if, in a case where no connection is found, it 
> could just prompt: "No database connection found. Do you want your 
> migration to be atomic? (y/N)"
> On Thursday, 9 December 2021 at 05:01:31 UTC-8 Jason wrote:
>
>> It uses db connection in two places:
>>
>> building the migration graph 
>> <https://github.com/django/django/blob/eba9a9b7f72995206af867600d6685b5405f172a/django/db/migrations/loader.py#L210-L215>
>>  in 
>> order to load previous applied migrations and transaction begin/end 
>> wrapping 
>> <https://github.com/django/django/blob/main/django/core/management/commands/sqlmigrate.py#L58-L60>
>>
>> This makes sense, because you can have N unapplied migrations between the 
>> db and your migrations history package.  
>>
>>
>>
>> On Tuesday, December 7, 2021 at 7:46:42 PM UTC-5 
>> shmuel@partnerize.com wrote:
>>
>>> Wondering why sqlmigrate needs a connection to an existing database.
>>>
>>> I understand that for certain commands, it needs the database to 
>>> generate the migration. But for most (basic) commands, no connection is 
>>> really needed.
>>>
>>> For example, I created a test project 
>>> <https://github.com/ShmuelTreiger/test-django-project/tree/master/testproject/migrations>and
>>>  
>>> generated migration files. Without ever running the `migrate` command, I 
>>> was able to use `sqlmigrate` perfectly well on all migrations, save the 
>>> last, which drops a `unique_together`.
>>>
>>> I'm sure there are other commands which actually need a database 
>>> connection (though I haven't found them yet). Seems to me sqlmigrate could 
>>> be rewritten along the lines of:
>>>
>>>- Try to generate sql from migration file
>>>- If it hits a command it needs the database, attempt to connect
>>>
>>> Or else:
>>>
>>>- If no connection, check if migration file needs connection to 
>>>database
>>>
>>> Is there something I'm unaware of?
>>>
>>>
>>> This email may contain confidential material; unintended recipients must 
>>> not disseminate, use, or act upon any information in it. If you received 
>>> this email in error, please contact the sender and permanently delete the 
>>> email.
>>
>>

-- 
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/ead8114b-e439-4319-a5e6-58a48639eb60n%40googlegroups.com.


Re: How to import UGETTEXT_LAZY ON DJANGO 4.0

2021-12-10 Thread Jason

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3
On Friday, December 10, 2021 at 12:01:03 AM UTC-5 ngal...@gmail.com wrote:

> Thanks hopefully the same to ugettext
>
>  
>
> Kind Regards
>
>  
>
> Ngallen Ramadhan
>
> T: +255 765 889 960 <+255%20765%20889%20960> | Emial: ngal...@gmail.com | 
> Skype: ngallen2
>
>  
>
> *From:* django...@googlegroups.com  *On 
> Behalf Of *David Nugent
> *Sent:* 10 December 2021 07:50
> *To:* django...@googlegroups.com
> *Subject:* Re: How to import UGETTEXT_LAZY ON DJANGO 4.0
>
>  
>
> Simply change it to gettext_lazy. You don't need the deprecated functions, 
> they were for python 2.
>
>  
>
> Regards, David
>
>  
>
> On Fri, Dec 10, 2021 at 3:43 PM  wrote:
>
> It seems Django has removed ‘ugettext_lazy`(from django.utils.translation 
> import ugettext_lazy as _) from Django version 4.0.x
>
> How can I handle translation on Django version 4.0.x?
>
>  
>
> -- 
> 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/009b01d7ed80%246da44d40%2448ece7c0%24%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...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%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/3c5bb795-d6f5-4831-aabf-154d6f620490n%40googlegroups.com.


Re: AttributeError: 'Values' object has no attribute 'link_base' in building sphinx documentation.

2021-12-09 Thread Jason
you could raise a bug report on the django tracker 
at https://code.djangoproject.com/query but I'm doubtful that this will 
gain any traction

Those versions of django you specified are very out of date.  1.10 was EOL 
in 2017, 1.11 EOL'd April 2020 and 2.0 EOLd Aug 2018

If you don't have any issues with currently supported versions (2.2, 3.2 
and 4.0),  then its likely that any PRs won't be applied. 

On Thursday, December 9, 2021 at 10:15:03 AM UTC-5 sencer...@gmail.com 
wrote:

> Hello everyone,
>
> If 'sphinx.ext.autodoc' extension enabled in conf.py of sphinx, when I try 
> to run 'make html' I'm ending up with AttributeError exception:
>
> Exception occurred:
>   File 
> /env/lib/python3.6/site-packages/django/contrib/admindocs/utils.py", line 
> 121, in _role
> inliner.document.settings.link_base,
> AttributeError: 'Values' object has no attribute 'link_base'
>
> I tried it with combinations of some django and sphinx versions.
>
> Here is the no luck list:
> django 1.10, django 1.11 and sphinx 3.5
> django 2.0.13 and sphinx 3.5 , sphinx 4.0, sphinx 4.2.0, sphinx 4.3.1
>
> I also opened an issue at sphinx github but they said this has to do with 
> django admindocs instead of  sphinx.
>
> Is there anybody who has resolved the AttributeError exception thrown 
> while building documents via sphinx?
>
> Regards,
> Sencer HAMARAT
>
>

-- 
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/d684ad8e-3001-4d36-8b13-33ce0029cb32n%40googlegroups.com.


Re: Why does sqlmigrate need a connection to an existing database?

2021-12-09 Thread Jason
It uses db connection in two places:

building the migration graph 

 in 
order to load previous applied migrations and transaction begin/end wrapping 


This makes sense, because you can have N unapplied migrations between the 
db and your migrations history package.  



On Tuesday, December 7, 2021 at 7:46:42 PM UTC-5 shmuel@partnerize.com 
wrote:

> Wondering why sqlmigrate needs a connection to an existing database.
>
> I understand that for certain commands, it needs the database to generate 
> the migration. But for most (basic) commands, no connection is really 
> needed.
>
> For example, I created a test project 
> and
>  
> generated migration files. Without ever running the `migrate` command, I 
> was able to use `sqlmigrate` perfectly well on all migrations, save the 
> last, which drops a `unique_together`.
>
> I'm sure there are other commands which actually need a database 
> connection (though I haven't found them yet). Seems to me sqlmigrate could 
> be rewritten along the lines of:
>
>- Try to generate sql from migration file
>- If it hits a command it needs the database, attempt to connect
>
> Or else:
>
>- If no connection, check if migration file needs connection to 
>database
>
> Is there something I'm unaware of?
>
>
> This email may contain confidential material; unintended recipients must 
> not disseminate, use, or act upon any information in it. If you received 
> this email in error, please contact the sender and permanently delete the 
> email.

-- 
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/769abf5f-8afe-4801-8355-fbf27c5b301bn%40googlegroups.com.


Re: Why does django throw TypeError when sending requests through Apache WSGI?

2021-12-09 Thread Jason

with your settings usage, are you defining a property in settings and 
trying to use it anywhere?

furthermore, are you using settings via 

from traveldata.traveldata import settings (example)

or via

from django.conf import settings

The latter is the recommended means because settings are lazy loaded.
On Wednesday, December 8, 2021 at 10:07:11 AM UTC-5 sencer...@gmail.com 
wrote:

> Hi,
>
> I think this is not related with apache
>
> It seems like class object property is called as a method somehow.
> Unfortunately the error does not reveal the property name.
>
> Regards,
> Sencer HAMARAT
>
>
>
> On Wed, Dec 8, 2021 at 4:59 PM Kyle Paterson  wrote:
>
>> Started a new project after not using Django for roughly two years, works 
>> fine when running as a development server but throws TypeError: 
>> SimpleLazyObject class: property object not callable.
>>
>> From apache error log:
>> [Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call 
>> last):
>> [Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in 
>> 
>> [Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from django.core.wsgi 
>> import get_wsgi_application
>> [Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py",
>>  
>> line 1, in 
>> [Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from django.utils.version 
>> import get_version
>> [Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py",
>>  
>> line 7, in 
>> [Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from 
>> django.utils.regex_helper import _lazy_re_compile
>> [Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py",
>>  
>> line 10, in 
>> [Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] from 
>> django.utils.functional import SimpleLazyObject
>> [Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946]   File 
>> "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py",
>>  
>> line 364, in 
>> [Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] class 
>> SimpleLazyObject(LazyObject):
>> [Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling 
>> the metaclass bases
>> [Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid 
>> 140343150348032] [remote 127.0.0.1:44946] 'property' object is not 
>> callable
>>
>> Apache site config file:
>> 
>> # The ServerName directive sets the request scheme, hostname and 
>> port that
>> # the server uses to identify itself. This is used when creating
>> # redirection URLs. In the context of virtual hosts, the 
>> ServerName
>> # specifies what hostname must appear in the request's Host: 
>> header to
>> # match this virtual host. For the default virtual host (this 
>> file) this
>> # value is not decisive as it is used as a last resort host 
>> regardless.
>> # However, you must set it for any further virtual host 
>> explicitly.
>> #ServerName www.example.com
>>
>> ServerAdmin webmaster@localhost
>> 
>> Alias /static /home/kyle/active-travel/traveldata/static
>> 
>> Require all granted
>> 
>>
>> 
>> 
>> Require all granted
>> 
>> 
>>
>> WSGIScriptAlias / 
>> /home/kyle/active-travel/traveldata/traveldata/wsgi.py 
>> process-group=traveldata
>> WSGIDaemonProcess traveldata 
>> python-home=/home/kyle/active-travel/venv 
>> python-path=/home/kyle/active-travel/traveldata/traveldata
>> WSGIProcessGroup traveldata
>>
>> # Available loglevels: trace8, ..., trace1, debug, info, notice, 
>> warn,
>> # error, crit, alert, emerg.
>> # It is also possible to configure the loglevel for particular
>> # modules, e.g.
>> #LogLevel info ssl:warn
>> LogLevel info
>>
>> ErrorLog ${APACHE_LOG_DIR}/error.log
>> CustomLog ${APACHE_LOG_DIR}/access.log 

Re: Setting debug=false is no workig

2021-11-07 Thread Jason
eep, that's a really old version.

what I'd do is 

• grep your project to make sure you're not defining DEBUG anywhere else
• ensure you restarted your server (apache, nginx, etc) process
• ensure your code you're looking at is the same as what is deployed.

On Sunday, November 7, 2021 at 4:44:57 PM UTC-5 andreil...@gmail.com wrote:

> Hi. i have a production site where i am using wsgi.py to show my django 
> project.
>
> i have my settings with DEBUG = False, but when i enter a non existant 
> route, it shows all the debug information, and it says that it has debug = 
> true. as far as i know it should be showing error 500 and send an email
>
> just in case, it is an old project and i am maintaining it, so maybe it is 
> debug set to true in another place? i was just following documentation but 
> could not find any other place where it could be
>
>
> Python Version: 2.7.5
> Django/1.2.7 
>

-- 
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/b1a85b8b-efc7-40ae-9319-cb95bc64f8e2n%40googlegroups.com.


Re: How to update old data with new data everyday from a scraper

2021-09-18 Thread Jason Turner
Take a look at update_or_create()

https://docs.djangoproject.com/en/3.2/ref/models/querysets/#update-or-create

On Sat, Sep 18, 2021, 9:27 AM Adib Neymar Jr.  wrote:

> Hello,
>
> What is a good way to compare new data with old data which is updated
> everyday with Django ORM? Basically I have a scraper which fetches
> hackathons everyday (basically just a celery task) and I want the newest to
> be unioned it with my master database which has the latest fetched
> hackathons from yesterday. I don't want to destroy my master database and
> then just upload everything that I just fetched since that seems wasteful.
> This is my strategy in approaching my problem but I am open to hear other
> options as well.
>
>
> Thanks,
>
>
>
> Adib
>
> --
> 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/CAN%3Doy7JkqHEtaizgKtHniofSS7T%2BybqVer0mJc1uRPRLupUSdQ%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/CADoyC16oRPgc1umjWG-NN1QScqBoebsm3JN_ypFpMHdss6FESw%40mail.gmail.com.


Re: Surpress Daphne request logging levels

2021-08-23 Thread Jason
daphene runs at the same infra layer level as uwsgi/gunicorn so you need to 
define the log level at process init.  Django has no control over this.

On Friday, August 20, 2021 at 12:05:17 PM UTC-4 benny.s...@gmail.com wrote:

> I am trying to surpress the log output from daphne.
>
> example log:
>
> Aug 20 08:33:53 admin daphne[663290]: 127.0.0.1:35638 - - 
> [20/Aug/2021:08:33:50] "PATCH /api/v1/worker/59/" 200 168
>
> logger  'django.request'  seem to have no effect on it.
>

-- 
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/97bb1d13-d536-4fab-94a4-158b40e83927n%40googlegroups.com.


Re: Strange Errors when Using MySQL DB

2021-08-21 Thread Jason
https://code.djangoproject.com/ticket/13906 might give some backgroud on 
this.  tl;dr its django setting the default transaction

the errors your seeing are mysql bugs, would it be possible to update to a 
newer version or at least the latest patch of 5.7?

On Friday, August 20, 2021 at 12:05:20 PM UTC-4 bikram...@homelane.com 
wrote:

> I have a Django (v2.2.23) application connected to a MySQL (v5.7) 
> database. Every now and then, for a few minutes at a time, all my DB 
> queries start to fail with one of the following errors: "Unknown MySQL 
> Error" (error code 2000), "InterfaceError", or "Malformed Packet" (error 
> code 2027). The errors resolve themselves on their own after a few minutes, 
> but then they pop up again a some time later (on average, every few hours). 
> These errors happen seemingly at random and I haven't found any reliable 
> way to reproduce them till now. There is nothing wrong with the code as far 
> as I can see because when the queries do execute, they work as expected and 
> give the correct results.
>
> I have already made several attempts to fix the issue to no avail, 
> including :-
>
>- Following all the steps given in this article 
>
>- Increasing the value of connect_timeout and wait_timeout 
>
> 
>- Changing the charset used in the table in my DB (tried latin1 and 
>utf8)
>- Upgrading the Python mysqlclient package 
> to the latest version (2.0.3)
>
> This error is occuring both on local and staging environments.
>
> In order to debug this further, I create a custom exception handler and 
> logged the error as well as the last 3 SQL queries 
> 
>  executed 
> (which I got using connection.queries[-3:]).
>
> The result is given below:
> 'EXCEPTION': InterfaceError(0, ''), 'LAST_QUERIES': [{'sql': 'SET SESSION 
> TRANSACTION ISOLATION LEVEL READ COMMITTED', 'time': '0.000'}, {'sql': 
> None, 'time': '0.000'}] 
>
> Notice that for the second query, the value of 'sql' is coming as None. Is 
> Django trying to execute a null query? Could this be the cause of the 
> strange, intermittent errors? Is this a bug inside Django or have I 
> configured something incorrectly?
>
>

-- 
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/eb26b775-eac6-4ea5-a2c2-35f240268f3fn%40googlegroups.com.


Re: 2.2.* to 3.2.5 update: jsonb deserialisation is broken!

2021-08-01 Thread Jason
going from 2.2.x to 3.2 is three separate releases of django.  That's alot 
to go in one jump.  Might help if you update one release at a time and 
narrow down which version this regression is in.  

In addition, I'd check the changelogs for each version and see what, if 
any, might apply to your issue.
On Sunday, August 1, 2021 at 10:04:59 AM UTC-4 Tim Richardson wrote:

> Database is postgresql 12
>  psycopg2-binary==2.8.6 \
>
> The bug occurs when I move from django 2.2.* to 3.2.5
> A raw sql query is now behaving differently. A result that was previously 
> deserialised from a jsonb field into a python dict now returns a string 
> (and breaks things). 
>
> this is a simplifed version of my query: 
>
>  sql = """select
> 
> jsonb_array_elements(cached_dear_dearcache.jdata#>'{Fulfilments}')->'Pick' 
> as picks
> from cached_dear_dearcache
>  """
>
> jdata is a jsonb field.
>
> picks should be a dict, eg 
> {"Lines":[{...line1...},{...line2...}]
>
> this has always worked; this django project has always been on 2.2.x
> I use this code in production on a variety of postgresql datbase from v 
> 9.6 to v12.
>
> As soon as I update to 3.2.5, I no longer get a dict. Instead, I get a 
> string which is json. 
>
> I have downgraded to 2.2 since this is major problem. 
>
> Is it a bug or have I missed something?
>
>
>

-- 
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/1328c62b-42a7-42f2-a20d-632a579d12f4n%40googlegroups.com.


Re: Admin TypeError - Cannot call delete() after .distinct()

2021-07-02 Thread Jason

https://code.djangoproject.com/ticket/32682 might be the root cause, which 
was fixed end of April and part of the 3.2.1 release, doesn't seem like its 
been backported to 3.1
On Friday, July 2, 2021 at 2:03:28 AM UTC-4 Mike Dewhirst wrote:

> Trying to delete a record in the Admin list view by checking the 
> checkbox and selecting the delete action and clicking [Go] the following 
> 500 error happened.
>
> It seems to be all within the Admin so I'm not sure how to proceed from 
> here.
>
> Thanks for any hints
>
> Mike
>
> Traceback (most recent call last):
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
>  
>
> line 47, in inner
> response = get_response(request)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py", 
> line 181, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 616, in wrapper
> return self.admin_site.admin_view(view)(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 130, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py", 
>
> line 44, in _wrapped_view_func
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py", 
> line 232, in inner
> return view(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 43, in _wrapper
> return bound_method(*args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py", 
> line 130, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1739, in changelist_view
> response = self.response_action(request, 
> queryset=cl.get_queryset(request))
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1408, in response_action
> response = func(self, request, queryset)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py", 
>
> line 45, in delete_selected
> modeladmin.delete_queryset(request, queryset)
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py", 
>
> line 1109, in delete_queryset
> queryset.delete()
>   File 
> "D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py", 
> line 728, in delete
> raise TypeError('Cannot call delete() after .distinct().')
>
> Exception Type: TypeError at /admin/chemical/chemical/
> Exception Value: Cannot call delete() after .distinct().
>
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
>
>

-- 
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/086bef60-4422-4021-949b-84e19e9768b2n%40googlegroups.com.


Re: how to prevent Django do auto capitalize static text in templates

2021-05-18 Thread Jason Turner
Have you tried Bootstrap's class="text-lowercase"?

On Tue, May 18, 2021, 8:23 AM Samuel Nogueira  wrote:

> I am using bootstrap, so my CSS shouldn't go wrong
>
>
> Em ter., 18 de mai. de 2021 às 10:04, 712189512 <
> gabrielstonede...@gmail.com> escreveu:
>
>> It’s not django that’s doing that,have you checked your css?
>>
>> On Tue, 18 May 2021 at 12:56 David Tobrise  wrote:
>>
>>> What happens if you try outputting the units from dynamically instead of
>>> hard-coding it?
>>>
>>> *Best Regards,*
>>> *David O. T.*
>>>
>>>
>>>
>>>
>>> On Tue, May 18, 2021 at 1:07 PM samuel nogueira bacelar <
>>> hu3mule...@gmail.com> wrote:
>>>
 Hi guys!

 I have something that appears to be a simple problem but I didn’t find
 anything useful anywhere. My problem is that my text in a template next to
 a Django tag keeps auto capitalizing but I don’t want this to happen.



 In the image above you can see that m³/ano and m² is not capitalized at
 all. But bellow my text keeps capitalizing.





 How can I prevent that to happen?



 --
 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/55BF1950-88D1-47E5-9654-18039E00E75E%40hxcore.ol
 
 .

>>> --
>>> 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/CAKeCWo_m7UqF-HLXr0Y%3DgzO9Puu%2BKCuA_mKF86-TPg3sv8QjXw%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> Gabrielstone
>>
>> --
>> 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/CAL-5MpXOhhj-ktjZrZqYmUbF6U933j9MFJr-cCmf67JcMxxO0A%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/CAOJT-cDo50jVF-QCZDWaoTTNQ4yrk3BnC2sszsp6a%3DgyhGmcOg%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/CADoyC14XpJ2mFgF5i2xL2QcPmXCZHnNP_AMc7t4U3o-9gs05mQ%40mail.gmail.com.


Re: django3.2---bug win10

2021-04-25 Thread Jason
that's not a bug.  Look at the two inputs in your terminal.  First one 
starts with a `>`, looks like you copied it verbatim.

`>>>` is convention for terminal prompt

On Sunday, April 25, 2021 at 10:37:59 AM UTC-4 cqwuxi...@gmail.com wrote:

>
> [image: QQ截图20210425220126.png][image: QQ截图20210425220229.png]

-- 
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/28499ffb-86ee-448b-9dba-6ab363a909ddn%40googlegroups.com.


Re: Try to make startapps but getting error

2021-04-15 Thread Jason Turner
Name the app something other than hello_world. It appears as if there is a
conflict.

On Thu, Apr 15, 2021, 8:23 AM Binay kumar  wrote:

> CommandError: 'hello_world' conflicts with the name of an existing Python
> module and cannot be used as an app name. Plea se try another name.
>
> please help me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f8845827-7988-4f8c-ad45-4f0c5f15229an%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/CADoyC15_EP4sbWQkTB1%3D%2BfEOiPLLjyQTtmgB%2BpXiywPbhzmsrg%40mail.gmail.com.


Re: Align Two buttons in a TD

2020-10-24 Thread Jason R
I'd wrap your td element in a container and display it as a flex element.
That will probably conflict with bootstrap though.

On Sat, Oct 24, 2020 at 7:27 PM Walter Randazzo 
wrote:

> Sorry, I forgot to attach the file. This is how the template looks like
> now:
>
> El sábado, 24 de octubre de 2020 a la(s) 20:19:27 UTC-3, Walter Randazzo
> escribió:
>
>> Hi Jhon thanks for replying:
>>
>> I was able to solve the aling issue following  the botstrapp
>> documentation about buttons. Here is the new code:
>>
>>   
>>
>> Editar> class="btn btn-primary btn-sm" href="{% url 'articulos:delete' 
>> articulos.codigo %}" role="button">Borrar
>>   
>>
>> Heres is the Template:
>>
>>
>> El sábado, 24 de octubre de 2020 a la(s) 20:06:30 UTC-3, John_Diddles
>> escribió:
>>
>>> Can you share the CSS?
>>>
>>> On Sat, Oct 24, 2020, 8:10 PM Walter Randazzo 
>>> wrote:
>>>
 Hi Folks,

 Im trying to get aligned 2 buttons in a TD but  they stay overlaped.
 Im attaching the html and the results.

 Hope u guys can help me,

 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/8cf82730-158f-4ef8-8770-fb92859afc03n%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/43d0d55c-d329-450d-852b-75968966f115n%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/CANQeD9taa5AgetTZNp%3D05kM6fvJab7kpU2ic2uEnHur2pMc1YA%40mail.gmail.com.


Re: Django 3.1.2 JSONField handling error with an Postgres Foreign Data Wrapper-based model

2020-10-18 Thread Jason
looks like you got a response back, and there's more context in the linked 
ticket too.  tl;dr json is not jsonb, and django only works with the latter

On Thursday, October 15, 2020 at 10:02:30 AM UTC-4 shahee...@gmail.com 
wrote:

> Thanks Jason, I filed https://code.djangoproject.com/ticket/32111#ticket.
>
> On Thursday, 15 October 2020 at 12:51:22 UTC+1 Jason wrote:
>
>> this is pretty interesting, and may be something to report to the devs at 
>> https://groups.google.com/g/django-developers, or open up a ticket at 
>> https://code.djangoproject.com/  I don't see any tickets with the query 
>> *jsonfield 
>> foreign data* that are similar with your experience, so you may have 
>> found an edge case.
>>
>> On Thursday, October 15, 2020 at 5:31:09 AM UTC-4 shahee...@gmail.com 
>> wrote:
>>
>>>
>>> Hi,
>>>
>>> I have a Django model working fine under Django 3.0 (i.e. "Django<3.1") 
>>> which looks like this:
>>>
>>> ===
>>> class Job(models.Model):
>>> id = models.CharField(max_length=36, primary_key=True)
>>> queue = models.CharField(max_length=40)
>>> args = JSONField()
>>> kwargs = JSONField()
>>> type = models.CharField(max_length=80)
>>> ...
>>>
>>> class Meta:
>>> managed = False  # <--   The table is implemented as a 
>>> Postgres FDW wrapper.
>>> db_table = 'jobs'
>>> ===
>>>
>>> I am testing the update to Django 3.1.2 and hit an error in executing 
>>> this line:
>>>
>>> jobs = list(models.Job.objects.filter(queue='celery', 
>>> state='scheduled'))
>>>
>>> The error is as follows from pytest (i.e. stack trace with local 
>>> variables too):
>>>
>>> ==
>>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>>> _ _ _ _ 
>>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:287: in 
>>> __iter__ 
>>>self._fetch_all() 
>>>self   =  
>>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:1308: 
>>> in _fetch_all 
>>>self._result_cache = list(self._iterable_class(self)) 
>>>self   =  
>>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:70: in 
>>> __iter__ 
>>>for row in compiler.results_iter(results): 
>>>annotation_col_map = {} 
>>>compiler   = >> 0x7f8685e49160> 
>>>db = 'fdw' 
>>>init_list  = ['id', 'queue', 'args', 'kwargs', 'type', 'state', 
>>> ...] 
>>>klass_info = {'model': , 
>>> 'select_fields': [0, 1, 2, 3, 4, 5, ...]} 
>>>known_related_objects = [] 
>>>model_cls  =  
>>>model_fields_end = 9 
>>>model_fields_start = 0 
>>>queryset   =  
>>>related_populators = [] 
>>>results= [[('8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
>>> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
>>> 'paiyroll.tasks.function_run', 'scheduled', ...)]] 
>>>select = [(Col(jobs, paiyroll.Job.id), ('"jobs"."id"', []), 
>>> None), (Col(jobs, paiyroll.Job.queue), ('"jobs"."queue"', []), None..., 
>>> paiyroll.Job.type), ('"jobs"."type"', []), None), (Col(jobs, 
>>> paiyroll.Job.state), ('"jobs"."state"', []), None), ...] 
>>>select_fields = [0, 1, 2, 3, 4, 5, ...] 
>>>self   = >> 0x7f86836f3040> 
>>> /usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py:1100:
>>>  
>>> in apply_converters 
>>>value = converter(value, expression, connection) 
>>>connection = >> object at 0x7f869a321670> 
>>>converter  = >> > 
>>>converters = [(2, ([>> >], Col(jobs, 
>>> pa...NField.from_db_value of 
>>> >], Col(jobs, 
>>> paiyroll.Job.details)))] 
>>>convs  = [>> >] 
>>>expression = Col(jobs, paiyroll.Job.args) 
>>>pos= 2 
>>>row= ['8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
>>> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
>>> 'paiyroll.tasks.function_

Re: Django 3.1.2 JSONField handling error with an Postgres Foreign Data Wrapper-based model

2020-10-15 Thread Jason
this is pretty interesting, and may be something to report to the devs at 
https://groups.google.com/g/django-developers, or open up a ticket at 
https://code.djangoproject.com/  I don't see any tickets with the query 
*jsonfield 
foreign data* that are similar with your experience, so you may have found 
an edge case.

On Thursday, October 15, 2020 at 5:31:09 AM UTC-4 shahee...@gmail.com wrote:

>
> Hi,
>
> I have a Django model working fine under Django 3.0 (i.e. "Django<3.1") 
> which looks like this:
>
> ===
> class Job(models.Model):
> id = models.CharField(max_length=36, primary_key=True)
> queue = models.CharField(max_length=40)
> args = JSONField()
> kwargs = JSONField()
> type = models.CharField(max_length=80)
> ...
>
> class Meta:
> managed = False  # <--   The table is implemented as a 
> Postgres FDW wrapper.
> db_table = 'jobs'
> ===
>
> I am testing the update to Django 3.1.2 and hit an error in executing this 
> line:
>
> jobs = list(models.Job.objects.filter(queue='celery', 
> state='scheduled'))
>
> The error is as follows from pytest (i.e. stack trace with local variables 
> too):
>
> ==
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> _ _ _ 
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:287: in 
> __iter__ 
>self._fetch_all() 
>self   =  
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:1308: in 
> _fetch_all 
>self._result_cache = list(self._iterable_class(self)) 
>self   =  
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:70: in 
> __iter__ 
>for row in compiler.results_iter(results): 
>annotation_col_map = {} 
>compiler   =  0x7f8685e49160> 
>db = 'fdw' 
>init_list  = ['id', 'queue', 'args', 'kwargs', 'type', 'state', 
> ...] 
>klass_info = {'model': , 
> 'select_fields': [0, 1, 2, 3, 4, 5, ...]} 
>known_related_objects = [] 
>model_cls  =  
>model_fields_end = 9 
>model_fields_start = 0 
>queryset   =  
>related_populators = [] 
>results= [[('8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
> 'paiyroll.tasks.function_run', 'scheduled', ...)]] 
>select = [(Col(jobs, paiyroll.Job.id), ('"jobs"."id"', []), 
> None), (Col(jobs, paiyroll.Job.queue), ('"jobs"."queue"', []), None..., 
> paiyroll.Job.type), ('"jobs"."type"', []), None), (Col(jobs, 
> paiyroll.Job.state), ('"jobs"."state"', []), None), ...] 
>select_fields = [0, 1, 2, 3, 4, 5, ...] 
>self   =  0x7f86836f3040> 
> /usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py:1100: 
> in apply_converters 
>value = converter(value, expression, connection) 
>connection =  object at 0x7f869a321670> 
>converter  =  > 
>converters = [(2, ([ >], Col(jobs, 
> pa...NField.from_db_value of 
> >], Col(jobs, 
> paiyroll.Job.details)))] 
>convs  = [ >] 
>expression = Col(jobs, paiyroll.Job.args) 
>pos= 2 
>row= ['8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
> 'paiyroll.tasks.function_run', 'scheduled', ...] 
>rows   =  
>self   =  0x7f8685e49160> 
>value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string', 
> [], {}] 
>
>
>
>
>
> */usr/local/lib/python3.8/dist-packages/django/db/models/fields/json.py:74: 
> in from_db_valuereturn json.loads(value, cls=self.decoder) 
>connection =  object at 0x7f869a321670>expression = Col(jobs, paiyroll.Job.args) 
>self   =  
>value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string', 
> [], {}] *
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> _ _ _ 
>
> s = ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], cls = 
> None 
> object_hook = None, parse_float = None, parse_int = None, parse_constant = 
> None 
> object_pairs_hook = None, kw = {} 
>
>def loads(s, *, cls=None, object_hook=None, parse_float=None, 
>parse_int=None, parse_constant=None, object_pairs_hook=None, 
> **kw): 
>"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` 
> instance 
>containing a JSON document) to a Python object. 
>
>``object_hook`` is an optional function that will be called with 
> the 
>result of any object literal decode (a ``dict``). The return value 
> of 
>``object_hook`` will be used instead of the ``dict``. This feature 
>can be used to implement custom decoders (e.g. JSON-RPC class 
> hinting). 
>
>``object_pairs_hook`` is an optional function that will be called 
> with the 

Re: how to make docker image of your django app

2020-06-17 Thread Jason Turner
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/

Also, Will Vincent's book "Django for Professionals" is a good resource.

On Wed, Jun 17, 2020, 8:51 AM Anirudh choudhary <
anirudhchoudary...@gmail.com> wrote:

> I Want to make make a docker image of my Django app using PostgreSQL and
> unicorn. but I can't find any good tutorial for reference
> please share my link to if you know any good tutorial
>
> My Dockerfile now is like
> FROM python:3.6
> ENV PYTHONUNBUFFERED 1
> RUN mkdir /app
> WORKDIR /app
> COPY requirements.txt /app/requirements.txt
> RUN pip install -r requirements.txt
> RUN apt install postgresql-client
> RUN mkdir postgresqlcode
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> RUN psql "sslmode=verify-ca sslrootcert=\server-ca.pem \
> sslcert=client-cert.pem sslkey=\client-key.pem \
> hostaddr=hostaddress \
> port=port \
> user=postgres dbname=postgres"
> COPY . /code/
>
>
> I know I have to make Django-compose.yml file and I ha
>
>
>
>
>
>
>
> --
> 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/CAL8_rkEBoEuAC7N9XCgDsakOVSsGtM1EM_3bZc9azOL3jPhDjw%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/CADoyC14A%3Df_c7FGt8RQqacpYKMuQAkj-QmGA49Hmzr08EaorLw%40mail.gmail.com.


Re: EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-26 Thread Jason Turner
Is the csv something you created? Or was it given to you?

I use pandas extensively & the times I've received that error, the issue
has been with the file itself.

Ard there blank line(s) at the top of the file?

On Tue, May 26, 2020, 4:11 AM jakote lejaha  wrote:

> The same very same file works fine for the python "csv.reader" function
> with the other parameter as (delimiter=",") other than the file itself.
> I recently added names attribute as a parameter to the "pandas.read_csv"
> function, but I can still not get my table as expected. Instead, I
> get an empty df. Example below:
>
> Empty DataFrame
> Columns: [name, date_time, image, place]
> Index: []
>
> On Tuesday, May 26, 2020 at 2:23:58 AM UTC+2, J.T. wrote:
>>
>> Are you sure the file is coma delimited? This error is usually because
>> the file is not coma separated.
>>
>> On Mon, May 25, 2020, 5:04 PM jakote lejaha  wrote:
>>
>>> Ideally I would have wanted to use the "csv.reader" function, but in
>>> this case it becomes complicated as I would like to load the cvs file to my
>>> web template before I decide if I want to save it to the database or not.
>>> So I opt for reading the file using pandas as it's easy to display the
>>> records to the HTML tags. But however, I keep getting the error below.
>>>
>>>
>>> File "pandas\_libs\parsers.pyx", line 532, in
>>> pandas._libs.parsers.TextReader.__cinit__
>>> 
>>>
>>> Exception Type: EmptyDataError at /upload_reading
>>> Exception Value: No columns to parse from file
>>>
>>>
>>>
>>> How do I fix this?
>>>
>>>
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/72b3aabd-3930-43ab-821f-e43bc23568e4%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/4e0a6361-f3f2-4005-ac2a-627f1b5076dc%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/CADoyC177kKB4Af9SZPB4PNta2QvpzmC%2B-Y8d-vmPRDgHroBB0g%40mail.gmail.com.


Re: EmptyDataError at /upload_reading while reading csv file using pandas

2020-05-25 Thread Jason Turner
Are you sure the file is coma delimited? This error is usually because the
file is not coma separated.

On Mon, May 25, 2020, 5:04 PM jakote lejaha  wrote:

> Ideally I would have wanted to use the "csv.reader" function, but in this
> case it becomes complicated as I would like to load the cvs file to my web
> template before I decide if I want to save it to the database or not. So I
> opt for reading the file using pandas as it's easy to display the records
> to the HTML tags. But however, I keep getting the error below.
>
>
> File "pandas\_libs\parsers.pyx", line 532, in
> pandas._libs.parsers.TextReader.__cinit__
> 
>
> Exception Type: EmptyDataError at /upload_reading
> Exception Value: No columns to parse from file
>
>
>
> How do I fix this?
>
>
>
> --
> 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/72b3aabd-3930-43ab-821f-e43bc23568e4%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/CADoyC17y9MA4Q5J8VZPNsbZ%3D-eShPD_iYHAtNehd%3DeKEypi48A%40mail.gmail.com.


Re: Dynamic Radio Form

2020-05-05 Thread Jason Turner
Thanks. That makes sense. Appreciate your help.

On Tue, May 5, 2020, 11:11 AM Chetan Ganji  wrote:

> To answer your question, you could add an extra field on schedule model to
> store the winner
> e.g. winner = models.CharField(max_length=55)
>
> IMO, league and team in the schedule model should be separate tables. You
> would use fk to them in schedule model.
> winner should also be an fk to team.
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Tue, May 5, 2020 at 3:54 AM J.T.  wrote:
>
>> I'm working on an app that will allow the user to select the winner
>> between two teams (radio buttons) and I need the info saved to the
>> database. I'm having trouble with the radio forms part. I've read the
>> documentation and searched Google all day, but I can't seem to wrap my
>> heads around it.
>>
>> Here are my models:
>>
>> class Schedule(models.Model):
>> LEAGUE_CHOICES = (('HS','HS'), ('NFL', 'NFL'), ('NCAA','NCAA'))
>> week = models.IntegerField()
>> game_id = models.IntegerField(unique=True)
>> away_team = models.CharField(max_length=55)
>> home_team = models.CharField(max_length=55)
>> away_id = models.IntegerField(unique=True)
>> home_id = models.IntegerField(unique=True)
>> league = models.CharField(max_length=15, choices=LEAGUE_CHOICES)
>> def __str__(self):
>> return f'Week {self.week} {self.away_team} vs {self.home_team}'
>>
>> class Selection(models.Model):
>> username = models.ForeignKey(User, on_delete=models.CASCADE)
>> week = models.ForeignKey(Schedule, on_delete=models.CASCADE)
>> select_one = models.CharField(max_length=50)
>> select_two = models.CharField(max_length=50)
>> select_three = models.CharField(max_length=50)
>> select_four = models.CharField(max_length=50)
>> select_five = models.CharField(max_length=50)
>> select_six = models.CharField(max_length=50)
>> select_seven = models.CharField(max_length=50)
>> select_eight = models.CharField(max_length=50)
>> select_nine = models.CharField(max_length=50)
>> select_ten = models.CharField(max_length=50)
>> tie_breaker = models.IntegerField()
>> def __str__(self):
>> return f'Week {self.week} selections for {self.username}'
>>
>> Below is a portion of what I want the template to look like when
>> rendered. It takes the teams from the "Schedule" model
>> and displays them.
>> I then want the id of the selection (the value) of each game saved to the
>> "Selections" model (select_one, select_two, etc.)
>> I can't figure out how to tie in the view so it saves the data to the db.
>> I realize I need to create a forms.py, import it into the view, but that
>> is the part I'm having trouble understanding. I don't
>> know what my forms.py should look like since the team names will change
>> weekly and each match-up is it's own radio selection.
>> Any help is greatly appreciated. Also, if I'm screwing this up on the
>> models level, let me know. I realize that could
>> also be an issue.
>> JT
>>
>> 1  Oklahoma  Oklahoma State NCAA
>> 1  Texas Christian  Houston NCAA
>> 1  Dallas  Philadelphia NFL
>> 1  Houston  Indianapolis NFL
>> 1  New Orleans  Atlanta NFL
>>
>>
>>
>>
>>
>> --
>> 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/398cb0ad-fb81-49ff-bbee-53aa054b6a17%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/CAMKMUjt7dG6QL_WRzB43H%2Bc4f%2B1Gkgt7PSb5YZLd_8Lde4OD-w%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/CADoyC14hZ%2B8ybad8CcOvMOx%3DtNGGGzUc%2B58BvEBUu0dA2dWNFA%40mail.gmail.com.


Re: Django form fields order

2020-04-10 Thread Jason
python dicts are ordered in terms of insertion order as an implementation 
detail in cpython 3.6, and was made part of the spec in 3.7.  You might be 
getting bit by this.

-- 
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/e3ad2b2e-e3c5-4d48-8ad2-a36e01ca2c96%40googlegroups.com.


Re: selectfilter2 javascript and django

2020-03-26 Thread Jason Liu
Thank you so much for providing the solution, it solved my problem as well.

On Wednesday, April 29, 2015 at 6:34:25 AM UTC-7, Dimitris Kougioumtzis 
wrote:
>
>
> ok i found it 
>
> in the urls.py i add  the 
>
>  (r'^jsi18n/$', 'django.views.i18n.javascript_catalog'),
>
>
> and in template 
>
>  
>
>
>
> Τη Τετάρτη, 29 Απριλίου 2015 - 4:12:56 μ.μ. UTC+3, ο χρήστης Dimitris 
> Kougioumtzis έγραψε:
>>
>> i want to use the selectfilter  widget for a view , the user in my django 
>> application is only active not staff because i want to restrict access to 
>> django admin pages. But selectfilter widget dosen't  work
>>
>>
>>
>> the error i get is  
>>
>>
>> SyntaxError: expected expression, got '<'
>>
>> 
>>
>> /admin/jsi18n/ (line 1)
>> 4
>> ReferenceError: interpolate is not defined
>>
>> quickElement('h2', selector_available, interpolate(gettext('Available %s'), 
>> [fie...
>>
>>
>>
>>
>>
>> how to use selectfilter functionality to other views in django 
>> application other tha the admin 
>>
>>
>> thx a lot 
>>
>

-- 
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/984326f4-6ae1-4704-bc28-c33dac44be1f%40googlegroups.com.


Re: Serializing forms and formsets to pass to Celery task

2020-02-29 Thread Jason
As said before, you really can't do that too well with celery.  Its a good 
practice to keep the message body between django -> broker -> worker to be 
as small as possible because we don't know what your configuration for the 
broker is.  In addition, you should never, ever, put sensitive information 
in a message, just the identifier of a thing and let celery/django pull 
from a data store when the task starts.

what I would do is save the form data to some intermediate data store, and 
pass in the identifier to the celery task for retrieval.  That ensures your 
data integrity and security is high.

-- 
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/b5cc2ff0-a4f4-4522-a562-770d392a60a9%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-10 Thread Jason
Hmm.  TIL about https://code.djangoproject.com/ticket/8576

Would a a uuid for this, rather than an integer?  If not, you'll have to 
implement a save override to handle the incrementing yourself.

In addition, it might be worthwhile bringing this ticket up for discussion 
at https://groups.google.com/forum/#!forum/django-developers

-- 
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/dc686528-0a8d-43ff-9973-d478cc765959%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-09 Thread Jason
You just need to use AutoField 


-- 
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/3f0ecd5b-9493-47dd-bf85-382e87c3efd9%40googlegroups.com.


Re: Adding a verbose_name to id field

2020-02-08 Thread Jason
Sounds to me you'd like a separate auto-increment field?

On Saturday, February 8, 2020 at 11:55:48 AM UTC-5, Bruckner de Villiers 
wrote:
>
> Mike,
>
> I tried id = model.AutoField(verbose_name=”Ticket #”).  Migrate didn’t 
> like it – can’t have duplicate primaries.  I suspect this is because the 
> Bug model already exists.
>
>  
>
> What I am trying to achieve is an auto-increment field whereby every time 
> a user logs a bug/suggestion/comment it writes a unique ticket number in 
> the background, which is used as a reference for subsequent actions like 
> Fixed, Close, WiP, etc.  and as a ForeignKey in the Comment model.   I 
> couldn’t find anything meaningful for this functionality and so thought 
> that the ‘id’ is already fit for purpose, but merely requires an 
> explanatory field text.
>
>  
>
> Make sense?
>
>  
>
> Bruckner de Villiers
>
> 083 625 1086
>
>  
>
> *From: *> on behalf of Mike 
> Dewhirst >
> *Reply to: *>
> *Date: *Saturday, 08 February 2020 at 13:48
> *To: *>
> *Subject: *RE: Adding a verbose_name to id field
>
>  
>
> I imagine you need to specify the id field in your model and give it a 
> verbose name. 
>
>  
>
> This is an unusual requirement. Why do you want to do such a thing?
>
>  
>
> Mike
>
>  
>
>  Original message 
>
> From: Bruckner de Villiers > 
>
> Date: 8/2/20 21:33 (GMT+10:00) 
>
> To: django...@googlegroups.com  
>
> Subject: Adding a verbose_name to id field 
>
>  
>
> Using Sqlite3 & Django 3.0.2 - I have searched high and low, but can’t 
> find a way to add a verbose name to the id of a model.
>
> Anyone have ideas, please?
>
>  
>
> Bruckner de Villiers
>
> +27 83 625 1086
>
> -- 
> 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...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/5e3e9fe6.1c69fb81.7cda5.a2fdSMTPIN_ADDED_MISSING%40gmr-mx.google.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/0627cb8d-c308-4ef0-85f9-14de135a2270%40googlegroups.com.


Re: is there a WYSIWYG for Django

2020-02-08 Thread Jason
Anytime you have a question of "is there something in django that will do 
X?", check out https://djangopackages.org/

For example, there is a pretty good up to date WYSIWYG category with 
possible options

https://djangopackages.org/grids/g/wysiwyg/

-- 
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/c8429460-83c6-4176-b917-d0bbf70981db%40googlegroups.com.


Re: Python Django Training

2020-02-02 Thread Charles Jason Decena
i am also interested
Charles Jason Decena

Developer

33F UnionBank Plaza Bldg., Meralco Ave.
Ortigas Center, Pasig City
www.ubx.ph 
[image: linkedin] <https://www.linkedin.com/company/ubx-philippines/>
[image: facebook] <https://www.facebook.com/ubxphilippines/>
[image: twitter] <https://twitter.com/UBXPhilippines>


On Mon, Feb 3, 2020 at 2:27 PM sagar ninave  wrote:

> i am also interested please add me
> whats app : 9657445206
> Email : sagarnin...@gmail.com
>
> On Mon, Feb 3, 2020 at 11:33 AM Sarvesh singh  wrote:
>
>> i am very passionate to learn django more.
>> thanks to you for your support.
>>
>>
>> On Sat, Feb 1, 2020 at 7:12 PM Srikanth K  wrote:
>>
>>> Hi,
>>>
>>> I am from Hyderabad. I am Python Developer by Profession. I am eager
>>> take up any Python , Django Training (online Preferrable or Weekends).
>>> Members who require can contact me or share me  there idea.
>>>
>>> Regards,
>>> Srikanth.K
>>>
>>> --
>>> 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CAK3CZUZ5vwO3ejKf5FpU_i5cQxH%3Dq65TgHKBY44Fu7GDZT2TLw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAK3CZUZ5vwO3ejKf5FpU_i5cQxH%3Dq65TgHKBY44Fu7GDZT2TLw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>
>
> --
>
> <https://about.me/sagarninave?promo=email_sig_source=product_medium=email_sig_campaign=gmail_api_content=thumb>
> sagar ninave
> about.me/sagarninave
> <https://about.me/sagarninave?promo=email_sig_source=product_medium=email_sig_campaign=gmail_api_content=thumb>
>
> --
> 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/CAA6pdZ93Ev%3DqmS9dsnS4jDCeivVni88RnYBo0gRkH3bbkcf-_g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA6pdZ93Ev%3DqmS9dsnS4jDCeivVni88RnYBo0gRkH3bbkcf-_g%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/CADnnF6NSTDTimpiJGMSw2YPzu6NA9PFE3vBSRe-q%2BiM3AvbdpQ%40mail.gmail.com.


Re: Jinja pattern doesnt work inside a for loop

2020-01-25 Thread Jason
While you can use Jinja templates in django, that requires additional 
configuration to ensure the proper template renderer is used.  Otherwise, 
by default, django uses its own template renderer.

You don't say whether you've taken the necessary steps to have your django 
project use Jinja, and from the output you posted, it seems unlikely.

So, the documentation on templates 
 is pretty 
thorough in the steps you need to take, or use django template syntax.

-- 
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/213f585e-4b65-409f-b94f-0bc0fb9547c4%40googlegroups.com.


Re: Django and MySQL NDB Cluster

2020-01-22 Thread Jason
https://code.djangoproject.com/ticket/27677

Check the last comment from Tim.

-- 
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/cf55ca36-909a-4a43-af29-c581b0a954ba%40googlegroups.com.


Re: URL pattern for URL with query string

2020-01-13 Thread Jason
The url resolver does not include GET query params in a URL, you need to 
add them manually after the string.

for example

url = 
f"{reverse('weather')}/?current_location={some_value}_location={another_value}"

-- 
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/6dd43044-909b-49b2-87fc-5344508af9e8%40googlegroups.com.


Re: How to filter a Window query?

2020-01-01 Thread Jason
I would use raw sql for this, since there's no direct support in the ORM 
for this.

-- 
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/1a384949-6baa-4810-9f9e-02f0a168065c%40googlegroups.com.


Re: Trouble with Django Generic List view

2020-01-01 Thread Jason
when you do 

return jobs, print(jobs)



you're returning a tuple from the method, which is not what is expected.  
Remove the print statement from that line


On Wednesday, January 1, 2020 at 5:02:13 PM UTC-5, Sam Hefer wrote:
>
> Hi,
>
> I'm having some issues with displaying a filtered list in a template. 
>
> My View:
>
> class MyJobs(ListView):
> model = Job
> template_name = 'jobs/my_job_list.html'
> context_object_name = 'jobs'
>
> def get_queryset(self, *args, **kwargs):
> jobs = Job.objects.filter(company_name__owner=self.request.user)
> return jobs, print(jobs)
>
>
> My Template:
>
> 
> {% for job in jobs %}
> {{ job.company_name }}
> {% endfor %}
> 
>
>
> The print function on jobs shows the correct list for the logged in user, 
> but for some reason, in the template the view only lists two objects (for 
> all users) and the field reference doesn't show anything (jobs.company_name 
> is always empty).
>
> Have I missed something?
>
> Thanks,
> Sam
>
>
>

-- 
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/bf76ad50-f57f-40d1-916f-3d29aec39b34%40googlegroups.com.


Re: pip install mysqlclient not working

2020-01-01 Thread Jason
OP is on windows, and doesn't have Visual Studio Build Tools installed.  
That's the problem.

https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
  
its the last item in the second section.

Also, OP, if you have python 2 and 3 on your machine, specify the version 
of pip you want, or use a virtualenv.  

-- 
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/576372dc-f76a-462d-a320-a7cb48df9c3b%40googlegroups.com.


Re: How to ensure genuine emails despite valid email format?

2019-12-30 Thread Jason
I have no idea if this is a thing in Mailgun, sorry.  You'll have to check 
their documentation.

-- 
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/8fe7b54a-be79-4c6b-baf6-57c95b26e17a%40googlegroups.com.


Re: How to ensure genuine emails despite valid email format?

2019-12-30 Thread Jason
Part of your problem is that email is a fire-and-forget application.  Once 
it's sent out, its in the control of the email server for routing.

   1. I don't know of a way to handle this without having any access to the 
   account the user uses to send the email
   2. Use a whitelist of valid email senders, but this is a neverending 
   task with high probability of false positives.  And disposable email 
   addresses have their valid uses, and I use them frequently to help control 
   spam. So if you block those, you might be angering alot of your valid users
   3. Same with 2, whitelist
   4. Same with 2, whitelist

-- 
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/e60804c0-ff8b-442d-95ad-efd6dbbc5e12%40googlegroups.com.


Re: Strange issue with django

2019-12-26 Thread Jason
Also, you haven't stated where the bottlenecks are happening.  Is it app 
code, internal in django, your stack, database, networking?  There's alot 
of variables in play for diagnosing a major slowdown, and you've provided 
no information about profiling/monitoring

-- 
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/37b9526a-756f-4ac7-835a-af49f0dada02%40googlegroups.com.


Re: Strange issue with django

2019-12-26 Thread Jason
Do you have any performance monitoring in place, with profiling add-ons, 
like new relic's x-ray trace?

That was really helpful in figuring out a bottleneck in a django service 
last year.

-- 
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/385cf9db-752b-473a-b37f-c26b866f2b2a%40googlegroups.com.


Handler 500

2019-12-03 Thread Charles Jason Decena
is there a way to retrieve the handler 500 data/error?  and also can i have 
multiple handler 500 in my base url in order to be dynamic? and how to get 
the error message in handler500

-- 
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/c65b91c2-dbea-4113-a446-6a4892f08135%40googlegroups.com.


Re: beginner's question

2019-11-05 Thread Charles Jason Decena
Hi, what you have entered is a command on checking on what django version
is installed on your machine, i suggest you create pipenv or venv everytime
you create projects in order to eliminate other dependencies not required
for your project

Regards,
Charles Jason Decena

Developer

33F UnionBank Plaza Bldg., Meralco Ave.
Ortigas Center, Pasig City
www.ubx.ph 
[image: linkedin] <https://www.linkedin.com/company/ubx-philippines/>
[image: facebook] <https://www.facebook.com/ubxphilippines/>
[image: twitter] <https://twitter.com/UBXPhilippines>


On Tue, Nov 5, 2019 at 11:42 PM Sarma Bhamidipati <
sarma.bhamidipat...@gmail.com> wrote:

> Did you activate your application?
> Have you added your python path to path variable?
>
> On Tuesday, November 5, 2019 at 3:25:00 PM UTC, Takashi Sawa wrote:
>>
>> 今再度挑戦したら、次はこれが出てきました。
>>
>>
>> C:\Users\sour->python -m django --version
>> 2.2.7
>>
>> C:\Users\sour->django-admin startproject mysite
>>
>> C:\Users\sour->python manage.py runserver
>> python: can't open file 'manage.py': [Errno 2] No such file or directory
>>
>> C:\Users\sour->
>>
>> なにが問題でしょうか。
>>
>>
>> 2019年11月6日水曜日 0時07分01秒 UTC+9 Siratim Mustaquim:
>>>
>>> Can you elaborate a  little bit? that command checks the version of
>>> django that is currently installed.
>>>
>>>
>>> On Tue, Nov 5, 2019 at 9:00 PM Takashi Sawa  wrote:
>>>
>>>>  File "", line 1
>>>> python -m django --version
>>>>   ^
>>>> SyntaxError: invalid syntax
>>>>
>>>> What's this?
>>>>
>>>> --
>>>> 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...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/a626578e-a97d-4bef-b394-5472917327fa%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/a626578e-a97d-4bef-b394-5472917327fa%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/73e70648-ae7a-4d85-93bb-9ae54fc1434d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/73e70648-ae7a-4d85-93bb-9ae54fc1434d%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/CADnnF6NkjdiXiD2m7J-BDgFnW2kydb0zGo2kStc%2B4-NhjmE%3Dyg%40mail.gmail.com.


Re: ModuleNotFoundError: No module named 'mysite.polls'

2019-10-28 Thread Charles Jason Decena
mysite.apps.polls would solve your problem


On Sunday, October 27, 2019 at 1:01:09 AM UTC+8, Beto Joaquim wrote:
>
> hello guys I'm new on Django and I would like to ask your help, I've added 
> "mysite.polls'' to my SETTINGS > Installed app... but it still say " 
> ModuleNotFoundError: No module named 'mysite.polls'"
>

-- 
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/211ca9e3-78bf-4d40-a7fb-a01f544ec728%40googlegroups.com.


Re: to make a wish list .

2019-10-28 Thread Charles Jason Decena
Try putting foreign key to the wishlist model 

On Friday, October 25, 2019 at 7:56:42 PM UTC+8, Shubham Mishra wrote:
>
> hello, 
> I am Surendra Mishra , I am student currently i'm learning django.
> I applied for internship , but they gave me a task if i complete then they 
> will consider me . 
> please help me to complete this task. 
>
> mostly i have done but in the last section im fighting but i not getting 
> exact thing .
> i have some item and in under i have wishlist button . my requirement 
> is when i click  the wishlist button for the particular item that item must 
> be added in the wishlist page .
>
> so what is the logic and what is the template page for that .
>
>
>  
>

-- 
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/b104f9e6-2ef9-431f-bf88-4b71157916bd%40googlegroups.com.


Re: Celery with SQS

2019-10-27 Thread Jason
celery 4.x is for django 18 or newer 
<https://docs.celeryproject.org/en/latest/django/first-steps-with-django.html>

Thing is, there's been *a lot* of changes in django since 1.4, which last 
recieved a minor update in 2015.  I get updating is not as easy as waving a 
magic wand, but you're using very out of date versions, so any 
investigation has to keep that in mind  That has the consequence of 
significantly limiting the amount of help you can get because you're 
relying on people dredging up 4 years or so of memories.

Unfortunately, I don't know SQS.  If this is working fine with Rabbit as 
your broker, why the move to SQS while keeping all other dependencies the 
same?

On Saturday, October 26, 2019 at 4:33:23 PM UTC-4, Rogério Carrasqueira 
wrote:
>
> Hello Jason! 
>
> Thanks for your reply, it is not so easy to move from 1.4.22 to 2.2, 
> it a big leap. I can upgrade the celery to 4.3, but I don't know if it 
> will work well with Django 1.4.22. Do you have a clue about what could 
> be this issue? 
>
> Thanks 
>
>
> Rogério Carrasqueira 
>
>
>
>
> Em sáb, 26 de out de 2019 às 16:40, Jason  > escreveu: 
> > 
> > both those versions are severely out of date, so I would first suggest 
> to update.  current version of celery is 4.3, and django is 2.2.  If you 
> have reasons to move from rabbit to SQS, why not update everything else 
> while you're at it? 
> > 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/419fedc2-a953-4a2f-a24e-560fbf3bd9ad%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/6ab818d9-8129-45e4-9912-c297614535f5%40googlegroups.com.


Re: Celery with SQS

2019-10-26 Thread Jason
both those versions are severely out of date, so I would first suggest to 
update.  current version of celery is 4.3, and django is 2.2.  If you have 
reasons to move from rabbit to SQS, why not update everything else while 
you're at it?


-- 
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/419fedc2-a953-4a2f-a24e-560fbf3bd9ad%40googlegroups.com.


  1   2   3   4   5   6   7   8   9   >