Re: Beginner question regarding virtualenv

2016-06-23 Thread Tiglath Suriol


On Thursday, June 23, 2016 at 2:38:45 PM UTC-4, Leo wrote:
>
> Hey Everyone,
>
>
> I’m a total newb to using Django and open stack. I am working on creating 
> a Django development environment in a VMware environment/Ubuntu OS. 
> Eventually I want to deploy this to production.  The site’s purpose is as 
> an intranet site.
>
>
> I have been following the Django tutorial but recently discovered some 
> other Django tutorials which led me to posting this question. I didn’t 
> create a Python vitrualenv rather installed everything at the root of the 
> OS. I am unsure if this will cause me problems or if I can proceed with 
> this approach. I do not plan to use the VM for anything else but this 
> specific intranet site.
>
>
> Thanks for your help.
>
> LV
>

No problems necessarily.  You can have a machine-wide Python environment, 
and then separate isolated one in any number of virtualenv environments.  
You keep track of which one you are using by chaning directory and 
activating virtualenv environments, or by getting out of them with 
'deactivate'  It's your choice which one to use and why. 

 

-- 
You received this message because you are subscribed to the Google Groups 
"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/35ce8ea5-bb77-4b4c-8c3a-67e369012c65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


python manage.py runserver error

2016-06-23 Thread Saranyoo Tiaakekalap
Guys - I am new to django, need some advise .
I am trying to learn how to use django from official web, while I am
running through step by step .

Just the beginning of the first step while I try to start server I hit into
issue .
There is no change in any python after start project .
Appreciate all the advice .

[root@jpetetis mysite]# python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by 
Traceback (most recent call last):
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/utils/aut
 oreload.py", line 226, in wrapper
fn(*args, **kwargs)
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana
 gement/commands/runserver.py", line 117, in
inner_run
self.check_migrations()
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana
 gement/commands/runserver.py", line 163, in
check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/loader.py", line 49, in __init__
self.build_graph()
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/loader.py", line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/recorder.py", line 65, in applied_migrations
self.ensure_schema()
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/recorder.py", line 56, in ensure_schema
with self.connection.schema_editor() as editor:
  File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/backen
 ds/sqlite3/schema.py", line 25, in __enter__
self._initial_pragma_fk = c.fetchone()[0]
TypeError: 'NoneType' object has no attribute '__getitem__'

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


Re: Beginner question regarding virtualenv

2016-06-23 Thread Mike Dewhirst

On 24/06/2016 4:36 AM, Leo wrote:

Hey Everyone,


I’m a total newb to using Django and open stack. I am working on
creating a Django development environment in a VMware environment/Ubuntu
OS. Eventually I want to deploy this to production.  The site’s
purpose is as an intranet site.


I have been following the Django tutorial but recently discovered some
other Django tutorials which led me to posting this question. I didn’t
create a Python vitrualenv rather installed everything at the root of
the OS. I am unsure if this will cause me problems or if I can proceed
with this approach. I do not plan to use the VM for anything else but
this specific intranet site.


The whole reason virtual environments were invented was because it is 
too expensive to use VMs in order to isolate your developments from each 
other. If that VM won't be used for other projects you can postpone 
using virtualenv until you want to work on more than one version of that 
project or you want multiple projects with varying dependencies.






Thanks for your help.

LV

--
You received this message because you are subscribed to the Google
Groups "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/f2afd0a2-9644-4818-98d5-85bad724cae6%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/c088e456-2ad0-cf52-0b2f-324f68aee508%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Inconsistent dedent error

2016-06-23 Thread Gary Roach

On 06/23/2016 02:41 PM, Erik Cederstrand wrote:

Den 23. jun. 2016 kl. 21.21 skrev Gary Roach :

class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def _str__(self):
return self.choice_text

