Re: sqlite3 database encrytion for Django.

2017-05-05 Thread Antonis Christofides
Hi,

That's interesting. May I ask why you want to do this?

Regards,

A.

Antonis Christofides
http://djangodeployment.com

On 2017-05-05 21:51, agajesh...@atompower.com wrote:
> Hello everyone,
>
> I want to encrypt my sqlite3 database such that it cannot be accessed without
> a key. I came across "sqlcipher" tool which provides encryption for sqlite3
> database, but I couldn't find enough support to make it work from django. 
>
> It would be very helpful if someone can share thoughts on how to encrypt
> sqlite3 database and be able to access the encrypted version through django.
>
> Thank you,
>
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> .
> To 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/18ffcee8-3ff1-4202-9143-cd446bc424cc%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/f94d7c44-d099-f269-517e-581433e751e8%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Doesn't generate apps.py (polls tutorial)

2017-05-05 Thread 齊藤大将
Hello, I am a beginner.
When I run 
$ python manage.py startapp polls
only apps.py does not exist so I cannot proceed next step.
How can I deal with this problem ?
It would be appreciate if it is explained.

I am looking this page,
https://docs.djangoproject.com/en/1.11/intro/tutorial01/

-- 
You received this message because you are subscribed to the Google Groups 
"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/b02a8aec-f1a2-4886-8583-0cd6c43ab6ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels Using Tokens

2017-05-05 Thread Vahid Kowsari
Hi

I am working on the Backend for an app that uses Django Rest Framework as 
well as Django Channels. In order to make both of these work together I 
have had to implement my own decorators to get the Token from the message 
on Django Channels which works great. 

I get the token using the following decorator which I use when I am for the 
initial connection and the second for processing messages from the 
Websocket client. And can associate the channel with a user, however I need 
to be able to do this when the user 


