Re: Redesign of agricultural project with python django and next.js technologies.

2024-02-19 Thread Dan
I'm Interested.
My WhatsApp number is +2205192833.

On Sunday, February 18, 2024 at 10:48:48 AM UTC-6 Jorge Bueno wrote:

> The project:
>
> I am working on an exciting project that I think you may be interested in. 
> It is an online marketplace, similar to the US farmers and livestock 
> markets, but with a strong online focus. The project is going to be redone 
> from 0 I have a very detailed backlog . Contributing to this real-world 
> project will allow you to learn a lot while working with modern and 
> relevant technologies.
>
> Technologies:
>
> We are using Python and Django for the backend, and Next.js for the 
> frontend.
>
> Why collaborate.
>
> Learn and grow: The project is well organized, providing the opportunity 
> to work with cutting-edge technologies.
> Impactful contribution: Your work will directly influence the success of 
> the project.
> Community involvement: Join our passionate team committed to project 
> excellence.
> How can you participate?
>
> I keep the repository private to avoid unnecessary distractions. Here's 
> the link to the GitHub repository: 
> https://github.com/Programacionpuntera/Marketplace-again. To add you, I 
> will need your GitHub username. Also, I have created a WhatsApp group for 
> the project. The more participants, the faster we will complete it! Feel 
> free to share your phone number and I'll add you to the group. And just so 
> you know exactly what I'm going to work on, I'm going to pass the entire 
> backlog:
> E-commerce Website Development Requirements:
>
> Backend (Python and Django):
>
>
> User Registration:
>
> Create user models for farmers, ranchers, and consumers.
> Define the necessary attributes for each type of user in the data model.
> Implement CRUD (Create, Read, Update, Delete) functions for each user 
> model.
> Implement authentication by email or phone number and password.
> Use a secure authentication library to store passwords securely.
> Implement logic to verify the authenticity of emails or phone numbers.
> Develop logic for user type selection and send verification emails or SMS.
> Create a user interface to select the user type during registration.
> Implement logic to send verification emails or SMS after registration.
>
>
> User Profiles:
>
> Create models and views to store basic information and specific details 
> for farmers, ranchers, and consumers.
> Define the necessary attributes for each type of profile in the data model.
> Implement CRUD (Create, Read, Update, Delete) functions for each profile 
> model.
> Create views to expose the profile data through an API.
>
>
> Product Listings:
>
> Implement models and views for products.
> Define the necessary attributes for each product in the data model.
> Implement CRUD functions (Create, Read, Update, Delete) for the product 
> model.
> Create views to expose product data through an API.
> Develop the logic for farmers and ranchers to publish products.
> Implement logic to allow farmers and ranchers to publish new products.
> Ensure that only authenticated users can publish products.
>
>
> Search Engine and Filters:
>
> Implement a search engine that supports filters.
> Develop logic to search for products based on different criteria (e.g., 
> product name, category, price, etc.).
> Implement logic to filter search results based on different criteria 
> (e.g., price range, location, etc.).
>
>
> Shopping Cart:
>
> Implement logic to add products to the cart.
> Develop logic to allow users to add products to the cart.
> Implement logic to update the quantity of a product in the cart.
> Create logic to remove products from the cart.
>
>
> Payment System:
>
> Integrate payment gateways (PayPal, cards, etc.).
> Implement the logic to process payments through different payment methods 
> such as PayPal and credit/debit cards.
> Ensure that all transactions are secure and comply with relevant 
> regulations.
> Generate invoices and manage sales commissions.
> Develop the logic to generate invoices automatically after each purchase.
> Implement logic to calculate and manage sales commissions.
>
>
> Ratings & Reviews:
>
> Implement a ratings and reviews system with moderation.
> Develop models to store ratings and reviews of products and sellers.
> Implement logic to allow users to post ratings and reviews.
> Create a moderation system to review and approve reviews before they are 
> posted.
>
>
> Messaging:
>
> Create a messaging system between consumers and vendors.
> Develop models to store messages between consumers and vendors.
> Implement logic to allow users to send and receive messages.
> Create a system to keep track of messages sent and received.
>
>
> Notification System:
>
> Develop an event-based notification system.
> Implement logic to generate notifications based on specific events (e.g., 
> new messages, order status updates, etc.).
> Create a system to store and manage notifications for each user.
>
>
> Order Management:
>
> Implement logic for sellers to 

Re: django multi databases and multi sessions

2023-03-20 Thread Dan Wood
I’m working on a big multi tenant app feel free to email for information, I
use a different schema for each tenant

-- 
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/CAAMaO6%2BjaussZhq%2BdKhSuZqCVj8x57ST_M_58C1TgpszHacqwQ%40mail.gmail.com.


uvicorn and ASGI

2022-06-05 Thread Dan Davis
I am doing some work comparing various ASGI frameworks, SQL Alchemy, just 
writing the SQL, and that sort of thing, in order to determine what I 
think.  Speed isn't every thing, but speed is a thing.

Anyway, I was reading about this 
at https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/uvicorn/ and 
it is curious that the advise is to run uvicorn as a work rather than a 
full ASGI server.  Can someone explain why this is necessary or better?

Thanks,

-Dan

-- 
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/5dbf8350-1c28-4eb1-a3c8-f3a06566a06dn%40googlegroups.com.


Update to Tutorial 4 - Generic Views

2022-03-11 Thread Dan Cox
Hi I've been searching on how I might contribute to the tutorials but I 
can't seem to find a way. If you could help me there I could take this 
question to a potentially more useful place.

Anyway; I am pretty new to Django but I've been following the tutorials and 
in the Generic Views section 
here: https://docs.djangoproject.com/en/4.0/intro/tutorial04/

I beleive that there is a missing import statement in the urls.py file:
from django.views.generic import TemplateView

I was scratching my head trying to work out why I was getting errors and 
upon adding that (which I found in the more general documentation on Views) 
everything worked.

Cheers,

Dan.

-- 
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/9869e767-7255-40e4-839e-fdcb6d834257n%40googlegroups.com.


Re: Periodic Execution of django functions or tasks

2022-03-07 Thread Dan Davis
If celery is too much, consider django-background-tasks.

To be totally honest, I am an old dog, and I generally do the following:
* Write a management command.
* Deploy a crontab to run my management command.

This is not so container or cloud friendly, but none of my cloud 
deployments run "long" tasks.  So, I've been able to translate this old 
pattern like this:
* Have a Lambda hit a web URL which runs the management command through 
django.core.management.call_command (for brief commands)
* Deploy to Lambda using Zappa and have a scheduled event in CloudWatch 
events run the command.

I think doing this same pattern with AWS Batch would work for longer 
commands - and only AWS is relevant to me.

Anyway, django-background-tasks or a simple management command are both 
less to deploy than celery.



On Tuesday, October 20, 2020 at 10:34:44 AM UTC-4 Derek wrote:

> Ryan's suggestion is a very good one. 
>
> If you don't need Django-specific commands, you can even write a 
> stand-alone Python script which accesses your database to do the work. An 
> alternative to cron that we use, on occasion, is 
> https://pypi.org/project/APScheduler/ which runs in a container (a Python 
> scheduler like this is also useful if you want to run on a non-Unix 
> operating system). 
>
> On Tuesday, 20 October 2020 at 01:53:50 UTC+2 Ryan Nowakowski wrote:
>
>> On Mon, Oct 19, 2020 at 04:53:35PM +0300, MUGOYA DIHFAHSIH wrote:
>> > Hello fellow django developers, i am working on a web app in which 
>> reports
>> > are archived in the database at the end of every month automatically, i
>> > have searched on internet and many folks are suggesting celery which i 
>> have
>> > tried but not fruitful, is there any other library i use to accomplish 
>> this.
>> > 
>>
>> Yeah, celery is great! But sometimes it's too complex a beast for
>> simple things. Usually I write a custom Django management command[1].
>> In your case it would probably be named something like archivereports.
>> Then add a cron entry to run it at the end of every month.
>>
>> [1] 
>> https://docs.djangoproject.com/en/2.2/howto/custom-management-commands/
>> [2] https://help.ubuntu.com/community/CronHowto
>>
>

-- 
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/3c58c400-ba48-4512-9f4a-0e1998a44190n%40googlegroups.com.


Re: Wrapping dbshell and invoking procedures and such

2021-10-22 Thread Dan Davis
Never mind - os.pipe, os.fork, and os.dup2 work quite well.  The only thing 
I needed was to open the output as a Python IO object, and to be careful 
about semicolons.  And I didn't want to go back to perl...  See the code at 
https://gist.github.com/danizen/de40b4e6bfa713fc76d6fe2cfaa236cc

This will allow me to have my Django management commands act as wrappers 
for the SQL stored procedures.
On Friday, October 22, 2021 at 6:58:04 PM UTC-4 Dan Davis wrote:

> I've succeeded over the last few years in creating a Django app that 
> everyone likes that uses a "tip of the iceberg" out of a 20 year old 
> database. Now I've inherited the SQL development as well, and I want to 
> cleanup and move towards more Django.
>
> There are lots of small, non-DRY scripts run from cron which invoke a 
> stored procedure after doing some boilerplate.  Because the procedures are 
> developed from an Oracle Developer's perspective, they do a lot via 
> DBMS_OUTPUT and stuff.  I want to replace most  of these scripts with a 
> single DRY Django management command taking the following inputs:
>
>- Stored procedure to run
>- What log file to generate
>- Who should get the email
>
> This makes things more DRY while still letting SQL development be SQL 
> development. My idea is that the parent management command forks a child 
> process that runs dbshell, and then writes into the dbshell input the stuff 
> to run.   However, I think to do that, my code really needs to call 
> pipe/dup2 (see basically history of UNIX).
>
> My problem is that I really want to combine that with django's 
> call_command.
>
> print(f'spool {sql_log_path}', file=dbshell_in)
> print(f'set echo on', file=dbshell_in)
> print(f'sho user', file=dbshell_in)
> print(f'execute {stored_proc}', file=dbshell_in)
> print(f'spool off')
>
> What do I have to do to really call pipe and dup2 before I do this stuff?  
> I used to be a wizard at this stuff in perl, but I don't want to go back to 
> perl... Python/Django is the world and anything more than that and SQL is 
> overkill for the backend and one more thing to learn (except maybe invoking 
> all of this stuff from Apache Airflow).
>

-- 
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/69f24acd-ba21-421b-bbac-99f568ff236en%40googlegroups.com.


Wrapping dbshell and invoking procedures and such

2021-10-22 Thread Dan Davis
I've succeeded over the last few years in creating a Django app that 
everyone likes that uses a "tip of the iceberg" out of a 20 year old 
database. Now I've inherited the SQL development as well, and I want to 
cleanup and move towards more Django.

There are lots of small, non-DRY scripts run from cron which invoke a 
stored procedure after doing some boilerplate.  Because the procedures are 
developed from an Oracle Developer's perspective, they do a lot via 
DBMS_OUTPUT and stuff.  I want to replace most  of these scripts with a 
single DRY Django management command taking the following inputs:

   - Stored procedure to run
   - What log file to generate
   - Who should get the email

This makes things more DRY while still letting SQL development be SQL 
development. My idea is that the parent management command forks a child 
process that runs dbshell, and then writes into the dbshell input the stuff 
to run.   However, I think to do that, my code really needs to call 
pipe/dup2 (see basically history of UNIX).

My problem is that I really want to combine that with django's call_command.

print(f'spool {sql_log_path}', file=dbshell_in)
print(f'set echo on', file=dbshell_in)
print(f'sho user', file=dbshell_in)
print(f'execute {stored_proc}', file=dbshell_in)
print(f'spool off')

What do I have to do to really call pipe and dup2 before I do this stuff?  
I used to be a wizard at this stuff in perl, but I don't want to go back to 
perl... Python/Django is the world and anything more than that and SQL is 
overkill for the backend and one more thing to learn (except maybe invoking 
all of this stuff from Apache Airflow).

-- 
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/4aedb216-427d-427b-86e2-3d307cb4ee3fn%40googlegroups.com.


dumpdata - output file not compressed

2021-08-14 Thread Dan Jacob

The dumpdata command does not appear to be doing any compression. This is 
using Django 3.2.6 running in a Docker container with the 
python:3.9.6-buster image. 

Given the command 

> ./manage.py dumpdata myapp.MyModel -o myfixture.json.gz --traceback 

I would expect the file myfixture.json.gz to be compressed in gzip format. 
Instead a plain uncompressed JSON file is generated without any errors. 

-- 
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/cf61cc36-4eb8-4136-90a3-a7447a7aa984n%40googlegroups.com.


How to create a user to user message system using Django Rest frame work

2021-03-14 Thread DAN DIGNITY
I am trying to create a private messaging system using the Django Rest 
framework. It doesn't have to be like a live chat, just have an inbox and 
be able to respond, a simple thing like 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/8e58fd1d-997b-4089-bfe3-fd99ee05cec4n%40googlegroups.com.


Re: Scaling dumpdata and loaddata

2020-10-22 Thread Dan Davis
I have found an answer of sorts in a previous thread.  Fred says:

> Just for the follow-up, I ended up using pgloader and after some argument 
tweaking, it worked. Cheers.
On Thursday, October 22, 2020 at 6:48:57 PM UTC-4 Dan Davis wrote:

> dumpdata and loaddata work for me on some smaller applications, but I am 
> wondering whether any of you have strategies to scale it up to more data.  
> My DevOps doesn't really give developers access to much - not even RDS 
> snapshots.  The larger applications have written some logic to move data, 
> but maybe there is a solution.

-- 
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/f5642d06-93b9-4eba-a251-eec7a7d038adn%40googlegroups.com.


Scaling dumpdata and loaddata

2020-10-22 Thread Dan Davis
dumpdata and loaddata work for me on some smaller applications, but I am 
wondering whether any of you have strategies to scale it up to more data.  
My DevOps doesn't really give developers access to much - not even RDS 
snapshots.  The larger applications have written some logic to move data, 
but maybe there is a solution.

-- 
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/2a8dc211-d9b6-4e27-8593-e2ba17343a69n%40googlegroups.com.


Expire session after N minutes of inactivity

2020-07-14 Thread Dan Davis
Does anyone know of a django pypi package that implements something like 
this so that I can steal the code?  I know I need to think about "what does 
inactivity mean" in the era of SPA and Ajax, but a module could save me 
some time.

-- 
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/5150060e-5795-4ed4-bd13-863237553b29o%40googlegroups.com.


Re: connection queries_log when DEBUG is False

2020-07-08 Thread Dan Davis
Answering my own question:

The queries_log is cleared when Django begins processing a new request in 
django/db/__init__.py:

# Register an event to reset saved queries when a Django request is started.
def reset_queries(**kwargs):
for conn in connections.all():
conn.queries_log.clear()


signals.request_started.connect(reset_queries)


On Wednesday, July 8, 2020 at 7:03:48 PM UTC-4, Dan Davis wrote:
>
> This has to do with Django internals, but is nonetheless a user question.
>
> Various packages force_debug_cursor as illustrated in  
> https://www.webucator.com/blog/2015/08/python-clocks-explained/.
> Other packages monkey patch the cursor wrapper to be used.
>
> Does Django clear connection.queries_log after each request, or only if 
> the connection is cleaned up?
>
> Thanks, anyone,
>
> -Dan
>

-- 
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/b1223c3d-7a20-41a9-85f0-04ce06d87cf9o%40googlegroups.com.


connection queries_log when DEBUG is False

2020-07-08 Thread Dan Davis
This has to do with Django internals, but is nonetheless a user question.

Various packages force_debug_cursor as illustrated in  
https://www.webucator.com/blog/2015/08/python-clocks-explained/.
Other packages monkey patch the cursor wrapper to be used.

Does Django clear connection.queries_log after each request, or only if the 
connection is cleaned up?

Thanks, anyone,

-Dan

-- 
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/3325c5b4-8a2e-4db3-9d13-9ca6c7f93d82o%40googlegroups.com.


Re: POSTGRES CONNTECTION TIMEOUT WHEN USING AN API

2020-07-06 Thread Dan Madere
Sounds like nginx is timing out waiting for Django, due to the slow query. 
You can set proxy_connect_timeout and proxy_read_timeout in your nginx 
config to allow it to wait longer. Another approach would be to optimize 
the SQL query and add indexes, to have the query run faster and not cause 
the timeout.

Dan

On Monday, July 6, 2020 at 9:24:48 AM UTC-4 sunne...@gmail.com wrote:

> I get this error from my postgresql log also : could not send data to 
> client: Broken pipe
> *AJAYI Sunday *
> (+234) 806 771 5394 <+234%20806%20771%205394>
> *sunne...@gmail.com*
>
>
>
> On Mon, Jul 6, 2020 at 2:06 PM Sunday Iyanu Ajayi  
> wrote:
>
>> I have a database sql function that I am running fine when on the 
>> database but once i link the output via an api I created  and test via 
>> postman, I get Nginx 502 error and on my postgresql log I get : Çonnection 
>> Timeout error.
>>
>> The sql db function link to a foreign table and pulls some data (between 
>> 500-2000 rows)
>>
>> Please how can I fix this?
>>
>>
>> *AJAYI Sunday *
>> (+234) 806 771 5394 <+234%20806%20771%205394>
>> *sunne...@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/9a815404-3c51-4a1f-b85d-ba6886dfc9a0n%40googlegroups.com.


Re: Django ContentTypes required?