The last entry (def __str__(self): throws an error "inconsistent dedent at line 
 I can find nothing wrong.

The error is actually in the line above. Your field definitions are 7-space 
indented when they should only be 3- or 4-space indented.

Python requires you to have consistent indenting, preferably 4 spaces per every 
indentation level. Your editor should help you with that. See 
https://www.python.org/dev/peps/pep-0008/#indentation

Erik


Thanks,

Another pair of eyes never hurts.

Gary R.

--
You received this message because you are subscribed to the Google Groups "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/00e864c5-6f91-3c05-0635-861e80096768%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Inconsistent dedent error

2016-06-23 Thread Erik Cederstrand

> Den 23. jun. 2016 kl. 21.21 skrev Gary Roach :
> 
> class Choice(models.Model):
>question = models.ForeignKey(Question, on_delete=models.CASCADE)
>choice_text = models.CharField(max_length=200)
>votes = models.IntegerField(default=0)
> 
>def _str__(self):
>return self.choice_text
> 
> The last entry (def __str__(self): throws an error "inconsistent dedent at 
> line  I can find nothing wrong.

The error is actually in the line above. Your field definitions are 7-space 
indented when they should only be 3- or 4-space indented.

Python requires you to have consistent indenting, preferably 4 spaces per every 
indentation level. Your editor should help you with that. See 
https://www.python.org/dev/peps/pep-0008/#indentation

Erik

-- 
You received this message because you are subscribed to the Google Groups 
"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/D7F096DD-DC1E-4A51-9723-66C9EABFEFD8%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Password hasher for vBulletin?

2016-06-23 Thread ludovic coues
Do you have extra good reason to call hashlib function with a variable
called password ?

If you simply want to hash user password, django provide a few
function for that job [1].

it's used like that:
>>> from django.contrib.auth.hashers import make_password, >>> check_password
>>> pwd = make_password("foobar")
>>> checkpassword("foobar", pwd)
Notice how you don't have to worry about thing like salt. Django take
care of that.

To answer your question, you are trying to concatenate
`hashlib.md5(force_bytes(password)).hexdigest()`, which is a str and
`force_bytes(salt)`, which is a bytes. You can add a str() aroung the
second part or a force_bytes around the first one.


[1] https://docs.djangoproject.com/en/1.9/topics/auth/passwords/

2016-06-23 17:09 GMT+02:00  :
> As a follow-up question to this... this line gives the error "Can't convert
> 'bytes' object to str implicitly":
>
> vB_hash = hashlib.md5(hashlib.md5(force_bytes(password)).hexdigest() +
> force_bytes(salt)).hexdigest()
>
>
> Do I need to insert a str() somewhere?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/c722dda1-009f-4bb0-b7a7-99bd9ffb2bbc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Re: Django urls.py reload (not from database)

2016-06-23 Thread Luis Zárate
I put all in urls and check permissions with

https://docs.djangoproject.com/en/1.9/topics/auth/default/#django.contrib.auth.decorators.user_passes_test

so if not

config.L7V_INITIALIZATED


I raise a 404 exception.

No need to reload urls.


2016-06-23 8:02 GMT-06:00 Thomas :

> Hy django lovers,
>
> it's my first post for being helped, sorry if I miss something.
>
> I want two list of urls available :
>
>- one (limited) before initializing (verify licence, etc...)
>- one (large) after initializing success
>
>
> Here is my settings.ROOT_URLCONF :
>
> from constance import config
>
> if not config.L7V_INITIALIZATED:
> urlpatterns = [
> url(r'^admin/', admin.site.urls),
> url(r'^initialization/', include('apps.initialization.urls'), 
> name='initialization'),
> ]
> else:
> urlpatterns = [
> url(r'^admin/', admin.site.urls),
> url(r'^dashboard/', include('apps.dashboard.urls')),
> url(r'^vmAPI/', include('apps.vmAPI.urls')),
> url(r'^protobook/', include('apps.protobook.urls')),
> ]
>
>
> config.L7V_INITIALIZATED is just a boolean updated if initialization has been 
> success.
>
> So, in my initialization view, I set the boolean to True and need to reload 
> settings.ROOT_URLCONF to understand the new list of urlpatterns.
>
>
> I saw a snippet but doesn't work under django 1.9 (says working under django 
> 1.4) :
>
>
> import sys
> from django.conf import settings
>
> def reload_urlconf(urlconf=None):
> if urlconf is None:
> urlconf = settings.ROOT_URLCONF
> if urlconf in sys.modules:
> reload(sys.modules[urlconf])
>
>
> I also tried the method 'django.core.urlresolvers.set_urlconf' but
> doesn't works..
>
>
> Any suggestions ?
>
>
> Thanks a lot !
>
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/2ac2ea9e-55eb-479f-9e30-271aeece1c26%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

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


Re: Beginner question regarding virtualenv

2016-06-23 Thread Leo
Gary and Daniele,

Looks like setting-up virtual environments is the way to go. Thanks for 
your help. I'm glad I asked before really digging in to serious development.

Leo

On Thursday, June 23, 2016 at 3:06:16 PM UTC-4, gary719_list1 wrote:
>
> On 06/23/2016 11:36 AM, Leo wrote:
> Hi Leo,
>
> The only problem with not using virtuaenv in your case is if you are still 
> periodically updating your software. Since you are using the OS versions of 
> python and django you are at the mercy of those upgrades. A switch from 
> Django 1.8 to 1.9 could break your project - as an example. A switch from 
> Python 2.7 to 3.5 will definitely break you project.  Also how you set up 
> depends on what IDE you are using. If you are just working with your 
> standard command line monitor then the virtual environment is fairly 
> straight forward. Use virtualevwrapper for python 2.7 but I would suggest 
> pyvenv for python 3. There are very good docs for those on the web. If you 
> are using an IDE, things could get more complicated. I'm using Eclipse with 
> PyDev and had fits with the setup. I finally created a virtual environment 
> in my /opt/ directory and, using pip, loaded it with Python3.5 and Django 
> 1.9. I never really open the virtualenv but just point to it in the IDE 
> setup. This seems to work so far.
>
> In short, be safe and setup a virtual environment. It will make migration 
> easier as well.
>
> Gary R.
>
> Hey Everyone,
>
>
> I’m a total newb to using Django and open stack. I am working on creating 
> a Django development environment in a VMware environment/Ubuntu OS. 
> Eventually I want to deploy this to production.  The site’s purpose is as 
> an intranet site.
>
>
> I have been following the Django tutorial but recently discovered some 
> other Django tutorials which led me to posting this question. I didn’t 
> create a Python vitrualenv rather installed everything at the root of the 
> OS. I am unsure if this will cause me problems or if I can proceed with 
> this approach. I do not plan to use the VM for anything else but this 
> specific intranet site.
>
>
> Thanks for your help.
>
> LV
> -- 
> You received this message because you are subscribed 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/f2afd0a2-9644-4818-98d5-85bad724cae6%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/b0ddb49d-0192-4121-959a-92e289f8cf26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: IntegrityError for unique_together ?

2016-06-23 Thread Derek
Thanks Simon

Those definitions are the closest I can get to the original in terms of
type and relationship; what other info is needed?

That ticket refers to child models inline - not my situation.

Upgrading is on the cards - but still has to be budgeted for

Derek

On 23 June 2016 at 21:26, Simon Charette  wrote:

> Hi Derek,
>
> It's hard to tell without your exact model admin definitions but I suspect
> this
> might be related to #25987[1] which is fixed in Django 1.10.
>
> By the way you should at least upgrade to 1.8 as your Django version is
> not supported anymore and you could be exposed to multiple security issues.
>
> Cheers,
> Simon
>
> [1] https://code.djangoproject.com/ticket/25987
>
>
> Le jeudi 23 juin 2016 14:44:10 UTC-4, Derek a écrit :
>>
>> Hi
>>
>> I have a strange situation (with Django 1.6.11 and MySQL 5.5). Attempting
>> to save a new entry (from the admin) with values that violate the
>> duplication restriction imposed by the unique_together constraint - in
>> other words a duplicate of a record already in the database - raises an
>> IntegrityError (stack trace listed at the end).
>>
>> The model looks like something like :
>>
>> name = CharField(
>> max_length=100)
>> title = ForeignKey(Title)
>> city = CharField(
>> max_length=50,
>> default=CITY_DEFAULT),
>> occupation = ForeignKey(Occupation)
>>
>> class Meta:
>> ordering = ['name']
>> unique_together = (('name', 'title', 'city', 'occupation', ),)
>>
>> I have also tested this situation in the shell. A normal clean() will not
>> raise any error, but a full_clean() will. Does that imply the code path
>> being triggered by an attempted save from within the admin does not call
>> full_clean() or attempt to trap an IntegrityError?
>>
>> I should add that `city` field is not on the form to be filled in; and is
>> added in the clean method.
>>
>> What is the best / correct solution to this?
>>
>> Thanks!
>> Derek
>>
>>
>> Traceback:
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/core/handlers/base.py"
>> in get_response
>>   112. response = wrapped_callback(request,
>> *callback_args, **callback_kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>> in wrapper
>>   465. return self.admin_site.admin_view(view)(*args,
>> **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>> in _wrapped_view
>>   99. response = view_func(request, *args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
>> in _wrapped_view_func
>>   52. response = view_func(request, *args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"
>> in inner
>>   198. return view(request, *args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>> in _wrapper
>>   29. return bound_func(*args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>> in _wrapped_view
>>   99. response = view_func(request, *args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>> in bound_func
>>   25. return func(self, *args2, **kwargs2)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/transaction.py"
>> in inner
>>   371. return func(*args, **kwargs)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>> in add_view
>>   1164. self.save_model(request, new_object, form, False)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>> in save_model
>>   893. obj.save()
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>> in save
>>   545.force_update=force_update,
>> update_fields=update_fields)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>> in save_base
>>   573. updated = self._save_table(raw, cls, force_insert,
>> force_update, using, update_fields)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>> in _save_table
>>   654. result = self._do_insert(cls._base_manager, using,
>> fields, update_pk, raw)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>> in _do_insert
>>   687.using=using, raw=raw)
>> File
>> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-package

Re: IntegrityError for unique_together ?

2016-06-23 Thread Simon Charette
Hi Derek,

It's hard to tell without your exact model admin definitions but I suspect 
this
might be related to #25987[1] which is fixed in Django 1.10.

By the way you should at least upgrade to 1.8 as your Django version is
not supported anymore and you could be exposed to multiple security issues.

Cheers,
Simon

[1] https://code.djangoproject.com/ticket/25987

Le jeudi 23 juin 2016 14:44:10 UTC-4, Derek a écrit :
>
> Hi
>
> I have a strange situation (with Django 1.6.11 and MySQL 5.5). Attempting 
> to save a new entry (from the admin) with values that violate the 
> duplication restriction imposed by the unique_together constraint - in 
> other words a duplicate of a record already in the database - raises an 
> IntegrityError (stack trace listed at the end).
>
> The model looks like something like :
>
> name = CharField(
> max_length=100)
> title = ForeignKey(Title)
> city = CharField(
> max_length=50,
> default=CITY_DEFAULT),
> occupation = ForeignKey(Occupation)
> 
> class Meta:
> ordering = ['name']
> unique_together = (('name', 'title', 'city', 'occupation', ),)
>
> I have also tested this situation in the shell. A normal clean() will not 
> raise any error, but a full_clean() will. Does that imply the code path 
> being triggered by an attempted save from within the admin does not call 
> full_clean() or attempt to trap an IntegrityError?
>
> I should add that `city` field is not on the form to be filled in; and is 
> added in the clean method.
>
> What is the best / correct solution to this?
>
> Thanks!
> Derek
>
>
> Traceback:
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/core/handlers/base.py"
>  
> in get_response
>   112. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>  
> in wrapper
>   465. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>  
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
>  
> in _wrapped_view_func
>   52. response = view_func(request, *args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"
>  
> in inner
>   198. return view(request, *args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>  
> in _wrapper
>   29. return bound_func(*args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>  
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
>  
> in bound_func
>   25. return func(self, *args2, **kwargs2)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/transaction.py"
>  
> in inner
>   371. return func(*args, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>  
> in add_view
>   1164. self.save_model(request, new_object, form, False)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
>  
> in save_model
>   893. obj.save()
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>  
> in save
>   545.force_update=force_update, 
> update_fields=update_fields)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>  
> in save_base
>   573. updated = self._save_table(raw, cls, force_insert, 
> force_update, using, update_fields)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>  
> in _save_table
>   654. result = self._do_insert(cls._base_manager, using, 
> fields, update_pk, raw)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
>  
> in _do_insert
>   687.using=using, raw=raw)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/manager.py"
>  
> in _insert
>   232. return insert_query(self.model, objs, fields, **kwargs)
> File 
> "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/query.py"
>  
> in insert_query
>   1514. return query.get_compiler(using=using).execute_sql(return_id)
> File 
> "/home/derek/.virtualenvs/reg/

Inconsistent dedent error

2016-06-23 Thread Gary Roach

Hi all,

The following code is part of the djangoproject.com/en/1.9/tutorial part 
2 in mysite/polls/models.py


class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __str__(self):
return self.question_text


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def _str__(self):
return self.choice_text

The last entry (def __str__(self): throws an error "inconsistent dedent 
at line  I can find nothing wrong. I have tried retyping the line 
with no results. I'm using Eclipse IDE with PyDev plugin. This is not 
just an annoyance. Any attempt to do migrate errors out with the same 
error. The code is typed verbatim from the tutorial.


I am at a loss as how to fix this . Please help.

Gary R.

--
You received this message because you are subscribed to the Google Groups "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/cc6df283-797a-64c3-bf3f-78aac9c80616%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Beginner question regarding virtualenv

2016-06-23 Thread Gary Roach

On 06/23/2016 11:36 AM, Leo wrote:
Hi Leo,

The only problem with not using virtuaenv in your case is if you are 
still periodically updating your software. Since you are using the OS 
versions of python and django you are at the mercy of those upgrades. A 
switch from Django 1.8 to 1.9 could break your project - as an example. 
A switch from Python 2.7 to 3.5 will definitely break you project.  Also 
how you set up depends on what IDE you are using. If you are just 
working with your standard command line monitor then the virtual 
environment is fairly straight forward. Use virtualevwrapper for python 
2.7 but I would suggest pyvenv for python 3. There are very good docs 
for those on the web. If you are using an IDE, things could get more 
complicated. I'm using Eclipse with PyDev and had fits with the setup. I 
finally created a virtual environment in my /opt/ directory and, using 
pip, loaded it with Python3.5 and Django 1.9. I never really open the 
virtualenv but just point to it in the IDE setup. This seems to work so far.


In short, be safe and setup a virtual environment. It will make 
migration easier as well.


Gary R.


Hey Everyone,


I’m a total newb to using Django and open stack. I am working on 
creating a Django development environment in a VMware 
environment/Ubuntu OS. Eventually I want to deploy this to 
production.  The site’s purpose is as an intranet site.



I have been following the Django tutorial but recently discovered some 
other Django tutorials which led me to posting this question. I didn’t 
create a Python vitrualenv rather installed everything at the root of 
the OS. I am unsure if this will cause me problems or if I can proceed 
with this approach. I do not plan to use the VM for anything else but 
this specific intranet site.



Thanks for your help.

LV

--
You received this message because you are subscribed to the Google 
Groups "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/f2afd0a2-9644-4818-98d5-85bad724cae6%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/fb57b312-37e0-4d9b-3220-a0a784356d17%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Beginner question regarding virtualenv

2016-06-23 Thread Daniele Procida
On Thu, Jun 23, 2016, Leo  wrote:

>I have been following the Django tutorial but recently discovered some 
>other Django tutorials which led me to posting this question. I didn't 
>create a Python vitrualenv rather installed everything at the root of the 
>OS. I am unsure if this will cause me problems or if I can proceed with 
>this approach. I do not plan to use the VM for anything else but this 
>specific intranet site.

You'll probably get away with it! But, using virtualenvs really will make your 
life easier and happier as you continue.

Daniele

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


IntegrityError for unique_together ?

2016-06-23 Thread Derek
Hi

I have a strange situation (with Django 1.6.11 and MySQL 5.5). Attempting
to save a new entry (from the admin) with values that violate the
duplication restriction imposed by the unique_together constraint - in
other words a duplicate of a record already in the database - raises an
IntegrityError (stack trace listed at the end).

The model looks like something like :

name = CharField(
max_length=100)
title = ForeignKey(Title)
city = CharField(
max_length=50,
default=CITY_DEFAULT),
occupation = ForeignKey(Occupation)

class Meta:
ordering = ['name']
unique_together = (('name', 'title', 'city', 'occupation', ),)

I have also tested this situation in the shell. A normal clean() will not
raise any error, but a full_clean() will. Does that imply the code path
being triggered by an attempted save from within the admin does not call
full_clean() or attempt to trap an IntegrityError?

I should add that `city` field is not on the form to be filled in; and is
added in the clean method.

What is the best / correct solution to this?

Thanks!
Derek


Traceback:
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
  112. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
in wrapper
  465. return self.admin_site.admin_view(view)(*args,
**kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
in _wrapped_view
  99. response = view_func(request, *args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
in _wrapped_view_func
  52. response = view_func(request, *args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"
in inner
  198. return view(request, *args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
in _wrapper
  29. return bound_func(*args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
in _wrapped_view
  99. response = view_func(request, *args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py"
in bound_func
  25. return func(self, *args2, **kwargs2)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/transaction.py"
in inner
  371. return func(*args, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
in add_view
  1164. self.save_model(request, new_object, form, False)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
in save_model
  893. obj.save()
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
in save
  545.force_update=force_update,
update_fields=update_fields)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
in save_base
  573. updated = self._save_table(raw, cls, force_insert,
force_update, using, update_fields)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
in _save_table
  654. result = self._do_insert(cls._base_manager, using,
fields, update_pk, raw)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py"
in _do_insert
  687.using=using, raw=raw)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/manager.py"
in _insert
  232. return insert_query(self.model, objs, fields, **kwargs)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/query.py"
in insert_query
  1514. return query.get_compiler(using=using).execute_sql(return_id)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py"
in execute_sql
  903. cursor.execute(sql, params)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/util.py"
in execute
  69. return super(CursorDebugWrapper, self).execute(sql,
params)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/util.py"
in execute
  53. return self.cursor.execute(sql, params)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/utils.py"
in __exit__
  99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File
"/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/bac

Beginner question regarding virtualenv

2016-06-23 Thread Leo


Hey Everyone,


I’m a total newb to using Django and open stack. I am working on creating a 
Django development environment in a VMware environment/Ubuntu OS. 
Eventually I want to deploy this to production.  The site’s purpose is as 
an intranet site.


I have been following the Django tutorial but recently discovered some 
other Django tutorials which led me to posting this question. I didn’t 
create a Python vitrualenv rather installed everything at the root of the 
OS. I am unsure if this will cause me problems or if I can proceed with 
this approach. I do not plan to use the VM for anything else but this 
specific intranet site.


Thanks for your help.

LV

-- 
You received this message because you are subscribed to the Google Groups 
"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/f2afd0a2-9644-4818-98d5-85bad724cae6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please help me with CBV template_name behaviour.

2016-06-23 Thread JoeCodeswell
Dear James,

Thanks for all the GREAT info. I'll be sure to look at 
#template-inheritance.


I'd be interested to see what the debug toolbar had to say while the typo 
> was in place. 
>

The contents of the debug toolbar that i published, in this thread, IN THIS 
POST , 
just before my afterthought post, *WAS "while the typo was in place". *I 
used the contents to discover the typo.

Thanks again, James for the info and the interest.

Love and peace,

Joe

On Wednesday, June 22, 2016 at 4:18:21 PM UTC-7, James Schneider wrote:
>
> On Tue, Jun 21, 2016 at 10:05 AM, JoeCodeswell  > wrote:
>
>> Dear James &  Django-Users,
>>
>> As an afterthought, I wonder why my misspelling didn't cause an error 
>> instead of a "wrong" Template being used?
>>
>> Any insights?
>>
>>
> Not particularly. That should have caused an error. The only way it 
> wouldn't have is if you have (or one of your installed apps has) a file 
> named crudlist.htm inside of a folder named contacts. I'd be interested to 
> see what the debug toolbar had to say while the typo was in place. 
>
> As far as your question about template inheritance earlier, here is the 
> link to the docs:
>
>
> https://docs.djangoproject.com/en/1.9/ref/templates/language/#template-inheritance
>
> -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/9fd4a2f0-752e-454c-8198-de02dd21f78f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django urls.py reload (not from database)

2016-06-23 Thread Thomas
Hy django lovers,

it's my first post for being helped, sorry if I miss something.

I want two list of urls available :

   - one (limited) before initializing (verify licence, etc...)
   - one (large) after initializing success


Here is my settings.ROOT_URLCONF :

from constance import config

if not config.L7V_INITIALIZATED:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^initialization/', include('apps.initialization.urls'), 
name='initialization'),
]
else:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^dashboard/', include('apps.dashboard.urls')),
url(r'^vmAPI/', include('apps.vmAPI.urls')),
url(r'^protobook/', include('apps.protobook.urls')),
]


config.L7V_INITIALIZATED is just a boolean updated if initialization has been 
success.

So, in my initialization view, I set the boolean to True and need to reload 
settings.ROOT_URLCONF to understand the new list of urlpatterns.


I saw a snippet but doesn't work under django 1.9 (says working under django 
1.4) :


import sys
from django.conf import settings

def reload_urlconf(urlconf=None):
if urlconf is None:
urlconf = settings.ROOT_URLCONF
if urlconf in sys.modules:
reload(sys.modules[urlconf])


I also tried the method 'django.core.urlresolvers.set_urlconf' but doesn't 
works..


Any suggestions ?


Thanks a lot !


Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/2ac2ea9e-55eb-479f-9e30-271aeece1c26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Password hasher for vBulletin?

2016-06-23 Thread jorrit787
As a follow-up question to this... this line gives the error "Can't convert 
'bytes' object to str implicitly":

vB_hash = hashlib.md5(hashlib.md5(force_bytes(password)).hexdigest() + 
force_bytes(salt)).hexdigest()


Do I need to insert a str() somewhere?

-- 
You received this message because you are subscribed to the Google Groups 
"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/c722dda1-009f-4bb0-b7a7-99bd9ffb2bbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


python manage.py runserver error

2016-06-23 Thread Saranyoo Tiaakekalap
Guys - I am new to django , while running through tutorial . I found issue 
when first start running 'python manage.py runserver' . 


After I installed 'django' and create my first project using command 
'django-admin 
startproject mysite' , then follow with 'python manage.py runserver' . 
I encounter error below . 
Can anyone please advise about this ? 

[root@jpetetis mysite]# python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by 
Traceback (most recent call last):
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/utils/autoreload.py",
 
line 226, in wrapper
fn(*args, **kwargs)
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/management/commands/runserver.py",
 
line 117, in inner_run
self.check_migrations()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/management/commands/runserver.py",
 
line 163, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrations/executor.py",
 
line 20, in __init__
self.loader = MigrationLoader(self.connection)
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrations/loader.py",
 
line 49, in __init__
self.build_graph()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrations/loader.py",
 
line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrations/recorder.py",
 
line 65, in applied_migrations
self.ensure_schema()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrations/recorder.py",
 
line 56, in ensure_schema
with self.connection.schema_editor() as editor:
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/backends/sqlite3/schema.py",
 
line 25, in __enter__
self._initial_pragma_fk = c.fetchone()[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
[root@jpetetis mysite]#
[root@jpetetis mysite]# cd

-- 
You received this message because you are subscribed to the Google Groups 
"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/98cac6d9-a164-455c-b353-6c42e84b5fba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django transaction rollback on deadlock detection

2016-06-23 Thread William Messer
As far as I can see, there's nothing in the django database doco about 
transaction failure due to deadlock detection in a multi-user environment. 
Does this mean that django retries transactions itself a number of times 
e.g., as google appengine does? I'm pretty sure this would have been 
mentioned if such were the case.
Alternatively, it's up to the programmer to handle deadlocks in code, e.g., 
by the following method that handles OperationalError exception:
except OperationalError as e:
code = e.args[0]
if attempts == 2 or code != 1213:
raise e
attempts += 1
time.sleep(0.2)
The above assumes the transaction is executed in a loop for retries to 
occur.

Is this the way to do it?





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