def token_request_parameter(func):
"""
Checks the presence of a "token" request parameter and tries to
authenticate the user based on its content.
"""
@wraps(func)
def inner(message, *args, **kwargs):
# Taken from channels.session.http_session
try:
if "method" not in message.content:
message.content['method'] = "FAKE"
request = AsgiRequest(message)
except Exception as e:
raise ValueError("Cannot parse HTTP message - are you sure this is 
a HTTP consumer? %s" % e)

token = request.GET.get("token", None)
if token is None:
_close_reply_channel(message)
raise ValueError("Missing token request parameter. Closing 
channel.")

auth = TokenAuthentication()
user, _ = auth.authenticate_credentials(token)
message.token = token
message.user = user

return func(message, *args, **kwargs)
return inner


def token_message_text_field(func):
"""
Checks the presence of a "token" field on the message's text field and
tries to authenticate the user based on its content.
"""
@wraps(func)
def inner(message, *args, **kwargs):
if not hasattr(message, 'token'):
raise ValueError('Did not see a Token session to get auth from')

message_text = message.get('text', None)
if message_text is None:
_close_reply_channel(message)
raise ValueError("Missing text field. Closing channel.")

try:
message_text_json = json.loads(message_text)
except ValueError:
_close_reply_channel(message)
raise

token = message_text_json.pop('token', None)
if token is None:
_close_reply_channel(message)
raise ValueError("Missing token field. Closing channel.")
auth = TokenAuthentication()
user, _ = auth.authenticate_credentials(token)
message.token = token
message.user = user
message.text = json.dumps(message_text_json.get('message'))

return func(message, *args, **kwargs)
return inner


However I need to be able to know the user for disconnection. My question 
is how do I associate a disconnection to a user? The 
token_message_text_field doesnt seem to be able to get it.

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 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/1491fe41-275d-419c-bb3e-38fdecdfc35d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with deployment

2017-05-05 Thread Luiz Guilherme Silva
Hello Ahmed.

Why are you using apache instead of IIS? I know it's not the question, but
I've worked in a project running on IIS for a long time without big
problems, and you don't need Apache for this.

2017-05-04 16:00 GMT-03:00 sarfaraz ahmed :

> Hello Friends,
>
> I have an Windows 2016 Server edition on EC2.
> I install Apache 2.4 VC10 on my server and installed 2.7.13
>
> I am not able to find MOD_WSGI.SO for this combination.
>
> Can someone provide me steps to compile or link to download
>
> --
> Thanks with regards,
> Sarfaraz Ahmed
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAEPJdixOMiS%3DBsPusybJaoKhJfaa1Pfqy6D3ND%
> 3DEOQ8EkbsnDA%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/CAPgKrJ2V6OWuJ6ZTQVASYa1aUtMpgm-TeQ0EJxODqZ3i78tt%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: php

2017-05-05 Thread James Bennett
Please remember that Django's Code of Conduct applies here, and asks all of
us to be respectful of each other and constructive in disagreement.
Insulting a person's choice of programming language falls very much on the
wrong side of that.

As to the original question, there are people who've worked on ways to
integrate PHP code into Python-based projects, and one of them has been
linked in this thread. In general, though, it's likely that someone who
wants to use PHP would have more success with a PHP-based framework rather
than the technical difficulties involved in getting a multi-language
codebase to 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/CAL13Cg_WnCqUfwcO%2BxJDSJZiZM%3DoRkBWFwuFP65RqNijqq-_hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Link to download

2017-05-05 Thread 'Abraham Varricatt' via Django users
That's an interesting project!

If I use WhiteNoise as part of a production deploy somewhere, can I skip 
(or ignore) running 'manage.py collectstatic' ? 

Yours,
Abraham V.


On Wednesday, 3 May 2017 15:13:36 UTC-4, Dan Tagg wrote:
>
> 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...@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/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/18c9354a-0325-4e53-ad4c-2bda5e7a2877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: php

2017-05-05 Thread Larry Martell
On Fri, May 5, 2017 at 3:28 PM, James Schneider  wrote:
>
> Can we add php code in our django framework to make it better
>
>
> No.
>
> Nothing can be made better by adding PHP to it.

LOL!

-- 
You received this message because you are subscribed to the Google Groups 
"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/CACwCsY7UM_uRbvnDzaOW7a5BK06fXc6RgaxnbT2LCZRgCqnxNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: php

2017-05-05 Thread carlos
i think read the source code here https://github.com/mvasilkov/django-php
maybe help you!

On Fri, May 5, 2017 at 8:45 AM, Saurabh Pathak 
wrote:

> Can we add php code in our django framework to make it 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-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/c60439cf-77fe-43c7-abef-f19f8b9dc51b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
att.
Carlos Rocha

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAM-7rO1rotxA%2BpvOL7f9cFgcJYxLfDea8kM_6BoCPUF8CWNeHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: php

2017-05-05 Thread James Schneider
Can we add php code in our django framework to make it better


No.

Nothing can be made better by adding PHP to it.

If you want to write PHP code, I'd suggest finding a framework in that
language.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"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/CA%2Be%2BciXJyqYrpzFkP3CT3wYpebk_8P8Pv%3DbrExo-0gXrxZiscA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sqlite3 database encrytion for Django.

2017-05-05 Thread Malcolm MacKinnon
I suggest you consider using keyzar and django-encrypted-fields. Here's the
code: https://github.com/defrex/django-encrypted-fields/


On Fri, May 5, 2017 at 11:51 AM,  wrote:

> Hello everyone,
>
> I want to encrypt my sqlite3 database such that it cannot be accessed
> without a key. I came across "sqlcipher" tool which provides encryption for
> sqlite3 database, but I couldn't find enough support to make it work from
> django.
>
> It would be very helpful if someone can share thoughts on how to encrypt
> sqlite3 database and be able to access the encrypted version through django.
>
> Thank you,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/18ffcee8-3ff1-4202-9143-cd446bc424cc%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/CAK8W3XoK5Q74dffTj-wtf8hb%2Bm9YQQNobxh0eW%2B2y2ki4b6yZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


sqlite3 database encrytion for Django.

2017-05-05 Thread agajeshwar
Hello everyone,

I want to encrypt my sqlite3 database such that it cannot be accessed 
without a key. I came across "sqlcipher" tool which provides encryption for 
sqlite3 database, but I couldn't find enough support to make it work from 
django. 

It would be very helpful if someone can share thoughts on how to encrypt 
sqlite3 database and be able to access the encrypted version through django.

Thank you,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/18ffcee8-3ff1-4202-9143-cd446bc424cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-05 Thread Prashant Verma
Only for window users: 

Follow the below steps to install gdal into the window environment:

Step 1: Install OSGeo4W

The OSGeo4W installer makes it simple to install the PROJ.4, GDAL, and GEOS 
libraries required by GeoDjango. First, download the OSGeo4W installer, and 
run it. Select Express Web-GIS Install and click next. In the ‘Select 
Packages’ list, ensure that GDAL is selected; MapServer and Apache are also 
enabled by default, but are not required by GeoDjango and may be unchecked 
safely. After clicking next, the packages will be automatically downloaded 
and installed, after which you may exit the installer.

for 32bit: http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe
for 64bit: http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe

Step 2: Modify Windows environment

In order to use GeoDjango, you will need to add your Python and OSGeo4W 
directories to your Windows system Path, as well as create GDAL_DATA and 
PROJ_LIB environment variables. The following set of commands, executable 
with cmd.exe, will set this up:

set OSGEO4W_ROOT=C:\OSGeo4W
set PYTHON_ROOT=C:\Python27
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" 
/v Path /t REG_EXPAND_SZ /f /d "%PATH%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" 
/v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" 
/v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"

Copy the above script into notepad or any editor and save the file name by 
geodjango_setup.bat

Note: 1 

Administrator privileges are required to execute these commands. To do 
this, right-click on geodjango_setup.bat and select Run as administrator. 
You need to log out and log back in again for the settings to take effect.

Note: 2

If you customised the Python or OSGeo4W installation directories, then you 
will need to modify the OSGEO4W_ROOT and/or PYTHON_ROOT variables 
accordingly. 

For more details: 
https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/#windows

-- 
You received this message because you are subscribed to the Google Groups 
"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/a2ee9953-f467-4c11-bdd0-33b9b082e3d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


php

2017-05-05 Thread Saurabh Pathak
Can we add php code in our django framework to make it 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-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/c60439cf-77fe-43c7-abef-f19f8b9dc51b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with CircularDependency Model

2017-05-05 Thread Dartos
Sorry, my earlier suggestion for Institute.members is incorrect. Here's the 
correct code:
def members(self):
return self.user_set.all() 

For example, if foo is an institute, then foo.user_set.all() would give all 
users related to that institution.

Dartos

On Friday, May 5, 2017 at 11:00:46 AM UTC-4, Dartos wrote:
>
> Hi,
>
> Have you tried breaking up the migrations into multiple steps?
>
> First create User and Institute without reference to each other. Then try 
> additional migrations.
>
> Also, you can simplify Institute.members using reverse relations as 
> follows:
> def members(self):
> return Institute.user_set.all() 
>
> Dartos
>
> On Friday, May 5, 2017 at 8:41:52 AM UTC-4, Tobias Dacoir wrote:
>>
>> I am trying to build a model (in two separate apps) which has the 
>> following constraints:
>>
>> - There can be many institutes
>> - there can many users
>> - each user is a member of exactly one institute
>> - each institute has exactly one master user
>>
>> However I am running into CircularDependency errors when trying to create 
>> this model and database. Of course this model is a bit problematic because 
>> you can't have an institute without master user, but also you can't create 
>> a user without some default institute. How do I fix this? Should I be more 
>> lean on the model side and allow for a lot of blanks and null values and 
>> make all the exception handling somewhere else? 
>>
>> Please tell me how to improve my model.
>>  
>>
>>>
 class User(AbstractBaseUser, PermissionsMixin):
>>>
>>> # account-related information
>>> institute = models.ForeignKey(Institute, blank=True, null=True, 
>>> on_delete=models.SET(get_default_institute))
>>> username = ...
>>> 
>>>
>>> This is the model in another app for the institutes
>>>
>>> class Institute(models.Model):
>>> master_user = models.ForeignKey(settings.AUTH_USER_MODEL, 
>>> related_name='master_user')
>>> name = models.CharField(max_length=255)
>>>
>>> def members(self):
>>> UserModel = apps.get_model('play', 'User')  # need to avoid 
>>> circular import
>>> return UserModel.objects.filter(institute=self)
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"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/22708991-71f6-47fd-9c1c-108d8c0bc976%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatic content types removal

2017-05-05 Thread marcin . j . nowak
Thanks, Tim. I'll take a look at this.  
 

> From the Django 1.11 release notes:
>
>- The prompt for stale content type deletion no longer occurs after 
>running the migrate command. Use the new remove_stale_contenttypes 
>
> 
> command instead.
>
> In older versions of Django, stale content type deletion doesn't happen 
> unless you type "yes" to the prompt that happens after migrate.
>
> On Friday, May 5, 2017 at 8:41:18 AM UTC-4, marcin@gmail.com wrote:
>>
>> Hi.
>>
>> Why Django automatically removes content types? 
>>
>> Due to lack of flexibility in auth system I was forced to create custom 
>> content type for custom perms.
>> Now I've realized that my custom content type is missing.
>> I am not sure, of course, but I think that Django removed my CT silently.
>>
>> I know that clearing content types is OK, maybe required, but it SHOULD 
>> NOT to be run automatically!
>> Deleting the data is a risky operation and should be called on demand.
>>
>> Is possible to disable automatic CT deletion?
>>
>>
>> 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/e7128eeb-b798-49ee-a60f-400c046ff249%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with CircularDependency Model

2017-05-05 Thread Dartos
Hi,

Have you tried breaking up the migrations into multiple steps?

First create User and Institute without reference to each other. Then try 
additional migrations.

Also, you can simplify Institute.members using reverse relations as follows:
def members(self):
return Institute.user_set.all() 

Dartos

On Friday, May 5, 2017 at 8:41:52 AM UTC-4, Tobias Dacoir wrote:
>
> I am trying to build a model (in two separate apps) which has the 
> following constraints:
>
> - There can be many institutes
> - there can many users
> - each user is a member of exactly one institute
> - each institute has exactly one master user
>
> However I am running into CircularDependency errors when trying to create 
> this model and database. Of course this model is a bit problematic because 
> you can't have an institute without master user, but also you can't create 
> a user without some default institute. How do I fix this? Should I be more 
> lean on the model side and allow for a lot of blanks and null values and 
> make all the exception handling somewhere else? 
>
> Please tell me how to improve my model.
>  
>
>>
>>> class User(AbstractBaseUser, PermissionsMixin):
>>
>> # account-related information
>> institute = models.ForeignKey(Institute, blank=True, null=True, 
>> on_delete=models.SET(get_default_institute))
>> username = ...
>> 
>>
>> This is the model in another app for the institutes
>>
>> class Institute(models.Model):
>> master_user = models.ForeignKey(settings.AUTH_USER_MODEL, 
>> related_name='master_user')
>> name = models.CharField(max_length=255)
>>
>> def members(self):
>> UserModel = apps.get_model('play', 'User')  # need to avoid 
>> circular import
>> return UserModel.objects.filter(institute=self)
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"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/f100ae07-d263-49d6-86af-8eed6487b558%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django forks / clones / wrappers

2017-05-05 Thread Andréas Kühne
Hi,

As far as I know, there is nothing that is compatible with Django and is
not Django? I don't really understand what you are trying to do either, and
why you don't want to use Django. From what you have written I am guessing
that you want the models/db layer and forms part from Django?

What I would do is use those parts of Django only. You can see an example
of this here:
http://softwaremaniacs.org/blog/2011/01/07/django-micro-framework/en/

I have heard of other examples in doing things like that as well. Just
because Django comes with batteries included, doesn't mean you have to use
the batteries...

I myself have looked at using flask instead of Django for certain things,
but have always come back to the fact that I like the db models, the forms
and especially the class based views too much.

Regards,

Andréas

2017-05-05 15:00 GMT+02:00 :

> Hi
>
> Does anyone know a web framework, non full-stack / microframework, but
> partially compatible with Django (in terms of the programming interface)?
> Django have too many design flaws for big projects, so I'd like to move
> into something less coupled. Any bridges / wrappers for Flask maybe?
>
> The core is highly based on models/db layer, and data input is based
> mostly on forms and modelforms. Everything else is easy to reimplement,
> relatively.
> Admin, postgis and most of contribs are not necessary.
>
> Thanks,
> 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/54820317-f542-4026-94b6-12375e2c756d%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/CAK4qSCfLy866iGg_1MdOPShRMThNL25x%3D3HQM-GBWiTXizvkeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatic content types removal

2017-05-05 Thread Tim Graham
>From the Django 1.11 release notes:

   - The prompt for stale content type deletion no longer occurs after 
   running the migrate command. Use the new remove_stale_contenttypes 
   

command instead.

In older versions of Django, stale content type deletion doesn't happen 
unless you type "yes" to the prompt that happens after migrate.

On Friday, May 5, 2017 at 8:41:18 AM UTC-4, marcin@gmail.com wrote:
>
> Hi.
>
> Why Django automatically removes content types? 
>
> Due to lack of flexibility in auth system I was forced to create custom 
> content type for custom perms.
> Now I've realized that my custom content type is missing.
> I am not sure, of course, but I think that Django removed my CT silently.
>
> I know that clearing content types is OK, maybe required, but it SHOULD 
> NOT to be run automatically!
> Deleting the data is a risky operation and should be called on demand.
>
> Is possible to disable automatic CT deletion?
>
>
> 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/ed95cde6-0cfa-4e57-a4d2-fc7dcc0702ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {{ form }} vs {{ form }}

2017-05-05 Thread guettli


Am Donnerstag, 4. Mai 2017 16:03:25 UTC+2 schrieb Todor Velichkov:
>
> Take a look at:
> 1) Form rendering options 
> 
> 2) Outputting forms as HTML 
> 
>
> {{ form }} and {{ form.as_table }} are basically the same.
> So in terms of valid markup {{ form }} would be more 
> correct.
>
>
OK,  {{ form }} is what I do now. Somehow I am unsure if 
this is really the best way.