2020-07-06 Thread Dan Madere
I agree that it should work. Django uses ContentType in the admin and user 
authentication, but you mention that you have removed these from 
INSTALLED_APPS, so I don't get it. I'd try clearing .PYC files first. Then 
maybe a sanity check.. double check what settings file you're actually 
using, and if INSTALLED_APPS contains what you expect.

Dan

On Monday, July 6, 2020 at 2:33:19 PM UTC-4 jzt...@gmail.com wrote:

> Hello,
>
> I am not using any of the ContentType relations, etc right now in my 
> Django 2.12 Python 3.6 application, am I able to run the application 
> without having django.contrib.contenttypes in the INSTALLED_APPS? Is there 
> a piece I am not understanding that Django uses it for in the background?
>
> I thought I had it working with it removed but I am getting:
>
> Model class django.contrib.contenttypes.models.ContentType doesn't declare 
> an explicit app_label and isn't in an application in INSTALLED_APPS.
>
> I have nothing in the INSTALLED_APPS except my apps and:
>
> 'django.contrib.staticfiles',
> 'rest_framework',
>
> Was trying an attempt where I avoided migrating contenttypes into a legacy 
> database.
>
> Best,
>
> JJ
>

-- 
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/cbce5c34-652a-42ac-84b5-0c881abce893n%40googlegroups.com.


Re: Django queryset filtering

2020-06-26 Thread Dan Madere
I'd make two queries. One to see which businesses currently have active 
licenses, then a second to get the expired licenses, excluding the 
businesses from the first query. Here's some example code, assuming the 
LicenseIssue model has a "business" foreign key field:

*active_business_ids = 
LicenseIssue.objects.filter(expiry_date__gt=TODAY).values_list('business_id', 
flat=True).distinct()*
*expired_licenses = 
LicenseIssue.objects.filter(expiry_date__lte=TODAY).exclude(business_id__in=active_business_ids).order_by('-expiry_date')*

On Wednesday, June 24, 2020 at 6:25:18 PM UTC-4 mtp...@gmail.com wrote:

> I have a queryset that returns all the expired licenses objects as shown 
> below.
>
>
> *qs = 
> LicenseIssue.objects.filter(expiry_date__lte=TODAY).order_by('-expiry_date')*
> 
>
> Here is my situation:
> There exists multiple issued licenses of different businesses for year 
> 2020 and their  previous issued licenses for the for year 2019, 2018 and so 
> on. The above queryset results to listing all expired licenses though I'd 
> like to make it possible if there exists issued licenses for year 2020 
> their previous issued licenses should not appear in the expired licenses 
> queryset. Please advise on 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/9a0c6125-efc6-4127-98cc-30ffadd01195n%40googlegroups.com.


Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Dan Madere
I don't know of a way to configure the admin do that, but one solution 
would be to use signals to notice when one-way records are created, then 
automatically create the record for reverse relationship. We need to notice 
when records are deleted as well. This approach would allow showing one 
inline that shows the combined results. I was able to get it working with 
this: https://gist.github.com/dgmdan/e7888a73c14446dccd7ad9aaf5055b10
Hope this helps!

On Thursday, June 25, 2020 at 1:53:45 PM UTC-4 jes...@gmail.com wrote:

> After reviewing the tests, I think I now understand what is going on.
>
> Basically, for symmetric ManyToManyField, Django creates entries for both 
> directions automatically if the correct interface is used. From the test 
> models:
>
> class PersonSelfRefM2M(models.Model):
> name = models.CharField(max_length=5)
> sym_friends = models.ManyToManyField('self', 
> through='SymmetricalFriendship', symmetrical=True)
>
>
> class SymmetricalFriendship(models.Model):
> first = models.ForeignKey(PersonSelfRefM2M, models.CASCADE)
> second = models.ForeignKey(PersonSelfRefM2M, models.CASCADE, 
> related_name='+')
> date_friended = models.DateField()
>
>
> And the tests:
>
> def test_self_referential_symmetrical(self):
> tony = PersonSelfRefM2M.objects.create(name='Tony')
> chris = PersonSelfRefM2M.objects.create(name='Chris')
> SymmetricalFriendship.objects.create(
> first=tony, second=chris, date_friended=date.today(),
> )
> self.assertSequenceEqual(tony.sym_friends.all(), [chris])
> # Manually created symmetrical m2m relation doesn't add mirror entry
> # automatically.
> self.assertSequenceEqual(chris.sym_friends.all(), [])
> SymmetricalFriendship.objects.create(
> first=chris, second=tony, date_friended=date.today()
> )
> self.assertSequenceEqual(chris.sym_friends.all(), [tony])
>
> def test_add_on_symmetrical_m2m_with_intermediate_model(self):
> tony = PersonSelfRefM2M.objects.create(name='Tony')
> chris = PersonSelfRefM2M.objects.create(name='Chris')
> date_friended = date(2017, 1, 3)
> tony.sym_friends.add(chris, through_defaults={'date_friended': 
> date_friended})
> self.assertSequenceEqual(tony.sym_friends.all(), [chris])
> self.assertSequenceEqual(chris.sym_friends.all(), [tony])
> friendship = tony.symmetricalfriendship_set.get()
> self.assertEqual(friendship.date_friended, date_friended)
>
>
> So the tests show that the add() method needs to be used to create both 
> sides of the relationship. I assume that the Admin page does not use the 
> add method, but creates the intermediate entries which would require both 
> the be added for each entry.
>
> Is it possible to configure the Admin models to use add() or to create 
> both directions automatically?
>
> 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/b8e0927d-6079-4a0a-91db-044d6f393998n%40googlegroups.com.


Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Dan Madere
I tried out the example code, and can replicate this. What's interesting is 
that if I try removing the ContactConnection model, and the "through" 
attribute, this allows Django to create the intermediate table on its own, 
and then your get_connections() method works as expected! It seems like 
using a custom through table is causing this somehow. I haven't found a fix 
but will keep looking.

On Thursday, June 25, 2020 at 8:52:47 AM UTC-4 jes...@gmail.com wrote:

> Mike, Thanks for your suggestions. 
>
> Just a stab in the dark - have you tried giving from_contact a 
>> related_name? 
>>
>
> Yes, I have tried a few different combinations of providing a single 
> related_name and various naming conventions when providing related_name on 
> both ForeignKey fields without success.
>  
>
>> Another stab ... maybe you could just display the 
>> ContactConnectionAdmin(admin.ModelAdmin) with model=ContactConnection? 
>>
>>
> Yes, adding a ModelAdmin for the through table will show all of the 
> relationships, but it still requires searching both ForeignKey fields to 
> capture all of the relationships, regardless of which Contact hey were 
> created on.
>
> Workarounds are to add two Inlines, one for each through table foreign 
> key, or perform a compound query to combine the two results. I just figured 
> that since the capability was added in Django 3.0, that the symmetric 
> queries were included as well. My guess is that it is possible with the 
> correct configuration / naming conventions. I'll dive into the code to see 
> if anything pops up.
>
> 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/7ee482c1-60ea-482f-8ffb-5f71ff92a1edn%40googlegroups.com.


Re: Updating the concept of Django

2020-06-15 Thread Dan Davis
Since Django is written in Python, you should know enough Python to 
understand it do really good code. If you are well versed in other computer 
languages, I recommend the book Fluent Python. It is not for newbies to 
programming however.

I find the Django Tutorial from the project itself, 
https://docs.djangoproject.com/en/3.0/intro/tutorial01/, very helpful and 
reasonably easy to follow.



On Monday, June 15, 2020 at 9:21:51 AM UTC-4, temitope iyanoye wrote:
>
> Hi everyone, I’m a newbie and I understand the basic syntax of python to 
> some extents, I have a thing for web development so I chose to learn Django 
> for backend dev but for like a week the whole thing looks strange to me, I 
> following YouTube tutorials but am not getting it yet, so please I need 
> suggestions, do I need to go back to python syntax from beginner to 
> intermediate level? What are those things I need to know that would help me 
> demystify the mystery behind Django, this is what am passionate about but 
> am somehow confused at the moment. 
>
> Thanks in anticipation. 

-- 
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/294f123e-a99c-4dc9-9d59-8bee3ab3addco%40googlegroups.com.


Path parameters and security scanners best practice

