Re: Explicitly setting 'created' date for initial user import from legacy application

2018-09-24 Thread Chris Routh
Ahh, I've worked out that if I overwrite the created property with `model.created = oldmodel.joined` and call `.save()` a second time it will work. Cheers folks! On Monday, 24 September 2018 10:37:11 UTC-7, Chris Routh wrote: > > Hi all, > > I need to explicitly set the created date for users

Running a single version of my Django app but with two databases: one for dev and one for prod

2018-09-24 Thread jim_rain
Hi, I'm developing a Django app, it's hosted on an EC2 instance so I'm using wsgi, even in development. I would like to create a production and a development version where really the only things that are different are the two databases. I want the code to be the same on both. I figured I

Re: Django - using intermediate user group model

2018-09-24 Thread Mateusz
I still doubt if I understood correctly, but if yes -- https://docs.djangoproject.com/en/2.1/topics/db/examples/many_to_many/ contains your answer. Either you don't need 'through' table (because it would not carry any additional data), or if you do... you can just add only foreign keys to

Explicitly setting 'created' date for initial user import from legacy application

2018-09-24 Thread Chris Routh
Hi all, I need to explicitly set the created date for users when saving them during an initial import process from a legacy user table. I am using a legacy DB model and trasnforming the models and saving the new user obects. I only need to override the default create behaviour for this one

Explicitly setting 'created' date for Users when importing from Legacy database

2018-09-24 Thread Chris Routh
Hi folks, I'm wondering if there is a way to override the automatic 'creation' date for a user for an initial import of users from a legacy database, but then use normal created date settings the rest of the time. I imagine I need to override the user model, however I would only need to do

Re: Django - using intermediate user group model

2018-09-24 Thread Fernando Balmaceda
Thanks for the answer Mateusz, but i need the original intermediate between User and Groups. i don't need to create my custom group model El domingo, 23 de septiembre de 2018, 14:19:45 (UTC-3), Mateusz escribió: > > Is that User [N] -- [N] Group with many to many through Enrollment > (something

Re: Chaining Q objects

2018-09-24 Thread MikeKJ
many thanks Simon dict filter kwargs was definitely the way to go! On Wednesday, 19 September 2018 15:45:07 UTC+1, Simon Charette wrote: > > Hey Mike, > > Please provide the full traceback. > > Also, since all your conditions are ANDed you could use a dict to build > filter() kwargs instead of

Re: Chaining Q objects

2018-09-24 Thread MikeKJ
Cheers Matthew, can't use .first() due to reskinning an existing site with an older version On Wednesday, 19 September 2018 15:36:13 UTC+1, Matthew Pava wrote: > > I’m not entirely sure if the error is from your Q chain, but something I > would try is to replace “[:1].get()” with “.first()”. >

Re: Update django 1.8 project to 2.0 lts

2018-09-24 Thread Bill-Torcaso-Oxfam
I strongly recommend this approach: My experience is that the best thing to do is to do minor upgrades - 1.8 -> 1.9.x -> 1.10.x -> 1.11.x (where x is the last patched version of each minor version). Further, at the completion of one Django version, I recommend saving a snapshot of your

Re: Multiple annotations in one query

2018-09-24 Thread David
Thanks Matthew will take a look. On Monday, 24 September 2018 15:40:44 UTC+1, Matthew Pava wrote: > > Hi David, > > Performing multiple annotations on a queryset is not the same as combining > multiple aggregations. > > Saying that, if you truly are getting wrong results, you could try using >

RE: Multiple annotations in one query

2018-09-24 Thread Matthew Pava
Hi David, Performing multiple annotations on a queryset is not the same as combining multiple aggregations. Saying that, if you truly are getting wrong results, you could try using the Window functions or the Subquery object.

Multiple annotations in one query

2018-09-24 Thread David
Hi I understand that performing multiple annotations on a queryset will produce incorrect results, I was wondering how anyone else gets around this? "Combining multiple aggregations with annotate() will yield the wrong results because joins are

Re: When I click on submit button on login page, its redirecting to an random csrf token page in django

2018-09-24 Thread Nelson Varela
Do you have 'django.middleware.csrf.CsrfViewMiddleware' in your list of middlewares in your settings? On Monday, September 24, 2018 at 2:52:33 PM UTC+2, Srinivas Gadi wrote: > > > When I clock on the login page, it supposed to save the data in DB but > instead URL being redirected to csrf token

When I click on submit button on login page, its redirecting to an random csrf token page in django

2018-09-24 Thread Srinivas Gadi
When I clock on the login page, it supposed to save the data in DB but instead URL being redirected to csrf token page. url.py from django.conf.urls import urlfrom . import viewsfrom django.contrib.auth.views import login, logout urlpatterns = [ url(r'^$', views.home), url(r'home',views.home,

Re: Error at OneToOneField in models while creating new models class

2018-09-24 Thread Srinivas Gadi
Thank you for the response, 1. Deleted the migrations folder 2. Removed the SQLite3 DB itself 3. My dir structure. 24-09-2018 16:37 . 24-09-2018 16:37 .. 23-09-2018 15:06 college 19-09-2018 08:56 554 manage.py 19-09-2018 10:59

Re: error at re_path

2018-09-24 Thread PASCUAL Eric
Hi, Not 100% sure, but I think that the 'p' should be a "P" (capital). I've always used the capital version, since it's was is shown in the docs and examples, so I can't say if lowercase 'p' works too. Eric From: django-users@googlegroups.com on behalf of

Re: Update django 1.8 project to 2.0 lts

2018-09-24 Thread Andréas Kühne
Hi, My experience is that the best thing to do is to do minor upgrades - 1.8 -> 1.9.x -> 1.10.x -> 1.11.x (where x is the last patched version of each minor version). The reason for updating in this fashion, is that when you start the server on each version, you will get warnings about