But I will do this for until I find a better solution.

Thank you Todor for your answer.

-- 
You received this message because you are subscribed to the Google Groups 
"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/bcdeda9c-0c58-4d07-abfd-10409c65624b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django forks / clones / wrappers

2017-05-05 Thread marcin . j . nowak
Hi

Does anyone know a web framework, non full-stack / microframework, but 
partially compatible with Django (in terms of the programming interface)?
Django have too many design flaws for big projects, so I'd like to move 
into something less coupled. Any bridges / wrappers for Flask maybe?

The core is highly based on models/db layer, and data input is based mostly 
on forms and modelforms. Everything else is easy to reimplement, relatively.
Admin, postgis and most of contribs are not necessary.

Thanks,
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/54820317-f542-4026-94b6-12375e2c756d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error was: cannot import name 'GDALRaster in Window 8.1

2017-05-05 Thread Prashant Verma
I have installed it now. But It's showing some error with version. Can you 
tell me what is this? How can I able to fix this? 

C:\Users\Prashant>*gdalinfo --version*
ERROR 1: Can't load requested DLL: C:\Program 
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program 
Files\GDAL\gdalplugins\ogr_MSSQLSp
atial.dll
126: The specified module could not be found.

*GDAL 2.1.3, released 2017/20/01*

On Friday, 5 May 2017 00:43:36 UTC+5:30, Daniel Wiesmann wrote:
>
> Your question regarding raster2pgsql has nothing to do with Django, so please 
> ask questions related to that somewhere else (for instance 
> onhttps://gis.stackexchange.com/ )
>
> Regarding your first error, could you share the output of the following 
> command on your command line:
>
> gdalinfo --version
>
> (just to check if you have gdal installed)
>
> I agree that the above error message is not useful for users that want to use 
> postgis but dont have gdal installed. Maybe its related to the gdal path or 
> something else. GDAL should be installed as postgis itself already requires 
> gdal.
> http://postgis.net/docs/manual-2.3/postgis_installation.html#install_requirements
>
>
>
> On Sunday, April 30, 2017 at 3:20:01 PM UTC+1, Prashant Verma wrote:
>>
>> C:\User\.\Desktop\Geolocation>*python manage.py makemigrations*
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\utils.py",
>>  
>> line 115, in load_backend
>> return import_module('%s.base' % backend_name)
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>>  
>> line 126, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 978, in _gcd_import
>>   File "", line 961, in _find_and_load
>>   File "", line 950, in 
>> _find_and_load_unlocked
>>   File "", line 655, in _load_unlocked
>>   File "", line 677, in exec_module
>>   File "", line 205, in 
>> _call_with_frames_removed
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py",
>>  
>> line 7, in 
>> from .operations import PostGISOperations
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\gis\db\backends\postgis\operations.py",
>>  
>> line 7, in 
>> from django.contrib.gis.gdal import GDALRaster
>> ImportError: cannot import name 'GDALRaster'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 22, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>>  
>> line 363, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\core\management\__init__.py",
>>  
>> line 337, in execute
>> django.setup()
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\__init__.py",
>>  
>> line 27, in setup
>> apps.populate(settings.INSTALLED_APPS)
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\registry.py",
>>  
>> line 108, in populate
>> app_config.import_models()
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\apps\config.py",
>>  
>> line 202, in import_models
>> self.models_module = import_module(models_module_name)
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\importlib\__init__.py",
>>  
>> line 126, in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 978, in _gcd_import
>>   File "", line 961, in _find_and_load
>>   File "", line 950, in 
>> _find_and_load_unlocked
>>   File "", line 655, in _load_unlocked
>>   File "", line 677, in exec_module
>>   File "", line 205, in 
>> _call_with_frames_removed
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\models.py",
>>  
>> line 4, in 
>> from django.contrib.auth.base_user import AbstractBaseUser, 
>> BaseUserManager
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\contrib\auth\base_user.py",
>>  
>> line 52, in 
>> class AbstractBaseUser(models.Model):
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>>  
>> line 124, in __new__
>> new_class.add_to_class('_meta', Options(meta, app_label))
>>   File 
>> "C:\Users\Prashant\Desktop\Geolocation\casino_locater\lib\site-packages\django\db\models\base.py",
>>  
>> line 330, in add_to_class
>> value.contribute_to_class(cls, name)
>>   File 
>> 

Problem with CircularDependency Model

2017-05-05 Thread Tobias Dacoir
I am trying to build a model (in two separate apps) which has the following 
constraints:

- There can be many institutes
- there can many users
- each user is a member of exactly one institute
- each institute has exactly one master user

However I am running into CircularDependency errors when trying to create 
this model and database. Of course this model is a bit problematic because 
you can't have an institute without master user, but also you can't create 
a user without some default institute. How do I fix this? Should I be more 
lean on the model side and allow for a lot of blanks and null values and 
make all the exception handling somewhere else? 

Please tell me how to improve my model.
 

>
>> class User(AbstractBaseUser, PermissionsMixin):
>
> # account-related information
> institute = models.ForeignKey(Institute, blank=True, null=True, 
> on_delete=models.SET(get_default_institute))
> username = ...
> 
>
> This is the model in another app for the institutes
>
> class Institute(models.Model):
> master_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name
> ='master_user')
> name = models.CharField(max_length=255)
>
> def members(self):
> UserModel = apps.get_model('play', 'User')  # need to avoid 
> circular import
> return UserModel.objects.filter(institute=self)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/6243e47f-f526-4d08-88ac-07034583201c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Automatic content types removal