2020-06-15 Thread Dan Davis
I have an odd question.  When I have a path parameter that is validated to 
be alphanumeric, and a security scanner sends a non-alphanumeric value, 
Django properly validates and then returns 404.   However, this gives the 
security scanner the mistaken impression that there is some some sort of 
security problem (it isn't very smart).

Is there an option I can give to Django to say that if an URL pattern 
matches but the path parameter does not match, it should return a different 
sort of 400 error?

Thanks,

-Dan

-- 
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/133b7cb9-b5fc-4758-9a98-595d99cce9dfo%40googlegroups.com.


Re: Django-React with webpack or create-react-app

2020-03-09 Thread Dan Davis
If you wish to use cache busting, or create-react-app sets that up by 
default, you can configure some special logic for loading the bundles.
Mine is per-process based, and assumes that since the bundle will be 
cached, it reasonable not to create a new static file loader:

https://gist.github.com/danizen/8d41f63c7bb4e35793a8e5d4d41fac16

On Saturday, March 7, 2020 at 5:43:06 AM UTC-5, Ronit Mishra wrote:
>
> You don't have to create a folder named 'build', `create-react-app` 
> provides you with a separate source and build directory. Once you've your 
> code ready, you just need to run `npm run build` and your source code would 
> be translated into a production-ready code in the build directory. 
>
> You can easily update any default scripts that `create-react-app` 
> provides, such as start, test or build to override the default behavior.
>
> Honestly, just dive into the documents and start getting your hands dirty 
> with coding.
>
> And If you're an advanced developer who understands working with 
> production build, then it won't be a challenging task for you to later 
> explore more configurations or packaging options for your React 
> application. 
>
> On Sat, Mar 7, 2020 at 3:30 PM Alaydyn Gholechragh  > wrote:
>
>> thanks for answer  but I think to build react from  'create-app-react' 
>> create a folder with name  'build' and I can't change it and config is hard 
>> for work them together
>>
>> On Saturday, March 7, 2020 at 1:07:44 PM UTC+3:30, Ronit Mishra wrote:
>>>
>>> Start with `creat-react-app`.. webpack and bundler are task runners that 
>>> bundle your code for production. `creat-react-app` has a bundler program 
>>> inbuilt. Once you're comfortable with React and you're easily able to 
>>> communicate between Django and React components, then you might wanna look 
>>> into improvising your production build for your react code. You should 
>>> explore external bundlers for your React application after that. 
>>>
>>> On Sat, Mar 7, 2020 at 2:52 PM Alaydyn Gholechragh  
>>> wrote:
>>>
 hi 
 I want to use Django and react together but there is one problem , I 
 don't know it is good I make react application with  "webpack and bundler 
 "  or  "creat-react-app "??

 which is better ???

 -- 
 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/e813b99f-1ec4-456a-8110-09be009ff4d3%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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/993da381-f9ce-4e70-a1f8-209be6585329%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/40d29fcb-2bc1-476a-b098-ad66fba2d2bd%40googlegroups.com.


CONN_MAX_AGE and Oracle

2020-03-09 Thread Dan Davis
One or my power users claims that CONN_MAX_AGE is not working properly with 
Oracle.  I've written a minimal backend to wrap the standard Oracle 
backend, and to log connection creation. I am seeing multiple connections 
sometimes in the same second with a CONN_MAX_AGE of 300.  I am currently 
attempting to discipline Phusion Passenger to use the same 2 processes for 
the length of the test, with no growth and shrinking, and we will see at 
this point.

Has anyone else seen similar issues, with Oracle especially.

-- 
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/d11424a8-7e3d-4ccd-9195-57c49b125cd9%40googlegroups.com.


AdminEmailHandler logging filter, formatting, and false positives

2020-01-16 Thread Dan Davis
My team uses the django.utils.log.AdminEmailHandler, but along with a 
filter I wrote - infrastructure.log.SkipNessusScanFilter

So, the security team moved its Tenable Nessus scanner from on-premise to 
the cloud (for public sites), and as usual, the scanner is misconfigured to 
use an IP address rather than the service URL, so that they are testing 
Django's built-in security (ALLOWED_HOSTS) rather than anything more.
But since they are coming from AWS IPs now, my whitelist of scan IPs is no 
longer effective, and we again receive something like 5000 emails for a 
typical scan.

While I can fix that by filtering out instead exceptions about 
SuspiciousOperation, I have a bigger problem - we will be going to cloud, 
and AWS SES charges $0.10 for each 1000 emails.  Even though a 
misconfiguration would only mean $1.50 or so in charges, a targeted DoS 
attack (against a government site), could be a much more expensive 
proposition.

While adding a filter for maybe django.core.exceptiopns.SuspiciousOperation 
or django.db.utils.OperationalError should be easy, achieving the rich 
formatting while putting the data into an ORM model (with a CLOB) would 
consume a lot more development cycles.   Maybe there is an existing Django 
package that already addresses these issues?Maybe others have home 
grown solutions they can propose?

Thanks in advance,

-Dan


-- 
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/d5a7bd5c-2ad2-467a-a6ba-e6b6aaa50ab1%40googlegroups.com.


Re: Making tests fast

2019-09-03 Thread Dan Davis
I will just use fixtures, natural-keys, and an in-memory database.

-- 
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/a4601657-35bf-445a-a972-2abda5ddabc3%40googlegroups.com.


Making tests fast

2019-09-03 Thread Dan Davis
I'm wondering how to make my tests fast while also having a lot of data 
defined in the models.  
This project is already using sqlite3 and the tests are single-threaded.

My ideas are:

   - Specify a different sqlite3 file and keepdb for different tests - 
   presumably with @override_settings
   - Do something to copy this data into memory 
   (see 
https://stackoverflow.com/questions/3850022/how-to-load-existing-db-file-to-memory-in-python-sqlite3)
 
   - I suspect Django already supports this, but I don't see where 
   _clone_test_db is called.

I am loathe to use modelmommy and/or factoryboy because they are simply a 
bit harder to use.   I'd rather use dump data/load data with :memory 
database.

   

-- 
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/b22204f4-85db-4eb9-9a53-adca0dea269c%40googlegroups.com.


Re: Channels: launching a custom co-routine from SyncConsumer

2019-08-28 Thread Dan Merillat
On 8/15/19 11:10 PM, Andrew Godwin wrote:
> SyncConsumer isn't async - it runs inside a separate synchronous thread.
> You'll need to get the event loop from the other thread and use
> call_soon_threadsafe instead!

Sorry for the delay in getting back to you, it took me a while to go
through the different layers to find the appropriate event loop.  Thank
you for the pointer, it got me headed down what I hope is the right path.

SyncConsumer is based on AsyncConsumer, with dispatch() ultimately
wrapped in SyncToAsync via DatabaseSyncToAsync.  SyncConsumer should
have a guaranteed SyncToAsync instance with threadlocal on the executor
thread, because it is running inside a SyncToAsync to begin with.  Is
that correct?

The following "works" as part of my sync consumer but I'm not positive
what the sharp edges are going to be:

 def start_coroutine(self, coroutine):
 loop = getattr(SyncToAsync.threadlocal, "main_event_loop", None)
 if not (loop and loop.is_running()):
 loop = asyncio.new_event_loop()
 asyncio.set_event_loop(loop)
 loop.call_soon_threadsafe(loop.create_task, coroutine())

Where the coroutine is anything awaitable.

The documentation at
https://channels.readthedocs.io/en/latest/topics/consumers.html goes
into the opposite scenario, using Synchronous functions such as django
ORM from an AsyncConsumer, but would really benefit from an example of
something like an idle timeout implementation for a SyncConsumer.

-- 
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/8bb3ac80-3b70-e8f6-697a-af5d86086612%40gmail.com.


Channels: launching a custom co-routine from SyncConsumer

2019-08-14 Thread Dan Merillat

I have an application that's 99% using the ORM and database work so it is 
using SyncConsumer.
However, I have one minor part that needs to use a timer, and I cannot get 
it to work for the life of me.

In an AsyncConsumer, I can use asyncio.ensure_future(self.coroutine()) to 
start a timer.

In sync consumer, nothing I've tried works:

class TestConsumer(SyncConsumer):

async def timer_task(self):
print(f'timer task: {self.counter}')
asyncio.sleep(1)
self.counter += 1
print(f'timer expired: {self.counter}')

def connect(self):
self.counter = 0

self.timer = asyncio.ensure_future(self.timer_task())
# ERROR:daphne.server:Exception inside application: There is no 
current event loop in thread 'ThreadPoolExecutor-0_20'.

self.timer = async_to_sync(asyncio.ensure_future)(self.timer_task())
# ERROR:daphne.server:Exception inside application: You cannot use 
AsyncToSync in the same thread as an async event loop - just await the 
async function directly.

I thought SyncConsumer was async under the hood, but I have no idea how to 
leverage 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/6fe7ad95-1bdb-4de2-9ed2-8c566ba27939%40googlegroups.com.


Re: Docker: NGINX, Postgres, Django, Static, Media Files

2019-07-14 Thread Dan Tagg
+1 for cookiecutter

On Sun, 14 Jul 2019 at 20:53, hunter.cur...@gmail.com <
hunter.cur...@gmail.com> wrote:

> Probably the easiest way to do what you are looking for is to use
> cookiecutter-django: https://github.com/pydanny/cookiecutter-django
>
> They are now using Caddy for the web server but if you look in earlier
> versions there are good examples of how to use Nginx if that is your
> preference.
>
> On Sunday, July 14, 2019 at 6:48:09 AM UTC-6, Sebastian Jung wrote:
>>
>> Hello,
>>
>> i want i complete ready Docker Container for production that accept all
>> Host of wourld on port 80. I want a docker container for Nginx another for
>> Postgres another for Django and static Files and another container for
>> Media Files. I have not enought experience to get a manual like this:
>> https://github.com/Pawamoy/docker-nginx-postgres-django-example
>>
>> Can someone give me a package to download?
>>
>> Regards
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7f79b866-a45f-4f48-89a4-4c6d79d22bfe%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY6o_g6D_68%2BHfphLHVw67FGfABHFQC5mg%2BLO%3DPMk_5Wnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Package that helps update only changed fields

2019-06-24 Thread Dan Davis
Thanks, I wrote a mixin class for most of my forms that works a lot like 
this, although it combines self.changed_fields and self.model._meta.fields 
to discover which fields to update, rather than the two stages you have 
above.  

I discovered when trying to generalize this mixin that some of my forms are 
too complicated for this to be a part of Django itself.  A ModelForm may 
have non-model fields whose initial value is computed from other models in 
__init__ or using a queryset with annotations.  I've found this to be 
easier in many cases that dealing with formsets.

So, if your save method already looks something like this:

def save(self, commit=True):
with transactions.atomic():
instance = super().save()
instance.relation.fubar = self.changed_data['relation_fubar']
instance.relation.save()

Well, you might as well just figure out update_fields in that form on its 
own.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0310b0a5-05f2-4faf-8c69-a911ed82976f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: architecture for Blue/Green deployments

2019-06-24 Thread Dan Davis
A related discussion on django-developers has turned up this module, 
written by one of the participants in the discussion there:

https://github.com/aspiredu/django-safemigrate


>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b9dae54-adcb-46eb-b016-5ddb4215605c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: call a view several times in another view

2019-06-18 Thread Dan Davis
I don't think it is a a good idea to call a view from another view, but if 
you have an underlying function that used to be a view, and you want to 
call it to do the secondmethod, then that's a good way to begin to do more 
with Django.   Another good way is to practice using the generic 
class-based views until they begin to make sense.

One of my developers used to "assume" the request.method was 'POST' in one 
function, called search_result, and she also had a search_request method 
which was also a view:

 def search_request(request):
 assumes GET ...

 def search_result(request):
 assumes POST ...

I created a new function search_view(), and made that the view, the other 
two are just functions:

 def search_view(request):
 if request.method == 'GET':
  return search_request(request)
 elif request.method == 'POST':
  return search_result(request)
 else:
  return HttpResponseNotAllowed();


On Tuesday, June 18, 2019 at 9:29:44 AM UTC-4, Sebastian Jung wrote:
>
> Hello,
>
> I have a view like this:
>
> def secondmethod(request,entry):
>
> if request.method='POST':
>
>   return request.POST.get('selection')
>
>render(request,'eintrag.html','entry':entry)
>
>
> def test(request):
>
> if request.method='POST':
>
>   queryresult = model.objects.all()
>   for entry in queryresult:
>  eintrag = secondmethod(request,entry)
>
>render(request,'homepage.html')
>
>
> This is a easy example. I call the view test, in for loop i want to call 
> the view secondmethod several times. In function secondmethod eintrag.html 
> render and the selection return back to test. Then next row from 
> queryresult is submit to secondmethod. Is this possible?
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6784c0d-28b4-4b34-8b5c-2ace163199e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Saving OnetoOne Field

2019-06-18 Thread Dan Davis

Shreejith Unnikrishnan Nair,

Is this in a ModelForm or the intsance itself?   That would help to give 
guidance...


On Tuesday, June 18, 2019 at 11:40:53 AM UTC-4, Lutalo Bbosa joseph wrote:
>
> A foreignKey with aunique attribute is same as using a OnetoOneField so 
> either can suit your needs
>  and please be clear about saving 
>
> On Tue, Jun 18, 2019 at 1:56 PM 'Shreejith Unnikrishnan Nair' via Django 
> users > wrote:
>
>> I'm beginner , so i need help 
>> Please suggest me the best practice to save the OnetoOneField in django.
>>
>> -- 
>> Thanks & Regards,
>> Shreejith
>>
>> -- 
>> 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 post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CADGnmLwY8wQmZ%2BOh40rG_%3DRiENRK84JWQ1v2hy2y3Wk3OnHsUA%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7091497b-8944-4f28-8806-c4c71a1f509d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Package that helps update only changed fields

2019-06-18 Thread Dan Davis
So, I recently observed that a Django ModelForm updates all columns when it 
is updating a model instance. This is appropriate for a typical situation 
where Django is also in control of the schema.
I also see that you can control this behavior by passing update_fields 
<https://docs.djangoproject.com/en/2.2/ref/models/instances/#saving-objects> 
to the save method, in a particular form:

self.instance.save(update_fields=self.changed_data)

I have some complicated forms that have non-model fields and many-to-many 
fields mixed in there.   I'm wondering whether there is a module for Django 
out there that gives me some base ModelForms that do not update all fields, 
but only changed fields.  I am asking because I don't want to work hard to 
handle corner cases if there's something already out there.   What I 
already have is hard-coded to the form where I've made this change to do 
only a limited update.

Thanks,

-Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c267866-3b46-4c20-a7a2-03cf581a5e98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2019-06-05 Thread Dan Davis
>
> Are you sure?
> My (possibly flawed) understanding is that if you can make the change in
> a single transaction, no-one else can see what is happening until it is
> committed. Effectively that would be an instantaneous change.
> Depending on your data architecture you might need to make some parts
> read-only for the 30 minutes prior to committing.

The transaction can be atomic if it is a database such as PostgreSQL that
offers DDL changes in a transaction.   The issue is that rather than
updating the code for the web application in place, and then running
migrations, my CI/CD pipeline will instead bring up an entirely new set of
servers.   This makes a more isolated change to the environment, and
deployment also will take care of OS patching and such, but the old web
servers will still be online and querying the database.   They may will be
querying a column that no longer exists, which is a form of "Read after
Write" synchronization problem.

I think with an alternative CI/CD, in the cloud or elsewhere, this would
not be an issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYbMEJ4k43%2BjxnSOojOgTMO9Y6%3Dc5W2DCrCWrNnsRMuEeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2019-05-22 Thread Dan Davis
Sure - setting it up is easy.   There are hard questions about database 
mutations however.   If you drop column bar from table Fubar, then the old 
code is still querying for buth Fu and Bar:

SELECT id, fu, bar FROM fubar 

On-premise, this is the case for maybe 10 seconds, tops.   In the cloud, 
this could be the case for 30 minutes.

We've decided that this is the developers responsibility, and not the 
responsibility of DevOps CI/CD, just like the developer needs to either use 
cache-busting techniques when changing JS and CSS, or educate his users to 
press Shift-F5 when things go wrong.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6cd917c1-814d-4839-9849-898ff03618c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Question on logging best practices and ALLOWED_HOST

2019-05-22 Thread Dan Davis
*First Question - How valuable is the check on ALLOWED_HOST?   *

How many folks out there simply have settings:

ALLOWED_HOSTS = ['*']


*Second Question - What is the best practice for enriching the log record?*

On-premise, we've struggled with the interaction of the AdminEmailHandler 
and security scans:

'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false', 
'skip_nessus_scan_requests'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},

Now we want to go farther and divert logs originating from the security 
scanner to a different log.

That means that some variant of this code would run again and again:


class SkipNessusScanFilter(logging.Filter):
"""
Avoids a trace back for requests coming from a NESSUS scan.  Depends on 
NESSUS_SCAN_IPS.
"""
def filter(self, record):
request = getattr(record, 'request', None)
if request and hasattr(request, 'META') and 
request.META.get('REMOTE_ADDR') in NESSUS_SCAN_IPS:
return False
return True



I want to centralize the check and make it more performant.   Is there a 
better place to enrich the log record than when the filter runs?

def is_nessus_scan(record):
is_nessus_scan = getattr(record, 'is_nessus_scan', None)
if is_nessus_scan is None:
request = getattr(record, 'request', None)
is_nessus_scan = (request 
  and hasattr(request, 'META') 
  and request.META.get('REMOTE_ADDR') in 
NESSUS_SCAN_IPS)
setattr(record, 'is_nessus_scan', None)
return is_nessus_scan


class SkipNessusScanFilter(logging.Filter):
"""
Avoids a trace back for requests coming from a NESSUS scan.  Depends on 
NESSUS_SCAN_IPS.
"""
def filter(self, record):
return is_nessus_scan(record)


class RequireNessusScanFilter(logging.Filter):
"""
Diverts nessus logging to another file.   Depends on NESSUS_SCAN_IPS.
"""
def filter(self, record):
return not is_nessus_scan(record)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52f30cdb-35f6-4251-95c7-46f97c3a2786%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Oracle ORA-03124 Two-task internal error

2019-05-08 Thread Dan Davis
Running my migrations with Django 1.11. (1.11.20), fails with the Oracle 
error ORA-03124 Two-task internal error.
I have tried this with Oracle instantclient 12.1.0.1 and 18.5.0.0., and 
several other versions of cx_Oracle.

There are no migrations to make, but I get the following error, always in 
the same place, the post_migrate handler for contentypes, after auth.



manage.py migrate -v 3
[2019-05-08 17:23:23,792] INFO nlm.occs.dbp retrieved password for 
mplusmon_dev@medplus_dev
Operations to perform:
  Apply all migrations: auth, casauth, contenttypes, django_cas_ng, 
mplusmon, sessions
Running pre-migrate handlers for application mplusmon
Running pre-migrate handlers for application auth
Running pre-migrate handlers for application contenttypes
Running pre-migrate handlers for application sessions
Running pre-migrate handlers for application django_filters
Running pre-migrate handlers for application django_cas_ng
Running migrations:
  No migrations to apply.
Running post-migrate handlers for application mplusmon
Running post-migrate handlers for application auth
Traceback (most recent call last):
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\backends\utils.py",
 
line 64, in execute
return self.cursor.execute(sql, params)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\backends\oracle\base.py",
 
line 497, in execute
return self.cursor.execute(query, self._param_generator(params))
cx_Oracle.DatabaseError: ORA-03124: two-task internal error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\davisda4\workspace\mplusmonitor\manage.py", line 15, in 

execute_from_command_line(sys.argv)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\__init__.py",
 
line 364, in execute_from_command_line
utility.execute()
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\__init__.py",
 
line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\base.py",
 
line 283, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\base.py",
 
line 330, in execute
output = self.handle(*args, **options)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\commands\migrate.py",
 
line 227, in handle
self.verbosity, self.interactive, connection.alias, 
apps=post_migrate_apps, plan=plan,
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\sql.py",
 
line 53, in emit_post_migrate_signal
**kwargs
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\dispatch\dispatcher.py",
 
line 193, in send
for receiver in self._live_receivers(sender)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\dispatch\dispatcher.py",
 
line 193, in 
for receiver in self._live_receivers(sender)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\contrib\contenttypes\management\__init__.py",
 
line 119, in create_contenttypes
content_types, app_models = get_contenttypes_and_models(app_config, 
using, ContentType)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\contrib\contenttypes\management\__init__.py",
 
line 96, in get_contenttypes_and_models
for ct in 
ContentType.objects.using(using).filter(app_label=app_config.label)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\models\query.py",
 
line 250, in __iter__
self._fetch_all()
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\models\query.py",
 
line 1121, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\models\query.py",
 
line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\models\sql\compiler.py",
 
line 899, in execute_sql
raise original_exception
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\models\sql\compiler.py",
 
line 889, in execute_sql
cursor.execute(sql, params)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\backends\utils.py",
 
line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\backends\utils.py",
 
line 64, in execute
return self.cursor.execute(sql, params)
  File 
"C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\db\utils.py", 
line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File 

Re: Autoreloader looping Django 2.2

2019-05-01 Thread Dan
Hi Ramiro

Thanks for answering.

Tried stable 2.2.1 and it looks like it is working ok now.

The folder is a virtualbox shared folder, shared from an osx host.

Thanks for your help!

On Tuesday, April 30, 2019 at 12:33:58 AM UTC+2, Ramiro Morales wrote:
>
> Hi Dan,
>
> On Fri, Apr 26, 2019 at 11:00 AM Dan > 
> wrote:
>
>> Forgot to mention that this is on a mac osx host with ubuntu 16 
>> virtualbox guest, I'm not sure that has something to do with it?
>>
>> On Thursday, April 25, 2019 at 10:06:59 PM UTC+2, Dan wrote:
>>>
>>> I'm using Django 2.2 on a new project and suddenly the autoreloader is 
>>> looping when I change a file
>>>
>>>
>>> DEBUG:
>>>
>>>
>>> /urls.py. is_changed: False, is_new: True
>>>
>>> /urls.py previous mtime: None, current mtime: 1556221457.0
>>>
>>> /urls.py notified as changed. Signal results: [(>> translation_file_changed at 0x7fd933e05d90>, None)].
>>>
>>> /urls.py changed, reloading
>>>
>>> It says the file is new but it was just changed - it refers 
>>> to translation_file_changed but I have no translation files in my project.
>>>
>>>
>>> My project is on a virtualbox shared folder, if I start a new project 
>>> from scratch it works ok and previous versions of Django work fine.
>>>
>>>
>>> I tried using watchman + pywatchman and it doesn't seem to work at all, 
>>> I dont think it works with shared virtualbox folders. 
>>>
>>>
>>> Is there anyway I can get this working with 2.2 can I use the old 
>>> reloader or do I need to revert to 2.1?
>>>
>>
>>
> Can you try the stable/2.2.x git branch? it contains a couple of post-2.1 
> fixes to the reloading code which will get released as 2.2.1 in a few days 
> AFAIK..
>
> Also, is the folder  where urls-py is located shared between the host and 
> the VM in some way? What file system type is the host using?
>
> -- 
> Ramiro Morales
> @ramiromorales
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0f394562-5223-4cab-9125-e3e73a3dfc86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autoreloader looping Django 2.2

2019-04-26 Thread Dan
Forgot to mention that this is on a mac osx host with ubuntu 16 virtualbox 
guest, I'm not sure that has something to do with it?

On Thursday, April 25, 2019 at 10:06:59 PM UTC+2, Dan wrote:
>
> I'm using Django 2.2 on a new project and suddenly the autoreloader is 
> looping when I change a file
>
>
> DEBUG:
>
>
> /urls.py. is_changed: False, is_new: True
>
> /urls.py previous mtime: None, current mtime: 1556221457.0
>
> /urls.py notified as changed. Signal results: [( translation_file_changed at 0x7fd933e05d90>, None)].
>
> /urls.py changed, reloading
>
> It says the file is new but it was just changed - it refers 
> to translation_file_changed but I have no translation files in my project.
>
>
> My project is on a virtualbox shared folder, if I start a new project from 
> scratch it works ok and previous versions of Django work fine.
>
>
> I tried using watchman + pywatchman and it doesn't seem to work at all, I 
> dont think it works with shared virtualbox folders. 
>
>
> Is there anyway I can get this working with 2.2 can I use the old reloader 
> or do I need to revert to 2.1?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7b35e7bf-65cd-447c-84db-aafd1ba2fc45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Autoreloader looping Django 2.2

2019-04-25 Thread Dan
 

I'm using Django 2.2 on a new project and suddenly the autoreloader is 
looping when I change a file


DEBUG:


/urls.py. is_changed: False, is_new: True

/urls.py previous mtime: None, current mtime: 1556221457.0

/urls.py notified as changed. Signal results: [(, None)].

/urls.py changed, reloading

It says the file is new but it was just changed - it refers 
to translation_file_changed but I have no translation files in my project.


My project is on a virtualbox shared folder, if I start a new project from 
scratch it works ok and previous versions of Django work fine.


I tried using watchman + pywatchman and it doesn't seem to work at all, I 
dont think it works with shared virtualbox folders. 


Is there anyway I can get this working with 2.2 can I use the old reloader 
or do I need to revert to 2.1?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1e80c226-9091-4bf5-8b51-1059c6489bae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2019-03-04 Thread Dan Davis
Derek, it all depends on where you are.  I'm \at a government agency.  The
wait time to get an NFS directory (yup, really) where I can write my data
between multiple redundant web servers is weeks.  After that, there are
size and synchronization issues.   So, there are other reasons than table
design to consider.  After all, we don't do the work to put our tables in
1NF, 2NF, 3NF just because - we do it if our data is going to be used for
OLAP, but prefer less normalized structures for OLTP.

I just think it is interesting that the standard advice about files in the
database has to do with Django's standard operations, and maybe ignores the
realities on the ground for some developers.

On Mon, Mar 4, 2019 at 2:11 AM Derek  wrote:

> Just because something can be done, does not mean it should be done.
>
> I have always avoided putting large binary files into the DB - why?
> Primarily because the information in them is "dead" - very hard to search
> or filter, which rather defeats the point of using a DB.  Rather leave them
> on disc and add a pointer to each of them.  For one app, I did convert all
> the data in their files (typically Excel or PDF) into "raw text" and stored
> that text in the DB so it was, at least, searchable (but obviously not
> really viewable in that state).
>
> Also, a call like:
>
> ModelWithFileContents.objects.all()
>
> Can be quite overwhelming unless you know what you are doing; rather look
> to extract specific fields that you know you want to display/access.  I
> would imagine that the only time you are going to want to retrieve that
> BLOB (assuming you stick to your current design) is per individual record
> "on request".
>
>
> On Wednesday, 27 February 2019 03:18:00 UTC+2, Dan Davis wrote:
>>
>> For the group, the eventual culprit was not complicated.  It is a model
>> with a BinaryField that holds a file's contents. The Django documentation
>> advises against this, but why?   Well, on-premise with big-iron database
>> like Oracle, storing the file in the database is attractive.  So, what's
>> the problem?
>>
>>   ModelWithFileContents.objects.all()
>>
>> There you go, even if you are not using the file, its contents will be
>> fetched into memory.
>> The solution if it must be at the Django level is to use defer()
>> properly, and add it to the ModelManager.
>>
>> What I did is to make sure the developer *always* used a database view
>> that doesn't have the binary field for most operations.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/TZ682yh2QfE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b4e09fb6-b426-455d-aa3c-7191da404fc1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b4e09fb6-b426-455d-aa3c-7191da404fc1%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYastwDvy4RkVU0WLr_Hnvr5d09OiFi%2BmyW%2Bst9buyV7yA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Max function and grouping with Oracle

2019-02-26 Thread Dan Davis
> That is not the case on MySQL and PostgreSQL for. example.

+1 Insightful.

I'm still trying to get my Ops guys to let us drop and re-create databases 
for Postgres/MySQL.  They are very afraid to give that permission because 
they worry about production databases, and it is hard for them to manage 
grants one way for some databases and other ways for other databases.

So, a long way to go to PostgreSQL


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fbe34f45-8356-458a-b359-34dc043803e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2019-02-26 Thread Dan Davis
For the group, the eventual culprit was not complicated.  It is a model 
with a BinaryField that holds a file's contents. The Django documentation 
advises against this, but why?   Well, on-premise with big-iron database 
like Oracle, storing the file in the database is attractive.  So, what's 
the problem?

  ModelWithFileContents.objects.all()

There you go, even if you are not using the file, its contents will be 
fetched into memory.
The solution if it must be at the Django level is to use defer() properly, 
and add it to the ModelManager.

What I did is to make sure the developer *always* used a database view that 
doesn't have the binary field for most operations.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28092b88-46a3-4390-8efa-f54072b24768%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django logging multi-process safe?

2019-02-26 Thread Dan Davis
So, there are some issues in managing the files.   It is not very 12-factor 
to have the application worry about such things.

The issues with using a FileHandler or TimedRotatingFileHandler from 
multiple processes/kernel threads are less important, but still exist.  If 
a file is append-only, then write automatically does a seek to the end 
before writing, and python logging works hard to make sure this is a single 
write.   Practically, that means that a log write to a file is atomic if:

   - It's size is less than a page in the buffer cache (4k)
   - You are not using NFS as a target for logs

In the later case (NFS), the kernel *simulates* the atomic seek to the end 
and write.  So, if there are multiple writers across multiple servers, you 
are going to be screwed, but if each single server has its own file, and 
multiple processes are writing, then it is mostly going to be OK.

There may be some other potential pitfalls using rotating files, such as 
logging.handlers.TimedRotatingFileHandler.  Haven't analyzed that closely.

So, anyway, the most likely problem then is if the log entries get larger 
than 4k, which may not be very likely but is possible.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ebde5694-6494-497a-8873-a43f61872711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django command logging levels

2019-02-15 Thread Dan Davis
The common verbosity will be passed to the handler:

class Command(BaseCommand):
...
def handler(**kwargs):
 verbosity = kwargs['verbosity']


I tried to get clever once and not have **kwargs, but Django sends that 
common stuff, like '--settings", and it is good for me to pay attention.

OTOH, if you want to know whether this has anything to do with Python's 
logging module, it doesn't - that all depends on your settings file 
contents.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e6e1936a-d45d-4212-acfc-be79d2cb328a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Preparing for 2.2LTS - testing for Deprecation Warnings

2019-01-17 Thread Dan Davis
I will then try like this in my manage.py:

 if len(sys.argv)>1 and sys.argv[1] = 'test':
  warnings.filterwarnings(...)

Thanks,

-Dan

On Thu, Jan 17, 2019 at 1:08 PM Simon Charette  wrote:

> You can use the category kwarg of filterwarnings[0] to pass the Django
> deprecation
> warning classes.
>
> They can be found in the django.utils.deprecation module. (e.g.
> RemovedInDjango30Warning).
>
> Cheers,
> Simon
>
> [0]
> https://docs.python.org/3/library/warnings.html?highlight=filterwarnings#warnings.filterwarnings
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Urrwf66qv6A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/520cea1a-7df7-4060-a8b0-3d361473e7a5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/520cea1a-7df7-4060-a8b0-3d361473e7a5%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYaiD7Q0Y%3DppAqw6K22VsFPve%2BuL0Sb%3DOKaYHfR7Vnw58A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.2 alpha 1 released

2019-01-17 Thread Dan Davis
Now I see it...

On Thursday, January 17, 2019 at 11:31:24 AM UTC-5, Dan Davis wrote:
>
> Great - I want to add it to some tox tests that I only run on demand.   It 
> isn't yet on pypi, right?
>
> On Thursday, January 17, 2019 at 10:40:21 AM UTC-5, Carlton Gibson wrote:
>>
>> We've made the first release on the way to Django's next major 
>> release, Django 2.2! 
>>
>> With about two and a half months until the 
>> final release (scheduled for April 1), we'll need timely testing 
>> from the community to ensure an on time, stable release. 
>>
>> Check out the blog post: 
>>
>> https://www.djangoproject.com/weblog/2019/jan/17/django-22-alpha-1/
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1b855de7-eaea-4222-afc7-a6610aeb267a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.2 alpha 1 released

2019-01-17 Thread Dan Davis
Great - I want to add it to some tox tests that I only run on demand.   It 
isn't yet on pypi, right?

On Thursday, January 17, 2019 at 10:40:21 AM UTC-5, Carlton Gibson wrote:
>
> We've made the first release on the way to Django's next major 
> release, Django 2.2! 
>
> With about two and a half months until the 
> final release (scheduled for April 1), we'll need timely testing 
> from the community to ensure an on time, stable release. 
>
> Check out the blog post: 
>
> https://www.djangoproject.com/weblog/2019/jan/17/django-22-alpha-1/
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83b595a3-2e65-464c-8e06-2ce61d0d2535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Preparing for 2.2LTS - testing for Deprecation Warnings

2019-01-17 Thread Dan Davis
PYTHONWARNINGS=error is too much.

How can I call warnings.filterwarnings() to make all *Django* 
DeprecationWarnings into errors?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b01f54a-ebf1-4082-b205-b83491d9bab7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis
Eric, thanks for confirming.  I've written my share of logrotate.d files,
but I may push to do something else, like send them directly to
Elasticsearch with a delay of some sort.


On Fri, Dec 21, 2018 at 2:00 PM PASCUAL Eric  wrote:

> Hi,
>
>
> If you are running on a Linux system, you'd better using the standard
> stream logs and *logrotate* to manage file rotating.
>
>
> The later is the blessed tool for this kind of task, since it manages for
> free the compression of rotated files and removal of oldest ones if you
> want to.
>
>
> Regards
>
>
> Eric
>
>
> --
> *From:* django-users@googlegroups.com  on
> behalf of Dan Davis 
> *Sent:* Friday, December 21, 2018 5:55:35 PM
> *To:* Django users
> *Subject:* Re: Is Django logging multi-process safe?
>
> Looks like I should use a WatchedFileHandler and then have logrotate do
> the logging.   If the file pointer is moved by another process, then it
> will work.
> Does gunicorn patch this for me?   Will I be better off using syslog or
> something?
>
> On Friday, December 21, 2018 at 11:51:16 AM UTC-5, Dan Davis wrote:
>
>
> I just came across this:
>
>
> https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
>
> This suggests that log messages sent to a StreamHandler will be processed
> properly, but log messages sent to a standard
> logging.handlers.TimedRotatingFileHandler are not process safe.
>
> What sayeth the group?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1792c98-0373-42e6-93ac-8b0961ec83e6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b1792c98-0373-42e6-93ac-8b0961ec83e6%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/1E1MuO08okk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/AM6P193MB042177E51A91076EAC03931E8CB80%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM
> <https://groups.google.com/d/msgid/django-users/AM6P193MB042177E51A91076EAC03931E8CB80%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYY5_uOiwn7xZUSzqKA3AX6J0V8TPD%2BRRZ%2B%3DdS5OpixGcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis
Looks like I should use a WatchedFileHandler and then have logrotate do the 
logging.   If the file pointer is moved by another process, then it will 
work.
Does gunicorn patch this for me?   Will I be better off using syslog or 
something?

On Friday, December 21, 2018 at 11:51:16 AM UTC-5, Dan Davis wrote:
>
>
> I just came across this:
>
>
> https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
>
> This suggests that log messages sent to a StreamHandler will be processed 
> properly, but log messages sent to a standard 
> logging.handlers.TimedRotatingFileHandler are not process safe.
>
> What sayeth the group?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1792c98-0373-42e6-93ac-8b0961ec83e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis

I just came across this:

https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes

This suggests that log messages sent to a StreamHandler will be processed 
properly, but log messages sent to a standard 
logging.handlers.TimedRotatingFileHandler are not process safe.

What sayeth the group?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c141b58-ac35-450d-955b-7bddad0b3052%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Max function and grouping with Oracle

2018-11-26 Thread Dan Davis
Looks like there is no problem here.   Django groups by whatever is in the 
query, so that this would be done as follows:

Parent.objects.values('id').annotate(child_updated_timestamp=models.Max('child_updated_timestamp'))



On Monday, November 26, 2018 at 12:32:09 PM UTC-5, Dan Davis wrote:
>
> I have a parent model that has a relationship to some data that is 
> changing:
>
>
> class Parent(models.Model):
>  name = models.CharField(...)
>  created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
>  updated_timestamp = models.DateTimeField(auto_now=True, null=True)
>
>
> class Child(models.Model):
>  parent = models.ForeignKey(Parent, on_delete=models.CASCADE)
>  created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
>  updated_timestamp = models.DateTimeField(auto_now=True, null=True)
>
>
>
> I am trying to annotate a query with a Max updated_timestamp for the 
> children:
>
> Parent.objects.annotate(child_updated_timestamp=models.Max('child__updated_timestamp',
>  
> output_field=models.DateTimeField()))
>
>
> It seems like Oracle backend is attempting to GROUP BY every field in the 
> child model.
>
> Can anyone tell me whether they've seen anything like this and how to 
> constrain the GROUP BY?
>
> Thanks,
>
> -Dan
>
>
>  
> 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71f1bd0e-73e9-45ea-8c94-3d83e2015bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Max function and grouping with Oracle

2018-11-26 Thread Dan Davis
I have a parent model that has a relationship to some data that is changing:


class Parent(models.Model):
 name = models.CharField(...)
 created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
 updated_timestamp = models.DateTimeField(auto_now=True, null=True)


class Child(models.Model):
 parent = models.ForeignKey(Parent, on_delete=models.CASCADE)
 created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
 updated_timestamp = models.DateTimeField(auto_now=True, null=True)



I am trying to annotate a query with a Max updated_timestamp for the 
children:

Parent.objects.annotate(child_updated_timestamp=models.Max('child__updated_timestamp',
 
output_field=models.DateTimeField()))


It seems like Oracle backend is attempting to GROUP BY every field in the 
child model.

Can anyone tell me whether they've seen anything like this and how to 
constrain the GROUP BY?

Thanks,

-Dan


 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a41b74a-a51b-4282-b292-2e6a59fe1bd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Checking for reference leaks

2018-11-09 Thread Dan Davis
So, my application apparently is the largest on our Django servers.   This 
doesn't mean that a reference leak exists, but it could mean that a 
reference leak exists.  I've been trying to find some generalizable way to 
search for such a problem.  I have difficulties drawing help from within 
the organization, because I am one of the two most expert with 
Python/Django.

I've written a "leak checking WSGI middleware", hoping to force Django to 
serialize completely.   It hasn't worked, really.

Can someone review this gist and suggest any changes:

https://gist.github.com/danizen/d410c7ed2dc09be1b0e18dcd9626f4e1



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e257b910-5ad1-434a-888a-0d29b50daf64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2018-11-06 Thread Dan Davis
This will likely do it - tracking as a django middleware, I suspect too
much will still be lazy:

https://pypi.org/project/wsgi-objgraph/

On Tue, Nov 6, 2018 at 6:39 PM Dan Davis  wrote:

> I am less certain this is the problem now.   It may simply be that my
> project is one of the larger on the server.   I did a quick audit, and
> although they are new to django, they either used connection.cursor() as a
> context manager, or called close explicitly.
>
> I will try to develop a middleware around pympler, tracemalloc, or
> objgraph.
>
> On Tue, Nov 6, 2018 at 6:23 PM Jason  wrote:
>
>> oh boy...  Good luck.
>>
>> you can use connection.cursor() as a context manager, which will clean up
>> connections after it exits.  You could grep the project for
>> connection.cursor and add the context manager.
>>
>>
>> how did none of the devs know to clean up after themselves, either with a
>> context manager or try-finally?
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/TZ682yh2QfE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/0b436954-3e31-4dd7-b1ae-2bf75d72f472%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/0b436954-3e31-4dd7-b1ae-2bf75d72f472%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYa88JNfCjkzfG1yastHs4T%2B96wC-i0iHaEwK%3DEmsnewxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2018-11-06 Thread Dan Davis
I am less certain this is the problem now.   It may simply be that my
project is one of the larger on the server.   I did a quick audit, and
although they are new to django, they either used connection.cursor() as a
context manager, or called close explicitly.

I will try to develop a middleware around pympler, tracemalloc, or objgraph.

On Tue, Nov 6, 2018 at 6:23 PM Jason  wrote:

> oh boy...  Good luck.
>
> you can use connection.cursor() as a context manager, which will clean up
> connections after it exits.  You could grep the project for
> connection.cursor and add the context manager.
>
>
> how did none of the devs know to clean up after themselves, either with a
> context manager or try-finally?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/TZ682yh2QfE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0b436954-3e31-4dd7-b1ae-2bf75d72f472%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFzonYbp7uaBuqtRuEt5y691Gzs0%2BbAJ5HkMYQkzFsRkgCPMNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: My developers have run amok

2018-11-06 Thread Dan Davis


On Tuesday, November 6, 2018 at 2:32:52 PM UTC-5, Jason wrote:
>
> refactor to use the ORM for those bits?  and implement a team styleguide 
> that says no direct connections unless its proven to work better?
>

I'm looking to identify the memory consuming bits to allow refactor.   Not 
a bad idea to do as you suggest.
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92937dab-1bcd-4985-840d-a8521b6a75f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


My developers have run amok

2018-11-06 Thread Dan Davis
My developers, who have come from ColdFusion, are fond of this:

cursor = connection.cursor()
cursor.execute()
data = [r for r in cursor]
return render(request, some_template_name, {'data': data})


The problem with this is that the database cursor reference will be leaked.

How do I integrate into a unit test environment (single-threaded, 
single-process), a check for no outstanding cursors?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f3a0682e-b36a-45ff-8f73-95628f231ebf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Left outer join rather than subquery.

2018-11-02 Thread Dan Davis
I'm going to answer myself in case anyone else looks for an answer to 
this.   In Django<2.x, the Subquery method I'm using is the best available.

In Django>=2, I can use the FilteredRelation with my annotation instead:

https://docs.djangoproject.com/en/2.1/ref/models/querysets/#django.db.models.FilteredRelation

The uniqueness constraint is actually already there in my actual model, and 
Django supports that through unique_together = ('journal', 'issn_type').

On Tuesday, October 30, 2018 at 2:05:58 PM UTC-4, Dan Davis wrote:
>
>
> Suppose you have a setup like this:
>
>  class Journal(models.Model):
>   title = models.CharField(max_length=200)
>
>
>  issn_type_choices = (
>  ('E', 'Electronic'),
>  ('P', 'Print'),
>  }
>
>  class Issn(models.Model):
>   ELECTRONIC='E'
>   PRINT='P'
>
>   journal = models.ForeignKey(Journal)
>   issn_type = models.CharField(max_length=1)
>   issn = models.CharField(max_length=10)
>
>
> I can express annotations to assure I get botha  Physical and Print ISSN:
>
> issn_p=Issn.objects.filter(issn_type='E', journal_id=OuterRef('id'))
> issn_e=Issn.objects.filter(issn_type='P', journal_id=OuterRef('id'))
> queryset = Journal.objects.annotate(issn_print=Subquery(issn_p), 
> issn_electronic=Subquery(issn_e)).filter(issn_print__isnull=False, 
> issn_electronic__isnull=False)
>
>
> However, is there anyway for me to express two OneToOneField relationships 
> from Issn to Journal to make sure a constraint is added at the database 
> level and get easier querysets?
>
>
> Thanks,
>
> -Dan
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc06ee4d-e159-4ea1-b44b-f8099b567581%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-11-01 Thread Dan Davis
Thanks, would you say that running Minikube is the best way to learn 
Kubernetes at a significant level, or would you recommend a small 
Virtualbox/vagrant setup that really is a multi-node Kubernetes?   I don't 
really have enough cores and memory for the later anyway, but I could just 
start-up workloads on Amazon KCS or GCP to learn, if Minikube is not enough.

On Tuesday, October 30, 2018 at 5:59:18 PM UTC-4, Eric Pascual wrote:
>
> I'm not even sure those are the same as Docker containers even though 
> Kubernetes can run Docker images.
>
>
> Kubernetes is an orchestrator for Docker containers, not a container 
> engine. You can run the same images in K8S managed containers or on your 
> local Docker engine, using docker-compose for instance. I currently work on 
> a project related to a services platform based on micro-services deployed 
> in Docker containers. I test the images locally on my machine either in 
> docker-compose assemblies or in Minikube *(for validating the K8S 
> descriptors involved in deployment, configuration,...)* and then I deploy 
> the stuff on GCP.
>
>
> As already mentioned, K8S provides tools * (indicators, graphs,...)* to 
> monitor the resources used by pods. I would not use Linux metrics, if ever 
> they were representative when collected from inside a pod, since the 
> containers are running on VMs and they can be spread over different nodes 
> if your configuration involves multi-nodes load balancing.
>
>
> Eric
> --
> *From:* django...@googlegroups.com  <
> django...@googlegroups.com > on behalf of Dan Davis <
> dans...@gmail.com >
> *Sent:* Tuesday, October 30, 2018 6:56:32 PM
> *To:* Django users
> *Subject:* Re: Using django on kubernetes 
>  
> Andreas, 
>
> I don't know terribly much about Kubernetes, only Docker, however it seems 
> that Kubernetes must natively provide some metrics collection, i.e 
> https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/.
>   
>  It would be nice to correlate particular views and their arguments with 
> resource use.   If you are using a process model, not a threading model, 
> then I think the Linux system call getrusage() could do that, providing 
> that it is supported in Kubernetes containers.I'm not even sure those 
> are the same as Docker containers even though Kubernetes can run Docker 
> images.  Maybe you can educate me!
>
> Anyway, the package django-statsd might provide some help collecting APM 
> data without something like NewRelic, but if you can use a real APM, do it.
>
> On Tuesday, October 30, 2018 at 4:28:29 AM UTC-4, Andréas Kühne wrote:
>
> Hi all, 
>
> I have created a SPA with angular on the frontend and django rest 
> framework on the backend. It also has celery to do background tasks. 
> Everything is working as intended and it is running pretty smoothly.
>
> We have deployed it on kubernetes - so the frontend (with nginx) is 
> running in one pod, the backend is running in another and celery is running 
> on a third. Everything is connected and works. My question is more about 
> the resources settings for django. Does anyone have any experience in 
> setting up this? Currently I am running without resource limitations - 
> which means that the kubernetes master doesn't know how much resources the 
> django pod needs.
>
> There has to be someone more who has done this and has setup the resource 
> limits correctly - I would like some inspiration. I don't know how much 
> django requires
>
> Andréas
>
> -- 
> 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 post to this group, send email to djang...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f9691131-cb97-4286-a248-73aa65750efb%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/f9691131-cb97-4286-a248-73aa65750efb%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d5383ce9-387d-4c41-91e2-f11ba452b9a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Left outer join rather than subquery.

2018-10-30 Thread Dan Davis

Suppose you have a setup like this:

 class Journal(models.Model):
  title = models.CharField(max_length=200)


 issn_type_choices = (
 ('E', 'Electronic'),
 ('P', 'Print'),
 }

 class Issn(models.Model):
  ELECTRONIC='E'
  PRINT='P'

  journal = models.ForeignKey(Journal)
  issn_type = models.CharField(max_length=1)
  issn = models.CharField(max_length=10)


I can express annotations to assure I get botha  Physical and Print ISSN:

issn_p=Issn.objects.filter(issn_type='E', journal_id=OuterRef('id'))
issn_e=Issn.objects.filter(issn_type='P', journal_id=OuterRef('id'))
queryset = Journal.objects.annotate(issn_print=Subquery(issn_p), 
issn_electronic=Subquery(issn_e)).filter(issn_print__isnull=False, 
issn_electronic__isnull=False)


However, is there anyway for me to express two OneToOneField relationships 
from Issn to Journal to make sure a constraint is added at the database 
level and get easier querysets?


Thanks,

-Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/116bf684-237a-4a33-a218-8c0cf69e3091%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-10-30 Thread Dan Davis
Andreas,

I don't know terribly much about Kubernetes, only Docker, however it seems 
that Kubernetes must natively provide some metrics collection, i.e 
https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/.
  
 It would be nice to correlate particular views and their arguments with 
resource use.   If you are using a process model, not a threading model, 
then I think the Linux system call getrusage() could do that, providing 
that it is supported in Kubernetes containers.I'm not even sure those 
are the same as Docker containers even though Kubernetes can run Docker 
images.  Maybe you can educate me!

Anyway, the package django-statsd might provide some help collecting APM 
data without something like NewRelic, but if you can use a real APM, do it.

On Tuesday, October 30, 2018 at 4:28:29 AM UTC-4, Andréas Kühne wrote:

> Hi all,
>
> I have created a SPA with angular on the frontend and django rest 
> framework on the backend. It also has celery to do background tasks. 
> Everything is working as intended and it is running pretty smoothly.
>
> We have deployed it on kubernetes - so the frontend (with nginx) is 
> running in one pod, the backend is running in another and celery is running 
> on a third. Everything is connected and works. My question is more about 
> the resources settings for django. Does anyone have any experience in 
> setting up this? Currently I am running without resource limitations - 
> which means that the kubernetes master doesn't know how much resources the 
> django pod needs.
>
> There has to be someone more who has done this and has setup the resource 
> limits correctly - I would like some inspiration. I don't know how much 
> django requires
>
> Andréas
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f9691131-cb97-4286-a248-73aa65750efb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Handling Database Tables without a unique column

2018-10-29 Thread Dan Davis
I am currently leading a team handling a 16 year old database filled with 
junk.  I think it has existed since its HTML application was served by 
Oracle forms.
We are in production with Django, and turning off the more recent 
ColdFusion version this Thursday.

However, some of our ways of working reflect the deep SQL roots of the 
team.   For some tables, we have multi-column unique keys.

At the time I wrote these things, these seemed the best practices:
* For read-only tables, manufacture a unique column through concatenation 
in a corresponding database view.   Base the Django model on the database 
view.
* For read-write tables, do the work of adding a new unique ID column, but 
keep the table as managed = False.


Now that I am better at thinking in querysets, and can regularly use 
annotations, including F, Subquery and OuterRef expressions, I wonder 
whether there is a better way.   Has anyone ever tried doing this by adding 
to the SQL expressions code to manufacture a unique column in a QuerySet 
subclass or in the ModelManager?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e5eedb52-0add-4f3c-902b-4e6e9bfe3d05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: tests pass individually but fail together

2018-07-05 Thread Dan Tagg
Hi Heather,

What is it you are testing? I have had issues with this kind of thing when
testing forms that are programatically changing dropdown list / default
values.

Dan

On 5 July 2018 at 14:24,  wrote:

> Hello, I'm simplifying a previous post. I just started using Django a few
> months ago, and for some reason I'm still having trouble getting my mind
> around the way Django thinks about some things.
>
> I have a test class that contains two specific tests that always pass when
> run just by themselves, but always fail when run with the rest of the test
> class.
>
> One of the tests in particular is very puzzling, because I can step
> through the entire method under test and watch everything happen exactly
> the way it should--the database field values are changed correctly and the
> correct values are returned. But after the return statement, the values are
> different than they were before the return statement. They are consistently
> different, so *something* is happening behind the scenes... but I have no
> idea what... So I can't tell if my tests are flawed or if my code under
> test is flawed.
>
> Django 2.0 with MS SQL Server 2014. Any suggestions at all appreciated,
> because I'm completely out of ideas. I haven't been able to get
> TransactionTestCase to work at all, though--set-up data that works
> flawlessly with TestCase breaks TransactionTestCase, and I don't know why.
>
> Thank you!
> Heather
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/72497524-6c76-41de-ba70-a5b0996335dd%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/72497524-6c76-41de-ba70-a5b0996335dd%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY5UPA79U1N%2Bkk6XzqvejjdXuzh73tzBi-pQNMPPqpx8ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: post_save signal is not dispatched

2018-06-24 Thread Dan Tagg
Hi,

Weirdly, I've just been doing this. What do you have in your settings
INSTALLED_APPS?

One of them should be something like 'employer.apps.EmployerConfig'
alternatively in your employer module's __init__.py file you need to say
default_app_config = 'employer.apps.EmployerConfig'

Dan

On 24 June 2018 at 14:45, Dejan Spasić  wrote:

> I don't wont to bother you with a long text and will first show you the
> code. I think this should be self explanatory. If not, let me know :)
>
> #
>
> from typing import Any, Dict
>
> from django.apps import AppConfig
> from django.db.models.signals import post_save
>
> from django.contrib.auth.models import User
> from .models import Employer
>
>
> class EmployerConfig(AppConfig):
> name = "employer"
> verbose_name = "Employer"
>
> def ready(self) -> None:
> def post_save_user(**kwargs: Dict[str, Any]) -> None:
> if kwargs['created']:
> return None
>
> user: User = kwargs['instance']
>
> if user.employer:
> return None
>
> employer = Employer(user=user)
> employer.save()
>
> post_save.connect(post_save_user, User)#
>
>
> As you can see I want to create an employer and link them with the new 
> created user.
>
> Running the command
>
> ./manager.py createsuperuser --username username --email u...@user.com 
> ***
>
> shows me that I'm wrong. There is no entry in the myapp_employer table. What 
> did I missend?
>
>
> * Django: 2.0.X
> * app is installed
>
> * python: 3.6
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8d0c4241-3d1a-46c9-9e52-6cc4f46a3906%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8d0c4241-3d1a-46c9-9e52-6cc4f46a3906%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY562U_NDqLeKgfEGvGOz3Un9u8k0RHaiHTg_AYts_UFzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Run server