2017-05-05 Thread marcin . j . nowak
Hi.

Why Django automatically removes content types? 

Due to lack of flexibility in auth system I was forced to create custom 
content type for custom perms.
Now I've realized that my custom content type is missing.
I am not sure, of course, but I think that Django removed my CT silently.

I know that clearing content types is OK, maybe required, but it SHOULD NOT 
to be run automatically!
Deleting the data is a risky operation and should be called on demand.

Is possible to disable automatic CT deletion?


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/e3f62088-3d24-42a3-8d21-e0418cfaafd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Redirect from auth backend

2017-05-05 Thread roboslone -
Hello,

I have an authentication backend, that authenticates users against a remote 
service using session cookie.
Mentioned cookie can expire and remote service requires users to refresh it by 
visiting that service's URL (https://auth-service.com/renew?...).

Cookie expiration is managed by that remote service, so my auth backend knows 
when cookie needs to be renewed before authenticating the user.

Is there a way to redirect user from auth backend?

-- 
You received this message because you are subscribed to the Google Groups 
"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/65F31125-3021-4D05-831D-24B814DBC495%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


choices choice utility

2017-05-05 Thread Mike Dewhirst
Because I use many of the same constants in different apps in my project 
I keep most of them including almost all choices in a single __init__.py 
file and import them wherever required.