2018-06-22 Thread Dan Nepejchal
Hi,
you forgot set up your databse. Here is some documentation
https://docs.djangoproject.com/en/2.0/ref/databases/

Dne pá, 22. 6. 2018 18:01 uživatel Quiosa Evaristo <
evaris...@una.adventist.org> napsal:

>
> Hello!
>
> I am learning python, I have installed it in my computer it is running
> very well.
> I have installed django version 1.11.13 whenever I try to run the server
> it triggers the error bellow:
>
> Performing system checks...
>
> System check identified no issues (0 silenced).
> Unhandled exception in thread started by  check_errors..wrapper at 0x10d311268>
> Traceback (most recent call last):
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 216, in ensure_connection
> self.connect()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 194, in connect
> self.connection = self.get_new_connection(conn_params)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py",
> line 162, in get_new_connection
> conn = Database.connect(**conn_params)
> sqlite3.OperationalError: unable to open database file
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/utils/autoreload.py",
> line 225, in wrapper
> fn(*args, **kwargs)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
> line 123, in inner_run
> self.check_migrations()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/base.py",
> line 427, in check_migrations
> executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/executor.py",
> line 18, in __init__
> self.loader = MigrationLoader(self.connection)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/loader.py",
> line 49, in __init__
> self.build_graph()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/loader.py",
> line 206, in build_graph
> self.applied_migrations = recorder.applied_migrations()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 61, in applied_migrations
> if self.has_table():
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 44, in has_table
> return self.Migration._meta.db_table in
> self.connection.introspection.table_names(self.connection.cursor())
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 255, in cursor
> return self._cursor()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 232, in _cursor
> self.ensure_connection()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 216, in ensure_connection
> self.connect()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/utils.py",
> line 89, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 216, in ensure_connection
> self.connect()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py",
> line 194, in connect
> self.connection = self.get_new_connection(conn_params)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py",
> line 162, in get_new_connection
> conn = Database.connect(**conn_params)
> django.db.utils.OperationalError: unable to open database file
>
> Please I want some body to help me
>
>
> *WARNING: The information contained in this communication may be
> confidential, is intended only for the use of the recipient named above,
> and may be legally privileged. If the reader of this message is not the
> intended recipient, you are hereby notified that any dissemination,
> distribution, or copying of this communication, or any of its contents, is
> strictly prohibited. If you have received this communication in error,
> please re-send this communication to the sender and delete the original
> message and any copy of it from your computer system.*
>
> --
> 