Here is a tiny utility I use all the time ... whenever 
get__display() is inappropriate.



def choose(choices, choice):
for pair in choices:
if pair[0] == choice:
return pair[1]
for section in choices:
for pair in section[1]:
if pair[0] == choice:
return pair[1]


Hope someone finds it useful. Also, I'm sure it can be made much more 
pythonic. It is Friday after all :)


Cheers

Mike




--
You received this message because you are subscribed to the Google Groups "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/fe15d311-84bf-99fc-1511-767c83572e3b%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.11 login user

2017-05-05 Thread ludovic coues
My guess is that your error happen when accessing the page before
submitting the firm. So you don't have any POST data and trying to access
any key rise an error.

You can use request.POST.get("key", "default_value") or you can write an if
and testing that request.method is "POST".

If I'm wrong, I suggest you share your template with your form.

A few tips for your future with django, not really related to your problem.
First, django provide a Form API which can handle form creation and
validation.
The doc is here
https://docs.djangoproject.com/en/1.11/ref/forms/api/
And django already provide a few of these for authentication, the doc for
the login form is here:
https://docs.djangoproject.com/en/1.8/topics/auth/default/#django.contrib.auth.forms.AuthenticationForm

If you have trouble to understand​ how to use the form API, I recommend the
django girls tutorial on the subject. That helped me a lot.