Re: Need to Add One Or More Fields in Signup

2018-06-11 Thread Dan Nepejchal
Hi,
I think you must define your own user model, with inherit from django user
model...
class User(AbstractUser): bio = models.TextField(max_length=500, blank=True)
location = models.CharField(max_length=30, blank=True) birth_date = models.
DateField(null=True, blank=True)

and settings:
AUTH_USER_MODEL = 'core.User'

source:
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html

po 11. 6. 2018 v 16:37 odesílatel Pravin Yadav  napsal:

> Hello,
>
> I want to add the one or more fields in User Models/Table.
> Kindly let me know about this module.
>
> My code below:-
>
> def register(request):
>
> if request.method == 'POST':
> first_name = request.POST['first_name']
> last_name = request.POST['last_name']
> email = request.POST['email']
> password = request.POST['password']
> username= str(first_name).lower() + str(last_name).lower()
> userdatalist = User.objects.filter(email=email).count() or
> User.objects.filter(username=username).count()
> if userdatalist == 0:
> new_user = User.objects.create_user(
> username= email,
> first_name=first_name,
> last_name=last_name,
> email=email,
> password=password,
> is_active=0,
> age=age
> )
> hostname = request.get_host
> context = {'first_name': first_name, 'last_name': last_name, 'pk':
> new_user.id, 'hostname': hostname}
> to_email = email
> from_email = 'VideoWithFriends'
> html_message = render_to_string('mails/useractivation.html', context)
> subject = 'Your account has been created successfully.'
> email = EmailMultiAlternatives(subject, html_message, from_email,
> [to_email])
> email.attach_alternative(html_message, "text/html")
> if(email.send()):
> success = 1
> return HttpResponse(success);
> else:
> success = 2
> return HttpResponse(success);
> else:
> error = 0
> return HttpResponse(error);
>
> I haven't created any model of User. I have called the predefined models
> of User.
> When i'm adding extra fields like (age). it's showing errors.
> kindly let me how  it will be fixed.
>
>
> Thanks,
> Pravin Yadav
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/05199455-aad3-4390-ac93-d902f2361680%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADS85tyidM_fBZPw9CjDxYp3i%3DjoAZRLko5GB5h3%2BN-K52D8Mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: responsive html

2018-06-08 Thread Dan Nepejchal
Hi,

so if I understand it right you can use django template
https://docs.djangoproject.com/en/2.0/topics/templates/ and use your css
media query, then check how to serve static files
https://docs.djangoproject.com/en/2.0/howto/static-files/ sou about css is
in basic nothing change.

pá 8. 6. 2018 v 15:34 odesílatel Musab Mohammed 
napsal:

> HI,
>
> I am using css media query  in normal Html file and I am tying to convert
> it to django. So now i am not able to get responsive view. please let me
> know whats the solution.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c13459bc-858a-4655-b800-ccd33c0bb602%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADS85tyv%2BT1%2BP0J4_nCW%2BYr5Zj%3D61Y7xpr4Sz7B8uOjeDevjPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: A calendar booking app

2018-06-05 Thread Dan Tagg
I'm looking for the same thing Kasper -- Django based not PHP.

Dan

On 5 June 2018 at 13:32, Kasper Laudrup  wrote:

> Hi fellow Django users,
>
> I'm planning to start up a homepage for my familys summer house.
>
> There are a few ideas of what should be there, user management, possibly
> "blog like" entries, a photo gallery etc. I think I've found some pretty
> good existing Django apps for that, so that shouldn't be a problem to
> integrate them together somehow.
>
> A really cool feature though, would be to have some kind of
> reservation/booking system where any (authenticated) user can see when the
> house has been reserved and when it's available.
>
> Ideally, a non-admin user can request a range of dates, and an admin can
> then accept or decline that request. Naturally, there can only be one
> reservation on a range of dates.
>
> I have found a few calendar/booking like applications, but I'm not sure if
> any of them really fits my purpose.
>
> I could write all the code myself, but it would be a lot easier for me if
> an existing project already supports something similar that I could
> integrate.
>
> Anyone who has any experience with doing something that or could recommend
> where I should look?
>
> Thanks a lot!
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/7c77a814-7416-91ce-25db-1b3f0f22bd03%40stacktrace.dk.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY6bO9hKhQNzHuDz_-L6JiWFfCCk6hJr9uxbMhy9%2BWvZnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making an object unsaveable ...

2018-03-04 Thread Dan Tagg
Two possibilities spring to mind

1. Don't grant django's database user the right to update the relevant
table. If you take this approach you'll need to catch any errors if anyone
writes code to attempt to do this

2. Use signals to catch any save attempts. This is easily circumvented.

On 4 March 2018 at 09:41, Bernd Wechner  wrote:

> An interesting question I've not been able to solve reading docs or
> Googling. As every posting here only after some serious research efforts
> including class inspections ;-). But am stumped and wonder if anyone else
> has any ideas.
>
> Here is the use case:
>
>1. Load an object from database
>2. Flag it as unsaveable, not to be written back to database under any
>circumstances
>3. Make changes to the object (its fields)
>4. Present a detail view of the object.
>
> Basically, would like the freedom to change an object knowing the database
> is secure.
>
> As ever, am more interested in how to do this, than questioning why to do
> it. It may not be possible in which case fear not, I'm on top of the why's
> and can look at alternative strategies. But this use case provides an easy
> way of injecting some filters in one place of a code body I have without
> changing any of the views or other code. Simply one small hook I place into
> extant code, which will play around with the object (making translations
> for example). But in order to do so would want to know this cannot be
> written back to the database, that from here on in, it's for display
> purposes only.
>
> Have a suspicion after some research that this can't be done. In which
> case there's a second and almost as useful use case:
>
>1. Load an object from database
>2. Make a copy, that is unsaveable, not to be written back to database
>under any circumstances
>3. Make changes to the copy (its fields)
>4. Present a detail view of the copy.
>
> This has some slightly better chance of being possible. If not as well,
> yes indeed, I have to dive into the view itself and put hooks into each
> field as it renders I guess. Which is life. But would seem useful to do it
> with one of these use cases (again no need to discuss the merits of one
> approach over the other at all, am more interested in possibility -
> projects have huge amounts of context not readily shareable that influence
> the relative merits of one approach over another of course.
>
> Regards,
>
> Bernd.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/9162bad4-935a-ed39-d2d8-a001103ec705%40gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY7BciY%2B5JRQ2o%2B8eiLMVfCfg6boR0g_Fc8ymqO_E1EU_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model Design Questions

2017-12-16 Thread Dan Tagg
If you switched to Postgres you could use a json data type or dictionary
data type. Django 1.11 onwards supports the storage and retrieval of both
types I believe.

Dan

On Sun, 17 Dec 2017 at 07:46, Mark Phillips <m...@phillipsmarketing.biz>
wrote:

> I am building an electronic document management system using django and
> mysql. The purpose of this system is to catalog and retrieve electronic
> documents. There is no inventory of the physical documents. There are about
> 3,000 documents (photos, pdfs, videos) now, and that number could double in
> the next year. The purpose of the site is to search for a set of documents
> that share some given set of metadata values. I am wrestling with the model
> design for the metadata part of this project.
>
> I have identified about 30 internal metadata types particular to these
> documents, and not related to any standards. If I use Dublin Core, there
> are 71 types, but I would not need all of them, and there is some overlap
> with the 30 internal metadata types - say another 25 types. Schema.org also
> has an interesting set of metadata tags, and some may be applicable to this
> project, and using that standard as well, could bring the number of types
> to 75.
>
> As I see it, I have three options.
>
> Option 1 - traditional database design, with metadata types as columns,
> and values in rows. The document model would have approx 50 - 80 fields,
> and one could expect out of 3,000 documents about 50-70% of the values are
> Null.
>
> This option is the most straight forward to create. I have no idea what
> the performance would be for django and mysql, searching for a set of
> documents in a model with 50-80 fields and 3,000 entries, where 60% are
> Null. Is this a feasible design, or do I need to think of another way to
> model this metadata? Will this scale to 6,000 documents? What if I need to
> add another metadata standard to the site in the future? (I am not looking
> for job security in this project)
>
> Option 2 - some sort of EAV design, with a table that has document_id,
> metadatatype_id, and metadatavalue_id. I have read all sorts of posts about
> the evils of EAV, but they seem to have peaked about 8 years ago, and now I
> am seeing some posts that even recommend this design approach.
>
> Is this approach a better fit for my particular application? Will it scale
> to the numbers of documents and metadata I am thinking about? I really
> don't want to go to the dark side if I can help it.
>
> Option 3 - A hybrid solution that I have also read about. Put the more
> common metadata types as fields in the model (columns in the database
> table), and then JSON-ize the rest of the metadata for that document in a
> string field in the model. This seems to put a rather large burden on the
> application code when searching for a set of documents with a particular
> set of metadata values.
>
> The performance cost of this method seems to depend heavily on the
> distribution of metadata types in the entire document set, and being smart
> enough to pick the best common ones. If there were a set of metadata types
> that span 90% of the the documents, then this would probably be a good
> solution. Span only 25% of the documents, and there is a lot of comparing
> values in the JSON string.
>
> Thanks for any insights/recommendations you can provide!
>
> Mark
>
>
>
>
>
>
>
>
>
> --
>
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
>
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
>
>
> To post to this group, send email to django-users@googlegroups.com.
>
>
> Visit this group at https://groups.google.com/group/django-users.
>
>
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEqej2MYmfqaA1Gq7nByjGo%3DcxF6_x7fbz4cuRy2EgrCBmuDVA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEqej2MYmfqaA1Gq7nByjGo%3DcxF6_x7fbz4cuRy2EgrCBmuDVA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY7H1Go%2BOVzYfdToF_JrV3Wo783S3c%3Dk_eWztj6F0twQng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make my form send a POST request to a specified view?

2017-11-23 Thread Dan Tagg
You need an "action" attribute to your form
https://www.w3schools.com/tags/att_form_action.asp



On 23 November 2017 at 22:12, Tom Tanner 
wrote:

> My page has a registration form at `"/login_register/"`. I want the form
> to send a POST request to `"/register/"`. Here's my code so far.
>
> `urls.py`:
> url("^login_register/$", views.login_register, name="login_register"),
> url("^register/$", views.register, name="register"),
>
>
> `views.py`:
> def login_register(request, template="pages/login_register.html"):
>  '''
>  Display registration and login forms
>  '''
>  registration_form= RegisterForm()
>  return render(request, template, {"registration_form": registration_form
> })
>
>
> def register(request):
>  '''
>  Process user registration
>  '''
>  if request.method=="POST":
># Some code here
>
>
> `pages/login_register.html`:
>  # For this example, I only include the registration form's HTML
>  Register
>  
>  {% csrf_token %}
>  {{ registration_form.as_p }}
>  Register
>  
>
>
> When I hit "Register" on the form, my browser sends a POST request to
> "login_register/". I want it to send a POST request to "register/". How do
> I do 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/72030063-8482-4723-9f2c-b25b17656a43%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY6bUmJ9BkCTvukDbbv2YZVXXAgY9%3DdEKBaqjru0R%2BXFrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get as result a list of all the users ordered by birthday (month day), ignoring year

2017-11-21 Thread Dan Tagg
Hi Roberta,

I haven't tested it but assuming you want the ordering to happen within the
database you may be able to do it with a combination of TIMESTAMPDIFF
<https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_timestampdiff>
 and MOD
<https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_mod>
.

Something like MOD( TIMESTAMPDIFF( 'SECOND', birthday, '1900-01-01'),
31556951) assuming you're using MySQL.

On average there are 365.2425 days per year, which equates to 31,556,951
seconds.

Dan

On 21 November 2017 at 15:52, Roberta Takenaka Granero <
takenaka.robe...@gmail.com> wrote:

> Dear Roy
>
> I had already seen that link. But I didn't like the solution. Anyway it
> works, so I am using it for while.
>
> Thank you
>
> 2017-11-17 11:13 GMT-02:00 Roy Shillingburg <roy...@gmail.com>:
>
>> https://stackoverflow.com/questions/4236226/ordering-a-djang
>> o-queryset-by-a-datetimes-month-day
>>
>>
>>
>> On Friday, November 17, 2017 at 7:19:43 AM UTC-5, Roberta Takenaka
>> Granero wrote:
>>>
>>> In models:
>>>
>>> birthday = models.DateField()
>>>
>>> def birthday_month_day(self):
>>>   # returns month and day
>>>   return '12-31'
>>>
>>>
>>> In views, I expect to see something pythonic like this:
>>>
>>> User.objects.all().order_by('birthday_month_day')
>>>
>>> I know it does not work because birthday_month_day is not a column in
>>> database.
>>>
>>> The question is how to get as result a list of all the users ordered by
>>> birthday (month + day), ignoring year. (queryset order_by DateField month
>>> day)
>>>
>>> Can you help me? Anyone has faced this question before?
>>>
>>> Thanks
>>>
>>>
>>>
>>> --
>>> Roberta Takenaka
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/97d66095-d7a5-42c9-ad99-673fac39dac5%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/97d66095-d7a5-42c9-ad99-673fac39dac5%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Roberta Takenaka
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAJ9dYMGUbq-QF%3Devx7u%3DtLPatWYUKCQQ0Qd-ks9Sjs3f_
> kP8SA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJ9dYMGUbq-QF%3Devx7u%3DtLPatWYUKCQQ0Qd-ks9Sjs3f_kP8SA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4OyC9XnEMjSfbT6G9Zd6K1-TOa6ZPukw%3DowcLG3xUW7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Timezone error when I launch the admin login screen in 'Writing your first Django app'-tutorial

2017-09-26 Thread Dan Tagg
Check the Django Settings file and set

TIME_ZONE = 'UTC'


or something in this list
http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

Dan

On 26 September 2017 at 14:30, Lise <lise.lystl...@gmail.com> wrote:

> Hi,
>
> I'm trying to learn how to use Django through the 'Writing your first
> Django app'-tuorial. I have reached the step where you create a superuser
> and you need to start the server and go to the local domain and see the
> admin login screen. I don't see the admin login screen, I see a message
> that says
>
> *'A server error occurred. Please contact the administrator.' *
>
> and in the command prompt it says
>
> *'File
> "C:\Users\lbl\Anaconda3\envs\reports\lib\site-packages\pytz\__init__.py",
> line 181, in timezone raise UnknownTimeZoneError(zone)
> pytz.exceptions.UnknownTimeZoneError: 'UTC+01:00''*
>
> I am working on a Windows computer, so it might be something about the
> time settings on the computer not being convertible with the settings in
> Django. Does anyone know how to fix this? :)
>
> I am very new to this, so please forgive me for being a newbie in some
> aspects!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/537b282e-e553-41c2-8ccf-4533090c45b0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/537b282e-e553-41c2-8ccf-4533090c45b0%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY6hQk2oxoxC7we6-p3oFFUq%3DtFwBEw8daDrp0GVQ3w27A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Forward messages from a third party async source.

2017-09-04 Thread Dan Tagg
Hi Roger,