A next step would be to look at class based view and check if there is one
for login. I've heard about that but never looked. If that true, you might
be able to get your view, as simply as declaring a class inheriting from
the django login view and putting a template attribute in your class
pointing to your template file

Anyway, good luck with your issue

On 5 May 2017 1:03 am, "sum abiut"  wrote:

Hi,
 i have try to login user using the guide from
https://docs.djangoproject.com/en/1.11/topics/auth/default/

but get an error. Can someone advise what i am doin wrong here



he is my view.py

#Authentication user
def login(request):
username=request.POST['username']
password=request.POST['password']
user=authenticate(request,username=username,password=password)
if user is not None:
login(request,user)
#Redirect to dashboard page
return render(request,'dashboard.html')
else:
# return invalid login message
return HttpResponse( 'You have enter a wrong password or username
please again')



Error message:


Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/login/

Django Version: 1.11
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'fundmanager']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/root/.virtualenvs/benchmark/local/lib/python2.7/site-packa
ges/django/core/handlers/exception.py" in inner
  41. response = get_response(request)

File "/root/.virtualenvs/benchmark/local/lib/python2.7/site-packa
ges/django/core/handlers/base.py" in _get_response
  187. response = self.process_exception_by_middleware(e,
request)

File "/root/.virtualenvs/benchmark/local/lib/python2.7/site-packa
ges/django/core/handlers/base.py" in _get_response
  185. response = wrapped_callback(request, *callback_args,
**callback_kwargs)

File "/var/www/projects/benchmark/fundmanager/views.py" in login
  22. username=request.POST['username']

File "/root/.virtualenvs/benchmark/local/lib/python2.7/site-packa
ges/django/utils/datastructures.py" in __getitem__
  85. raise MultiValueDictKeyError(repr(key))

Exception Type: MultiValueDictKeyError at /login/
Exception Value: "u'username'"

-- 
You received this message because you are subscribed to the Google Groups
"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/CAPCf-y4Lg1ZkqDA4TR7RuV6z-gutuKmzFZ%2BvpQsr
%3DUnqXV2OkA%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/CAEuG%2BTb%3DzQktCUen5iRfLi2tGm2y6iXbMEuOL8NHHetGR%2B-atg%40mail.gmail.com.
For more options, visit