Have you seen Diamond (http://diamond.readthedocs.io/en/latest/) it may be
just what you need on the client side. Graphite (the server process) runs
on Django.

Dan

On 1 September 2017 at 11:56, Roger Gammans <rgamm...@gammascience.co.uk>
wrote:

> Hi all,
>
> I'm trying to build a system with a Django frontend which displays live
> information from other services on the backend (eg, the one running
> python - not the browser) host.
>
> To keep my dependencies as light as possibly I'm trying to avoid import
> the settings file for django and channel into the backend services. And
> run those a much lighter an simple process which concentrate on their
> tasks.
>
> I can easily create an async event in the backend processes; but to
> get the channels layer to respond to it; It seems that I need to create
> my own thread with it own tight loop doing something like:-
>
> def forward_sensor_to_web(sensor_gen,dj_channel):
> for sensor_data in sensor_gen():
> Channel(dj_channel).send(sensor_data.as_json())
>
>
> Obviously this needs to be kept running and restarted if the
> loop/thread raises an exception etc.
>
> Is there any extant best practice for how to set this sort of
> architecture up using channels? Can I integrate the into the channels
> main Aio loop?  Or is channels to the best way to go?
>
> I'm seeking to make sure I'm not missing anything; before thing start
> to get hard to change.
>
> Anybody got any thoughts?
>
> --
> Roger Gammans <rgamm...@gammascience.co.uk>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1504263403.30060.7.camel%40gammascience.co.uk.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY5Ces3s2%2Bdy%2Bhqz4xFmqUh27Noz_dQk%2BhyGtF5zoe-f8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: forms.Form.to_div ? and how override forms.Boundfield.label_tag?

2017-07-27 Thread Dan Tagg
crispy forms is a good addition for form creation
http://django-crispy-forms.readthedocs.io/en/latest/.

It gives you a lot of control over layout and templating.

Dan

On 26 July 2017 at 13:02, threesixright <threesixri...@gmail.com> wrote:

> Hi All,
>
> Just started a few weeks ago with (v1.11) *Django* (coming from Rails)
> and I *love* it! Kudos to all the dev's!
>
> I'm fiddling with creating forms. What would be the best approach to add a
> *to_div* method to the *forms.Form* class ? many frameworks (bootstrap,
> semantic-ui, etc.)  are using:
>
>  https://semantic-ui.com/modules/checkbox.html>">  tabindex="0" class="hidden"> I agree to the Terms and Conditions label> 
> 
>
> ..to group fields (label + input).
>
> I understand I can make my own form template and just loop over the
> fields. But nicer would be (imo) if you can use a *to_div* method om the
> form.
>
> Another thing I ran into is the usage of the form label. Unlike the input
> fields that you can easily override via the widget html templates, the
> label you can not. This is implemented in the *Boundfield* *label_tag*
> method. What would be the best way to change its default behaviour?
>
> Thanks!
> 36R
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d5a2df9b-e9ea-4cd6-8fb2-355a38bacd03%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d5a2df9b-e9ea-4cd6-8fb2-355a38bacd03%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY57G%3DT3Hnm8wgp4-BhWnFLiOLFQF_UPMFaqAp7n-w2XtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: recommendation for Django + Bootstrap

2017-06-28 Thread Dan Tagg
django cookie cutter does it very simply in my experience.

https://github.com/pydanny/cookiecutter-django

Dan

On 27 June 2017 at 22:55, Alceu Rodrigues de Freitas Junior <
alceu.freitas...@gmail.com> wrote:

> Hello folks,
>
> Could you please recommend any options available to integrate Django and
> Boostrap?
>
> I find out projects like https://github.com/dyve/django-bootstrap3, but
> I'm new to Boostrap and need something very basic: my views/templates
> should render nicely in different sizes os screens (desktop, smartphones,
> etc).
>
> Thanks!
> --
> Alceu
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ae316257-4b43-4c96-c2b3-6237847e3e87%40gmail.com
> <https://groups.google.com/d/msgid/django-users/ae316257-4b43-4c96-c2b3-6237847e3e87%40gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4ubmO8R%2BUe9M8BJ%3D0-xwMsHVPDr3afzVukL%2BVYy9EY8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Link to download

2017-05-03 Thread Dan Tagg
You might want to check out WhiteNoise (
https://whitenoise.readthedocs.io/en/stable/) perhaps in conjunction with a
CDN

On 3 May 2017 at 19:35, Tim Chase  wrote:

> On 2017-05-02 19:11, Antonis Christofides wrote:
> > response = HttpResponse(csvfile.read(), content_type='text/csv')
>
> Beware that, if your content can get huge (some of our reports can
> run to hundreds of megabytes), you might want to investigate
> something like the "sendfile" alternatives or spew it out as generator
> instead of doing .read() to suck the whole thing into memory.
>
> -tkc
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/20170503133519.05365d67%40bigbox.christie.dr.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY5FnmudhJSV5k2FBptiK1EdGk1%3D7vhyXicbJZf1uD3j3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - Class Based Consumers

2017-04-05 Thread Dan Alderman
That makes sense.

I got myself in such a muddle I somehow ended up knowing less about 
Channels than I did a couple of weeks go.

Thanks very much for the help!

On Wednesday, 5 April 2017 09:18:58 UTC+1, Andrew Godwin wrote:
>
> The stream is the name of the stream inside the Multiplexer - it's like a 
> sub-channel inside the WebSocket that is used by either end to distinguish 
> packets from each other (it's why you provide it to the JavaScript binding 
> - it needs to know which stream to listen to)
>
> Andrew
>
> On Wed, Apr 5, 2017 at 9:15 AM, Dan Alderman <daniel.thom...@gmail.com 
> > wrote:
>
>> Hi Andrew,
>>
>> Many thanks for your input - that does indeed help.
>>
>> What was really confusing me was what arguments I actually needed to 
>> supply to the JsonWebsocketConsumer.group_send() function.
>>
>> Not fully understanding classmethods, I was trying to pass the cls 
>> argument as well.
>>
>> I understand what the group_name and payload arguments do - but what s 
>> the stream argument doing?
>>
>> Dan
>>
>> On Tuesday, 4 April 2017 13:57:07 UTC+1, Andrew Godwin wrote:
>>>
>>> Hi Dan,
>>>
>>> An initial glance shows that you might be passing the arguments wrong to 
>>> Multiplexer.group_send(group_name, stream, payload) - I'm not sure why you 
>>> are using multiplexer.__class__.__name__ as the group name, but the group 
>>> name you configured in connection_groups is updatedb_results, and the 
>>> stream you're listening to in the JS client is also updatedb_results, so 
>>> you should set both of these to that value.
>>>
>>> Andrew
>>>
>>> On Tue, Apr 4, 2017 at 9:55 AM, Dan Alderman <daniel.thom...@gmail.com> 
>>> wrote:
>>>
>>>> Hi guys,
>>>>
>>>> Been trying to get my head around this for ages now but still no luck, 
>>>> hopefully someone can point me in the right direction.
>>>>
>>>> I'm trying to set up a Demultiplexer with a JsonWebsocketConsumer that 
>>>> sends to a group. (There is only one stream in the Demultiplexer at 
>>>> the moment, but I intend to add more).
>>>>
>>>> The prints in each of the functions work when I interact with my app in 
>>>> the web browser, but I'm having trouble getting a response in the 
>>>> browser via websockets.
>>>>
>>>> If I user multiplexer.send() then it works, but it only goes to a 
>>>> single connection (as you'd expect).
>>>>
>>>> consumers.py
>>>>
>>>> from channels.generic.websockets import JsonWebsocketConsumer, 
>>>> WebsocketDemultiplexer
>>>>
>>>> class DatabaseUpdateConsumer(JsonWebsocketConsumer):
>>>> strict_ordering = True
>>>>
>>>> def connection_groups(self, **kwargs):
>>>> return ["updatedb_results"]
>>>>
>>>> def connect(self, message, multiplexer, **kwargs):
>>>> print "Connected!"
>>>> multiplexer.group_send(multiplexer.__class__.__name__, 
>>>> self.connection_groups(), {'text': "Connected!"})
>>>>
>>>> def disconnect(self, message, multiplexer, **kwargs):
>>>> print("Stream %s is closed" % multiplexer.stream)
>>>>
>>>> def receive(self, content, multiplexer, **kwargs):
>>>> print "Message received by server!"
>>>> multiplexer.group_send(multiplexer.__class__.__name__, 
>>>> self.connection_groups(), {'text': "Message received by server!"})
>>>>
>>>> class Demultiplexer(WebsocketDemultiplexer):
>>>>
>>>> consumers = {
>>>> "updatedb_results": DatabaseUpdateConsumer,
>>>> }
>>>>
>>>> index.html
>>>>
>>>> {% extends "base.html" %}
>>>>
>>>> {% block title %}Test Dashboard{% endblock %}
>>>>
>>>> {% block content %}
>>>> {{ job_detail|length }}
>>>> 
>>>> {% for line in job_detail %}
>>>> {{ line.job_number }}
>>>> {% endfor %}
>>>> {% endblock %}
>>>>
>>>> {% block javascript %}
>>>> 
>>>> const webSocketBridge = new channels.WebSocketBridge();
>>>> webSocketBridge.connect("ws:/development01:8000/ws/");
>>>> webSocketBridge.listen();
>>>> webSocketBridge.demultiplex('updatedb_results

Re: Django Channels - Class Based Consumers

2017-04-05 Thread Dan Alderman
Hi Andrew,

Many thanks for your input - that does indeed help.

What was really confusing me was what arguments I actually needed to supply 
to the JsonWebsocketConsumer.group_send() function.

Not fully understanding classmethods, I was trying to pass the cls argument 
as well.

I understand what the group_name and payload arguments do - but what s the 
stream argument doing?

Dan

On Tuesday, 4 April 2017 13:57:07 UTC+1, Andrew Godwin wrote:
>
> Hi Dan,
>
> An initial glance shows that you might be passing the arguments wrong to 
> Multiplexer.group_send(group_name, stream, payload) - I'm not sure why you 
> are using multiplexer.__class__.__name__ as the group name, but the group 
> name you configured in connection_groups is updatedb_results, and the 
> stream you're listening to in the JS client is also updatedb_results, so 
> you should set both of these to that value.
>
> Andrew
>
> On Tue, Apr 4, 2017 at 9:55 AM, Dan Alderman <daniel.thom...@gmail.com 
> > wrote:
>
>> Hi guys,
>>
>> Been trying to get my head around this for ages now but still no luck, 
>> hopefully someone can point me in the right direction.
>>
>> I'm trying to set up a Demultiplexer with a JsonWebsocketConsumer that 
>> sends to a group. (There is only one stream in the Demultiplexer at the 
>> moment, but I intend to add more).
>>
>> The prints in each of the functions work when I interact with my app in 
>> the web browser, but I'm having trouble getting a response in the 
>> browser via websockets.
>>
>> If I user multiplexer.send() then it works, but it only goes to a single 
>> connection (as you'd expect).
>>
>> consumers.py
>>
>> from channels.generic.websockets import JsonWebsocketConsumer, 
>> WebsocketDemultiplexer
>>
>> class DatabaseUpdateConsumer(JsonWebsocketConsumer):
>> strict_ordering = True
>>
>> def connection_groups(self, **kwargs):
>> return ["updatedb_results"]
>>
>> def connect(self, message, multiplexer, **kwargs):
>> print "Connected!"
>> multiplexer.group_send(multiplexer.__class__.__name__, 
>> self.connection_groups(), {'text': "Connected!"})
>>
>> def disconnect(self, message, multiplexer, **kwargs):
>> print("Stream %s is closed" % multiplexer.stream)
>>
>> def receive(self, content, multiplexer, **kwargs):
>> print "Message received by server!"
>> multiplexer.group_send(multiplexer.__class__.__name__, 
>> self.connection_groups(), {'text': "Message received by server!"})
>>
>> class Demultiplexer(WebsocketDemultiplexer):
>>
>> consumers = {
>> "updatedb_results": DatabaseUpdateConsumer,
>> }
>>
>> index.html
>>
>> {% extends "base.html" %}
>>
>> {% block title %}Test Dashboard{% endblock %}
>>
>> {% block content %}
>> {{ job_detail|length }}
>> 
>> {% for line in job_detail %}
>> {{ line.job_number }}
>> {% endfor %}
>> {% endblock %}
>>
>> {% block javascript %}
>> 
>> const webSocketBridge = new channels.WebSocketBridge();
>> webSocketBridge.connect("ws:/development01:8000/ws/");
>> webSocketBridge.listen();
>> webSocketBridge.demultiplex('updatedb_results', function(data, stream) {
>> console.log(data);
>> });
>> 
>> {% endblock %}
>>
>> routing.py
>>
>> from channels import route_class
>> from dashboard.consumers import Demultiplexer
>>
>> channel_routing = [
>> route_class(Demultiplexer, path="^/ws/"),
>> ]
>>
>> Can anyone tell me where I'm going wrong?
>>
>> Thanks,
>>
>> Dan
>>
>> -- 
>> 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 post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/965e2ace-f7af-43d8-bf20-cac1745bb51e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/965e2ace-f7af-43d8-bf20-cac1745bb51e%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e00a2db6-db82-45e4-a08c-bb805488a37e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels - Class Based Consumers

2017-04-04 Thread Dan Alderman
Hi guys,

Been trying to get my head around this for ages now but still no luck, 
hopefully 
someone can point me in the right direction.

I'm trying to set up a Demultiplexer with a JsonWebsocketConsumer that sends 
to a group. (There is only one stream in the Demultiplexer at the moment, but 
I intend to add more).

The prints in each of the functions work when I interact with my app in the web 
browser, but I'm having trouble getting a response in the browser via 
websockets.

If I user multiplexer.send() then it works, but it only goes to a single 
connection 
(as you'd expect).

consumers.py

from channels.generic.websockets import JsonWebsocketConsumer, 
WebsocketDemultiplexer

class DatabaseUpdateConsumer(JsonWebsocketConsumer):
strict_ordering = True

def connection_groups(self, **kwargs):
return ["updatedb_results"]

def connect(self, message, multiplexer, **kwargs):
print "Connected!"
multiplexer.group_send(multiplexer.__class__.__name__, 
self.connection_groups(), {'text': "Connected!"})

def disconnect(self, message, multiplexer, **kwargs):
print("Stream %s is closed" % multiplexer.stream)

def receive(self, content, multiplexer, **kwargs):
print "Message received by server!"
multiplexer.group_send(multiplexer.__class__.__name__, 
self.connection_groups(), {'text': "Message received by server!"})

class Demultiplexer(WebsocketDemultiplexer):

consumers = {
"updatedb_results": DatabaseUpdateConsumer,
}

index.html

{% extends "base.html" %}

{% block title %}Test Dashboard{% endblock %}

{% block content %}
{{ job_detail|length }}

{% for line in job_detail %}
{{ line.job_number }}
{% endfor %}
{% endblock %}

{% block javascript %}

const webSocketBridge = new channels.WebSocketBridge();
webSocketBridge.connect("ws:/development01:8000/ws/");
webSocketBridge.listen();
webSocketBridge.demultiplex('updatedb_results', function(data, stream) {
console.log(data);
});

{% endblock %}

routing.py

from channels import route_class
from dashboard.consumers import Demultiplexer

channel_routing = [
route_class(Demultiplexer, path="^/ws/"),
]

Can anyone tell me where I'm going wrong?

Thanks,

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/965e2ace-f7af-43d8-bf20-cac1745bb51e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How install Django in PyCharm Community edition?

2017-02-10 Thread Dan Tagg
+1 for virtualenv

On 10 February 2017 at 11:44, Stefan Milutinovic 
wrote:

> You can't install django in PyCharm.
>
> You must set proper Python interpreter into PyCharm Settings.
> File>Settings>Project:name_of_your_project>Project Interpreter
> There you must setup proper Python interpreter.
>
> The best option is that you create Virtual Environment for each project.
> This is guide for virtualenvironment.
> http://docs.python-guide.org/en/latest/dev/virtualenvs/
>
> Than in your virtualenv. you install all desired packages and you set that
> is your project interpreter python located in environment folder.
>
> Good luck.
>
> петак, 10. фебруар 2017. 00.05.12 UTC+1, Sławomir Gontarek је написао/ла:
>>
>> How install Django in PyCharm Community edition?
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8e8a7691-61ad-427c-a2f7-ecd24bae17ea%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY5C8FFx0ctQDeHAhwa9Tguz7yhLcWONo2tcKY0ho9Vsug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Questions about templates from a novice - Question #1

2016-12-01 Thread Dan Tagg
Hi Jim,

I would really recommend looking at https://ccbv.co.uk/projects/Django/1.9/

There are diagrams to show the hierarchy of inheritance and mixins, plus
all the properties and methods are there to see and explore.

The place to start is the dispatch method, as_view is called first but you
can backtrack to that later. Have a look, you'll see dispatch gets the
request's method tries to call a method with that name if it is a valid
HTTP method and returns a HTTP 405 if either the method is not defined.

Dan



On Thursday, 1 December 2016, jim_anderson <jim_ander...@jjajava.com> wrote:

> Hi,
>
> A few intro words first. I am an experienced programmer and worked on a
> few python projects for maybe 3 years around 2000. Most of my other
> programming has been in c, c++, and java - maybe too many years. My current
> project is a web based project using Python 3.5.2 and Django 1.9.7. I have
> gotten to the point where I'm feeling pretty comfortable with python again,
> but I'm still getting a handle on django, so I'll classify myself as being
> intermediate in my python knowledge and mid-novice with django. I am
> writing a bit of code for the project and in parallel, I am experimenting
> with a django project that I call 'testDjangoProject' (I'm not too
> original). My current objective in the test project is to get a working
> template environment and a working knowledge so that I can write and
> templates, template tags and template filters.
>
> I have a few questions, but I'm going enter each question as a separate
> thread in this group.
>
> So, question number 1:
>
> I have created a view class that is derived from generic.ListView, which
> inherits from a few other classes both directly and indirectly. My class,
> called TagView, overrides 2 methods get_query_set() and get(). I basically
> did this to mimic what I saw in some tutorials. When I run my test case,
> the get() method is called. There are a number of other derived methods
> that could also have been overriden. What are the deciding factors that
> django uses to determine which view class method to call?
>
> BTW, my 'tag' model has 2 entries in a sqlite3 db.
>
> Jim Anderson
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/ce1e5ebf-725f-4c44-8a91-2e742061c764%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ce1e5ebf-725f-4c44-8a91-2e742061c764%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4LBOy5JeOts1nphScOgnBj%2B1HG%3DShUZF6CPCqwt1A0jw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango with Docker

2016-12-01 Thread Dan Tagg
Cookie cutter is pretty awesome. Don't know whether it works with GeoDjango
though.
https://github.com/pydanny/cookiecutter-django

Dan


On 1 December 2016 at 13:32, hunter.cur...@gmail.com <
hunter.cur...@gmail.com> wrote:

> Hi Tadeo, I've recently gone through this exercise myself, and documented
> my progress in three posts:
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-1/
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-2/
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-3/
>
> It's based on Ubuntu but you should be able to move it to Alpine without
> too much effort.
> Dave
>
> On Wednesday, November 30, 2016 at 10:02:59 AM UTC-7, Tadeo C wrote:
>>
>> Hi, I'm starting a project with GeoDjango and I want to use Docker
>> containers to build the stack (GeoDjango, Nginx, Postgis) preferably Alpine
>> base images.
>> Does anyone has successful done this before? Where can I find a useful
>> docker-compose.yml or a tested and working updated image?
>> Thanks a lot,
>> Tadeo
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/3f10a892-c65d-4f5e-96ce-cca55295c33f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3f10a892-c65d-4f5e-96ce-cca55295c33f%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4X9%3Dg2O4PQfex7fd4f%2BbUR3Ckyh7akHKOesd%2BZ-tgQKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations for multiple Django versions

2016-11-25 Thread Dan Tagg
Hi Vlastimil,

Why not use your source control system to publish different releases for
different versions of django.

Dan

On 25 November 2016 at 10:01, Vlastimil Zíma <vlasti...@ziima.cz> wrote:

> I don't think separate migrations would make the problem any better, that
> looks just like more complicated implementation of migrations with
> condition in it.
>
> Our use case:
> Our webs consist from several projects based on Django, with dependencies
> between them. One of the core projects provides, among other things, custom
> user model for some of our applications. Given the experience we had with
> transition to newer Django in past we agreed to move to newer versions
> gradually, that is first support new version then drop the old one. Sadly
> there seems to be number of issues related to migrations which makes it
> quite hard.
>
> Personally I think, the problem lies in migrations generated for 
> `AbstractBaseUser`.
> Any changes in `AbstractBaseUser` model should result in migrations for
> `AUTH_USER_MODEL` instead of `auth.User` model directly. That should solve
> the problems with migrations on custom user model.
>
> Or alternatively, let us redefine model fields inherited from parent class
> when we know what we're doing. IMHO warning should be enough, reporting
> error is not necessary.
>
> Vlastimil
>
>
> Dne čtvrtek 24. listopadu 2016 15:30:27 UTC+1 Tim Graham napsal(a):
>
>> I'm not sure. Possibly you could hack up a solution with separate
>> migration directories for each Django version you want to support, e.g.
>> migrations_dj19, migrations_dj18, ... and then point to the correct
>> directory with settings.MIGRATION_MODULES. I'm doubtful if that can be done
>> elegantly when upgrading from one Django version to the next (if each
>> directory has different migrations) but maybe it inspires a solution.
>>
>> Off topic, but I'm curious why you want to support multiple versions of
>> Django with a custom user model. Usually when I see a use case for multiple
>> Django version support it's for reusable apps, which shouldn't contain a
>> custom user model.
>> https://docs.djangoproject.com/en/stable/topics/auth/customi
>> zing/#reusable-apps-and-auth-user-model
>>
>> On Thursday, November 24, 2016 at 5:36:03 AM UTC-5, Vlastimil Zíma wrote:
>>>
>>> We find out migrations with condition on Django version doesn't work.
>>>
>>> Let's have migrations based on Django version for user last_login:
>>>  1. Create database
>>>  2. Run migrations in Django 1.7 - that correctly creates table
>>> custom_user with last_login NOT NULL
>>>  3. Update Django to 1.9
>>>  4. Run migrations -> migration for auth.User is correctly ignored
>>>  5. custom_user with last_login is NOT NULL, altough it shouldn't be.
>>> Both migrations that should take care of it were ignored - our migration
>>> because it was based on Django version, auth migrations because the use is
>>> swapped.
>>>
>>> So, what now?
>>>
>>> Vlastimil
>>>
>>> Dne středa 19. října 2016 1:57:25 UTC+2 Tim Graham napsal(a):
>>>>
>>>> Assuming the problem is makemigrations generating different migrations
>>>> based on the Django version, conditionally adding operations in migrations
>>>> with some django.VERSION checks may help.
>>>>
>>>> On Tuesday, October 18, 2016 at 7:12:02 AM UTC-4, Vlastimil Zíma wrote:
>>>>>
>>>>> Hi everyone,
>>>>>
>>>>> we are trying in our application to support multiple Django versions,
>>>>> specifically 1.7 to 1.9. But we encountered a problem with
>>>>> `User.last_login` field. We use custom User model based on
>>>>> `AbstractBaseUser` as specified by the documentation. Everything was fine
>>>>> in Django 1.7, but we got stuck when we wanted to add support for Django
>>>>> 1.8, where the `last_login` was modified to allow NULL values. As
>>>>> recommended by https://docs.djangoproject.com
>>>>> /en/1.10/topics/migrations/#supporting-multiple-django-versions we
>>>>> have migrations generated in Django 1.7 (lowest supported version) an thus
>>>>> `last_login` is NOT NULL, but that causes tests to fail when run in Django
>>>>> 1.8/1.9, since code allows `last_login` to be NULL.
>>>>>
>>>>> We can't even redefine the field in our model, which would be the most
>>>>> straight forward solution, but that's not allowed by Django either.
>>>>>
>

Subtracting UNIX_TIMESTAMPS broke in Django 1.10

2016-08-16 Thread Dan Edwards
I have a query that works in Django 1.9.9 but not 1.10. Running on CentOS 
7, with python 2.7.5, and MySQL 5.6.23 on Amazon RDS
Example:

class TaskLog(models.Model):
id = models.AutoField(primary_key=True)
start = models.DateTimeField(auto_now_add=True)
stop = models.DateTimeField(blank=True, null=True, default=None) 

Query =  TaskLog.objects.extra(select = {"day": "left(start, 
10)"}).values("day").annotate(sum=Sum(Func(F('stop'), 
function='UNIX_TIMESTAMP') - Func(F('start'), function='UNIX_TIMESTAMP')))

In 1.9.9 the value for sum would be the sum of the number of seconds 
between start and stop. 
In 1.10 it is always None.

The sql generated is:
Django 1.9.9:
SELECT (left(start, 10)) AS `day`, SUM((UNIX_TIMESTAMP(`TaskLog`.`stop`) - 
UNIX_TIMESTAMP(`TaskLog`.`start`))) AS `sum`  FROM `TaskLog` WHERE 
(`TaskLog`.`user_id` = 22) GROUP BY UNIX_TIMESTAMP(`TaskLog`.`stop`), 
UNIX_TIMESTAMP(`TaskLog`.`start`), (left(start, 10)) ORDER BY NULL

Django 1.10:
SELECT (left(start, 10)) AS `day`, SUM(TIMESTAMPDIFF(MICROSECOND, 
UNIX_TIMESTAMP(`TaskLog`.`start`), UNIX_TIMESTAMP(`TaskLog`.`stop`))) AS 
`sum` FROM `TaskLog` WHERE (`TaskLog`.`user_id` = 22) GROUP BY (left(start, 
10)) ORDER BY NULL

It looks like the new temporal subtraction feature to swap out the - with 
TIMESTAMPDIFF is the problem. Maybe it shouldn't do that for 
UNIX_TIMESTAMPs?

I fixed my app by simplifying my code to not convert to UNIX_TIMESTAMP 
before subtracting:
Query =  TaskLog.objects.extra(select = {"day": "left(start, 
10)"}).values("day").annotate(sum=Sum(F('stop') - F('start')))

But thought I should still report that subtracting UNIX_TIMESTAMPs appears 
to be broken

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8309dec9-edfd-4b07-b9ed-26a19dec01b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django session issue with mod_wsgi + apache

2016-07-15 Thread Dan Tagg
Cacheing?
1. Do Bob's and James's pages have different URLs
2. Have you configured your cacheing. if you are using it, to not reuse
components that could be confused?
3. Are you sending the correct cacheing directions to try and make sure
caches between your infrastructure and the user's screen are not making the
mistake.

D

On 15 July 2016 at 11:27, Dipankar B  wrote:

> Hello,
>
> I am working on Django Aplication . It has almost 350 users right now.
>
> Problem.
>
> Suppose we have a username bob and james.
>
> So, bob logged in and using our Django web application. But Sometimes
> bob's session is showing james account information. So bob is able to see
> James private data as we are using session (request.user ) to show user
> profile data.
>
> I am too much worried about this as it can completely ruin our application.
>
> Can you please tell me what is possible cause to such behavior.
>
> We are using 1.9.6.
>
> Please help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9bb086f2-8d30-4d97-af2c-921610d364df%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4%3DRXY4GH21YdcT58375kwER5oC2CfoAED-P_wwHZMYRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to retrieve data from deep nested object?

2016-04-26 Thread Dan Tagg
Does {% for question in subsection.subsection_set.all %} work?

Dan

On 26 April 2016 at 13:33, Said Akhmedbayev <said@gmail.com> wrote:

> I am trying to figure out how to loop over deep nested object in Django
> template.
>
> Here is my app's code
>
> models.py
>
> from django.db import models
>
>
> class Unit(models.Model):
> unit_number = models.PositiveIntegerField(blank=True, null=True,
> default=1)
> title = models.CharField(max_length=150, blank=True, null=True)
> scripture_ref = models.CharField(max_length=250, blank=True, null=True)
>
> def __str__(self):
> return self.title
>
>
> class Subsection(models.Model):
> title = models.CharField(max_length=150, blank=True, null=True)
> subsection_text = models.TextField(default='SUBSECTION TEXT')
> unit = models.ForeignKey(Unit, on_delete=models.CASCADE)
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=2000, default='QUESTION
> TEXT')
> subsection = models.ForeignKey(Subsection, on_delete=models.CASCADE)
>
> views.py
>
> from django.shortcuts import get_object_or_404
> from django.shortcuts import render
>
> from .models import Unit
>
>
> def unitdetail(request, unit_id):
> unit = get_object_or_404(Unit, pk=unit_id)
> return render(request, 'correspondence_course/unit_detail.html',
> {'unit': unit,})
>
> unit_detail.html (template)
>
> Урок {{ unit.unit_number }}
> {{ unit.title }}
>
>
> {% for subsection in unit.subsection_set.all %}
> {{ subsection.title }}
> {{ subsection.subsection_text }}
> {% for question in subsection. %} # this is just for reference. It
> does not work
> {{ question.question_text }}
> {% endfor %}
> {% endfor %}
>
> As you can see I have three class models: Unit, Subsection with back
> relationship with Unit and then Question with back relationship with
> Subsection.
>
> I managed to show in the template (see above) unit.title alone with 
> subsection.title
> and subsection.subsection_text. It is all nice, but I cannot figure out
> how to loop over and display questions that are nested to Subsection(s).
>
> Can you please help me to figure out how make it work?
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2f0d18f4-57c1-4852-b510-114a9b7fffc6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2f0d18f4-57c1-4852-b510-114a9b7fffc6%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4w%2Bdz2ied_%2BYX%3D9y_4x3E%3Dn7SF3Z_WLwRBJRJo5uFO3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GROUP BY without using aggregate function

2016-03-02 Thread Dan Tagg
if your aren't counting or averaging then why are you grouping?

D

On 2 March 2016 at 17:06,  wrote:

> Hello,
>
> I would like to query database with Django ORM and add GROUP BY clause
> without including unnecessary counting, avg, etc.
> I can force/hack queryset by settting qs.query.group_by=['my_column'],
> but this is unclean and risky.
>
> Is possible something like:
>
> MyModel.objects.filter(...).group_by('my_column')
>
> ?
>
> Kind Regards,
> Marcin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/64f4b422-7704-413d-a9c5-837c53eaefc9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY7tKM%2BBFPGf0o%3DXwJBOAhiyt8Avu0Xbe%2BqpfeiFQoRafA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use selenium automated testing in django projects

2016-02-27 Thread Dan Tagg
Harry Percival is very good
http://www.obeythetestinggoat.com

Not sure if he covers Excel

Dan
On 27 Feb 2016 13:22, "Vikneswaran S J" <vickyrahul...@gmail.com> wrote:

> I need to use selenium automated testing for django application with input
> from excel sheet. How to use use this feature? any idea?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0868a7b8-652a-40c5-b80f-d56159ad15af%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0868a7b8-652a-40c5-b80f-d56159ad15af%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY60busYmHGENCo1u2%3DbsSDjvb7-3EP9K3ZogD1PoOETtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: testing django migrations

2015-12-27 Thread Dan Tagg
Hi,

I used this:
https://github.com/plumdog/django_migration_testcase

It's only worth writing tests if you are modifying code created by
makemigrations.

Dan

On 27 December 2015 at 10:14, varun naganathan <varunnaganathan...@gmail.com
> wrote:

> Hi,I wanted to know how am i supposed to test the working of django
> migrations.As in how the migrations generate the SQL query.Basically I want
> to inspect how the sql query generated as in the output of "./manage.py
> sqlmigrate" is being generated.I've generally used "pdb" along wth
> unittest.TestCase,but for migrations I'm pretty much stuck.Does anyone
> probably have a sample test they wrote to test the django migrations.
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b6364f7e-56ab-4682-ad0a-3684e6199c8f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b6364f7e-56ab-4682-ad0a-3684e6199c8f%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY5CJ_9jex%2BnKNi%3DCy2XG9X9zrLS%3DJBW-mUmDoCpK6%2BTPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to serve a static file with django?

2015-12-23 Thread Dan Bikle
*Hi List,*























































*I am new to django.I read 
this:https://docs.djangoproject.com/en/1.9/howto/static-files/I did this:cd 
~django-admin startproject mysiteI see this in 
~/mysite/mysite/settings.pyINSTALLED_APPS = ['django.contrib.admin',
'django.contrib.auth','django.contrib.contenttypes',
'django.contrib.sessions','django.contrib.messages',
'django.contrib.staticfiles',]So, I see staticfiles in there.cd 
mysitepython manage.py startapp my_appmkdir -p my_app/static/my_appecho 
hello > my_app/static/my_app/hello.htmlpython manage.py runserverOther 
terminal:curl 127.0.0.1:8000/my_app/static/my_app/hello.htmlgives:Page not 
found (404)So, I'm curious.How to serve a static file with django?I sense 
that This URL is leaving out a step or maybe I read it 
wrong:https://docs.djangoproject.com/en/1.9/howto/static-files/??I am 
running this django:>>> import django>>> print(django.get_version())1.9>>> 
>>> *

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6ebacf12-c365-4a0d-bd23-c18926c9fff6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tool to document project urls, views, templates, etc...

2015-12-14 Thread Dan Tagg
http://ccbv.co.uk/ does this for django class based views. The code is on
github
https://github.com/refreshoxford/django-cbv-inspector/

Might be a good starting point.

D

On 14 December 2015 at 17:49, Royendgel Silberie 
wrote:

> The closest I know is :
>
> python manage.py show_urls
>
> in the django-extensions package
>
> On Saturday, December 12, 2015 at 9:43:28 AM UTC-4, Mat Gessel wrote:
>>
>> Anyone know of a tool that can analyze a project and generate a list or
>> graph of *views* & related information?
>>
>> I'm maintaining a medium size Django project. For each feature/change, I
>> am finding myself creating a "map" of the relevant view names/relationships
>> for quick reference. This includes:
>>
>>- URL pattern
>>- URL pattern name
>>- view class name
>>- template file name
>>
>> Example:
>>
>>> /training/, course-list, TrainingCourseList,
>>> training/trainingcourse_list.html
>>> /training/courses//, course-detail, TrainingCourseDetail,
>>> training/trainingcourse_detail.html
>>> /training/courses//purchase/, course-cart, TrainingCourseCart,
>>> training/trainingcourse_cart.html
>>> /training/checkout/, course-checkout, TrainingCourseCheckout,
>>> training/trainingcourse_checkout.html
>>
>>
>> I'm new to Django and I like it so far, but identifying references is a
>> bit of a nuisance. I found manage.py graph_models, but that only
>> processes models.
>>
>> I lieu of a tool, anyone have organizational practices they'd like to
>> share?
>>
>> Thanks,
>>
>> --
>> Mat Gessel
>> http://www.asquare.net
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ae250cf2-2fc8-41fe-857a-f64c1a8e56e7%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY7UKT5mHEw2%2BhhZ_xDZr6SnX2VmWYVAeYAWtDS%3DZBF3xw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What will be the replacement for .extra()?

2015-12-10 Thread Dan Stephenson
Following is worth a watch

https://opbeat.com/events/duth/#expressions


On Thursday, 10 December 2015 21:22:39 UTC, thinkwell wrote:
>
> So how would an query like this be written, with the new Query Expression 
> API? Where a count of events by day is required but the date column is 
> datetime?
>
> Triggers.objects.all().extra({"day": "date_trunc('day', date)"}).
> values_list('name', 'severity', 'day').annotate(total=Count('severity'))
>
>
>
>
>
> On Wednesday, December 9, 2015 at 8:07:28 PM UTC-5, Russell Keith-Magee 
> wrote:
>>
>> Hi Luis,
>>
>> On Thu, Dec 10, 2015 at 7:10 AM, Luis Masuelli  
>> wrote:
>>
>>> When I see the docs (
>>> https://docs.djangoproject.com/en/1.8/ref/models/querysets/#extra), I 
>>> notice .extra will be deprecated and removed. Is there a plan for the 
>>> replacement? As I see it, limiting ourselves to using Manager.raw() is not 
>>> a good idea, since you cannot work anymore on a RawQueryset object (as you 
>>> can work on any Queryset object you called .extra). So my question is: Is 
>>> there a good replacement for .extra being planned?
>>>
>>
>> Yes - the Query Expression API.
>>
>> https://docs.djangoproject.com/en/1.9/ref/models/expressions/
>>
>> Yours,
>> Russ Magee %-)
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ec4072cf-65d5-4a9d-9afb-8362b3857de6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: RemoteUserMiddleware stay logged in

2015-12-02 Thread Dan Davis
Thanks,

I can probably just install it and use it.   If I must stay in 1.8 for some 
arcane reason, I can read the code at https://github.com/django/django.

On Monday, November 30, 2015 at 8:29:00 PM UTC-5, Tim Graham wrote:
>
> Does the PersistentRemoteUserMiddleware added in Django 1.9 help?
>
>
> https://docs.djangoproject.com/en/1.9/howto/auth-remote-user/#using-remote-user-on-login-pages-only
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a5ea3adf-1e9e-491d-abdb-67437ce23f75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RemoteUserMiddleware stay logged in

2015-11-30 Thread Dan Davis
So, where I work we have a CAS server we like to use.   We like to use it 
with mod_auth_cas.So far, so good - RemoteUserMiddleware is my friend. 
  The problem here is that REMOTE_USER will not be set unless the URI is 
protected by CAS, and if the URI is protected by CAS, then the user will be 
redirected right away.This is fine for admin URLs, but I want the CAS 
cookie to be validated/checked only on some URLs, without redirect.So, 
REMOTE_USER should be set only if the cookie is present and valid.

Does anyone have any suggestions, either how I should change mod_auth_cas 
or my Apache directives to support this, or how I should change my use of 
RemoteUserMiddleware to allow this.

Thanks,

-Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f39f3b30-c418-4491-bd5d-2e4105544b9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unresolved references error in Pycharm Community edition

2015-11-28 Thread Dan Tagg
Agreed, but it is very good to use virualenv, a requirements file and then
set the PyCharm project interpreter to your virtualenv one, then PyCharm
picks up all the imports and can alert you if you're importing something
wrongly or if you want to view the declaration of a function. I also really
like django cookiecutter. https://github.com/pydanny/cookiecutter-django

Dan



On 28 November 2015 at 11:33, aftnix <aft...@gmail.com> wrote:

> On শুক্রবার 27 নভে 2015 03:04 অপরাহ্ণ, Sneha R wrote:
>
>> Hi,
>>
>> I am new to Pycharm and I am trying to run a Django project in Pycharm
>> Community edition 5.0.1 but there are few import errors saying
>> ''Unresolved reference'" . I am using Python 2.7. How do I solve this
>> error ?
>>
>> --
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>>
>> https://groups.google.com/d/msgid/django-users/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/django-users/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com?utm_medium=email_source=footer
>> >.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> Obviously you would first at least try to run the project from command
> line using "python manage.py runserver" before doing anything with an IDE.
> IDE's are never good choice for django development IMHO
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/565990F2.2030603%40gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY6okWECJCFbmU-Bx_Fz9xigUrVsN7ov30wnuyHbZFPJ3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get logged username in template

2015-11-12 Thread Dan Tagg
I would recommend using allauth
http://django-allauth.readthedocs.org/en/latest/templates.html. It has
template tags for adding all that info, creates pages for logging in, picks
up your base template etc etc.

Dan

On 12 November 2015 at 08:57, Andreas Kuhne <andreas.ku...@suitopia.com>
wrote:

> Hi,
>
> First of all, you are using request.user.username and not username in your
> template. If you want the username to be accessed via the "username"
> variable. You should write this in your view:
>
> def profile(request):
> return render_to_response('accounts/profile.html', {'username': 
> request.user.username})
>
> And then in your template use the following code:
>
> {{ username }}
>
>
> However if you want to use the request object you should use the
> RequestContext context when rendering the page. See
> https://docs.djangoproject.com/en/1.8/ref/templates/api/#subclassing-context-requestcontext
>
> Also because you are using django 1.8, I would recommend that you start
> using class based views instead of view functions. But that's just my
> preference :-)
>
> Regards,
>
> Andréas
>
>
> 2015-11-12 8:46 GMT+01:00 Dariusz Mysior <mysior.da...@gmail.com>:
>
>> I am using Django 1.8 with Python 3.4 I had no idea why my template
>> doesn't show my username on template profile.html :/
>>
>>
>> profile.py
>>
>>
>> {% load staticfiles %}
>>
>> 
>>
>> {% block content %}
>> My profile
>> {{ request.user.username }}
>> {% endblock %}
>>
>>
>> views.py
>>
>>
>> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
>> from django.shortcuts import render_to_response
>> from django.http import  HttpResponseRedirect
>> from django.core.context_processors import csrf
>> from django.contrib.auth import authenticate, login
>>
>>
>> def login_view(request):
>>
>> if request.method == 'POST':
>> username = request.POST['username']
>> password = request.POST['password']
>> user = authenticate(username=username, password=password)
>> if user is not None:
>> if user.is_active:
>> login(request, user)
>> return HttpResponseRedirect('/accounts/profile')
>> else:
>> # Return a 'disabled account' error message
>> ...
>> pass
>> else:
>> # Return an 'invalid login' error message.
>> pass
>> form = AuthenticationForm()
>> args = {}
>> args.update(csrf(request))
>> args['form']= AuthenticationForm()
>> return render_to_response('accounts/login.html', args)
>>
>> def my_view(request):
>> username = request.POST['username']
>> password = request.POST['password']
>> user = authenticate(username=username, password=password)
>> if user is not None:
>> print(request.user)
>> if user.is_active:
>> login(request, user)
>> return HttpResponseRedirect('/accounts/profile')
>> else:
>> # Return a 'disabled account' error message
>> ...
>> else:
>> # Return an 'invalid login' error message.
>> ...
>> def profile(request):
>> username = request.user.username
>> return render_to_response('accounts/profile.html', username)
>>
>> def register_user(request):
>> if request.method == 'POST':
>> form = UserCreationForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect('/accounts/register_success')
>> args = {}
>> args.update(csrf(request))
>> args['form']= UserCreationForm()
>> return render_to_response('accounts/register_user.html', args)
>>
>> def register_success(request):
>> return render_to_response('accounts/register_success.html')
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/88ec2289-59b6-41a3-a1d7-c41be3fc0b4b%40google

  1   2   3   4   5   >