Re: No module named client

2017-02-13 Thread ludovic coues
I would do that to get more debugging information :

try:
from salt import client
except :
import salt
raise RuntimeError("[%s]" % ", ".join(dir(salt)))

If it work like I hope it does, it will print all the module from salt and
a bit more information.

Or you can do `print(dir(salt))` and read the results in the console




On 13 Feb 2017 12:42 a.m., "Pravin Kumar"  wrote:

> Hi All,
>
> I have imported below module in views.py, but i getting error "No module
> named client".
>
> import salt.client
>
>
> i can import this module in ipython but when i import it in Django app
> view, the app getting error while loading main page itself.
>
> *Error in web page:*
>
> ImportError at /salt/
>
> No module named client
>
>
> Please help guys!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/3a0d8fbc-2d84-4cd3-8217-80f5c654a1e7%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/CAEuG%2BTaJqttZu9nuvG5Mu6csSEiDyoePqbA7pJhZMKao796H%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't use psycopg2 2.7b1 with django

2017-02-13 Thread notsqrt
Hi Tim,

Ticket created at https://code.djangoproject.com/ticket/27830, with some 
additional info, and other potential places needed to be fixed.

Thanks,

Le vendredi 10 février 2017 20:40:42 UTC+1, Tim Graham a écrit :
>
> I think distutils.version.LooseVersion should be safe to use (django-cms 
> is using it, for example). Not sure about "packaging". Do you want to 
> create a Trac ticket for this issue? Probably the same technique could also 
> be used in other places.
>
> On Friday, February 10, 2017 at 5:58:29 AM UTC-5, not...@gmail.com wrote:
>>
>> Hi !
>>
>> psycopg2 is preparing a new release, and currently the git project uses PEP 
>> 440 -compatible version 
>> numbers : 2.7b1,  2.7b2.dev0 (see 
>> https://github.com/psycopg/psycopg2/blob/master/setup.py#L67) 
>>
>> In 
>> https://github.com/django/django/blob/master/django/db/backends/postgresql/base.py,
>>  
>> django parses that version string to check if it is greater than 2.4.5.
>>
>> But the psycopg2_version function can't handle version strings like 
>> 2.7b1, and returns (2,).
>>
>> Any ideas to improve django ?
>>
>> The "packaging" package could be used for that : 
>> https://packaging.pypa.io/en/latest/version/, a correct version parser 
>> does not seem simple !
>> Or "from distutils.version import LooseVersion"
>>
>> Thanks,
>> NotSqrt
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/9ce07f83-a4f3-4de4-99ce-8cd5ebb1043c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login when adding a superuser

2017-02-13 Thread ludovic coues
Have you tried to run makemigrations before migrate ?

On 12 Feb 2017 7:33 p.m., "Adam"  wrote:

> Hi Antonis, this is the full message including the command:
>
> :~/udemystuff/test_project# python manage.py createsuperuser
> /root/udemystuff/test_project/trydjango19/local/lib/python2.
> 7/site-packages/django/template/utils.py:37: RemovedInDjango110Warning:
> You haven't defined a TEMPLATES setting. You must do so before upgrading to
> Django 1.10. Otherwise Django will be unable to load templates.
>   "unable to load templates.", RemovedInDjango110Warning)
>
> /root/udemystuff/test_project/test_project/urls.py:11:
> RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and
> will be removed in Django 1.10. Update your urlpatterns to be a list of
> django.conf.urls.url() instances instead.
>   url(r'^admin/', include(admin.site.urls)),
>
> Username (leave blank to use 'root'): adams
> Email address:
> Password:
> Password (again):
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/core/management/__init__.py", line 350, in
> execute_from_command_line
> utility.execute()
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/core/management/__init__.py", line 342, in
> execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/core/management/base.py", line 348, in
> run_from_argv
> self.execute(*args, **cmd_options)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
> line 52, in execute
> return super(Command, self).execute(*args, **options)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/core/management/base.py", line 399, in
> execute
> output = self.handle(*args, **options)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
> line 173, in handle
> self.UserModel._default_manager.db_manager(database).
> create_superuser(**user_data)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/contrib/auth/models.py", line 165, in
> create_superuser
> return self._create_user(username, email, password, **extra_fields)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/contrib/auth/models.py", line 148, in
> _create_user
> user.save(using=self._db)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/contrib/auth/base_user.py", line 74, in
> save
> super(AbstractBaseUser, self).save(*args, **kwargs)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/base.py", line 700, in save
> force_update=force_update, update_fields=update_fields)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/base.py", line 728, in save_base
> updated = self._save_table(raw, cls, force_insert, force_update,
> using, update_fields)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/base.py", line 812, in
> _save_table
> result = self._do_insert(cls._base_manager, using, fields, update_pk,
> raw)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/base.py", line 851, in _do_insert
> using=using, raw=raw)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/manager.py", line 122, in
> manager_method
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/query.py", line 1039, in _insert
> return query.get_compiler(using=using).execute_sql(return_id)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/models/sql/compiler.py", line 1064, in
> execute_sql
> cursor.execute(sql, params)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
> return super(CursorDebugWrapper, self).execute(sql, params)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
> return self.cursor.execute(sql, params)
>   File "/root/udemystuff/test_project/trydjango19/local/lib/
> python2.7/site-packages/django/db/utils.py", line 95, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>   File "/root/udemystuff/

Re: Edx LDAP Auth setting

2017-02-13 Thread 'Faruk D.' via Django users
Hi Yip,

I could fix the issues. 

Thank you very much for your help. 

Kind regard 
Faruk 


-- 
You received this message because you are subscribed to the Google Groups 
"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/b705fee7-4319-4e75-8374-3ac94014d56c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to save children before parents?

2017-02-13 Thread ludovic coues
You could use a method instead of a property for the proportions.

https://docs.djangoproject.com/en/1.10/ref/utils/#django.utils.functional.cached_property
The cached_property decorator let you use the method like a property and
will cache the results so it's only computed once per objects.

On 13 Feb 2017 8:44 a.m., "Antonis Christofides" <
anto...@djangodeployment.com> wrote:

> Hello Mike,
>
> Could you paste (the necessary part of) your models.py? Otherwise it's not
> easy
> to understand _exactly_ what you are doing, and the exact details are
> playing a
> role here.
>
> Regards,
>
> Antonis
>
> Antonis Christofides
> http://djangodeployment.com
>
> On 02/13/2017 01:46 AM, Mike Dewhirst wrote:
> > On 13/02/2017 1:12 AM, Derek wrote:
> >> Mike
> >>
> >> Not sure I understand your scenario completely, but can you not just
> add a
> >> post-save trigger that updates the parent field (in which the total is
> saved)
> >> after all the other saves have happened?
> >
> > Derek
> >
> > That does not work and is one of the ways I have tried. I have also tried
> > pre-saving the ingredient proportions. [1]
> >
> > It is all triggered by saving the mixture and all happens at the database
> > level not in the browser.
> >
> > 1. Start with ingredients summing to 100% (A = 50% and B = 50%)
> > - mixture M displays 100% in its total field
> > - A displays 50% (nicely displayed via __str__(self))
> > - B displays 50%
> >
> > 2. Adjust B to 40% and click [Save]
> > - mixture gets saved and checks ingredient proportions (before or
> after it
> > gets saved itself) and M = 100% because B has not yet been saved and the
> > database still has it at 50%.
> >
> > 3. B gets saved as a related object and B = 40%
> >
> > 4. Refresh the page and predictably nothing changes because the database
> still
> > has M = 100%, A = 50%, B = 40%.
> >
> > 5. Click [Save] again and the mixture checks proportions again except
> this
> > time B = 40% so M correctly becomes 90% in the database and is correctly
> > displayed.
> >
> > I would love to adjust Substance_Ingredients._meta.verbose_name_plural
> to
> > display the total percentage and forget about storing it in the mixture
> > altogether. I only want a "live" display of the total to assure the user
> about
> > proportions.
> >
> > I have looked at adjusting verbose_name_plural in the admin but I can't
> figure
> > out how to get access to the proportions to do the sums.
> >
> > I have a horrible feeling I'm going to have to allocate some really
> scarce
> > brainspace to learning javascript. :-(
> >
> > Mike
> >
> > [1] I thought a pre-save would work but unfortunately not. If it
> *should* work
> > I must be doing something wrong. We really need to pre-save the
> ingredients
> > but it all happens in a single transaction which I think must succeed or
> be
> > rolled back.
> >
> >
> >
> >
> >>
> >> On Sunday, 12 February 2017 00:55:52 UTC+2, Mike Dewhirst wrote:
> >>
> >> A mixture has a number of ingredients and the proportions should
> >> (eventually) sum to 100%
> >>
> >> Ingredients are substances connected to the mixture - also a
> >> substance
> >> -  via m2m relationships. Each m2m record carries an ingredient
> >> proportion value.
> >>
> >> If a proportion changes the sum total changes after saving the
> >> mixture
> >> but cannot be displayed in the parent until the following save. I
> >> expect
> >> I'm wrong but I cannot see any way in the Admin to update the parent
> >> field in which the total is saved until after the second save.
> >>
> >> Is it possible to save children before the parent so the sum can be
> >> evaluated, the parent field updated and then the parent saved?
> >>
> >> Thanks
> >>
> >> Mike
> >>
> >> Django 1.8
> >> Python 2.7 and 3.5
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "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/4441fec6-
> 783c-41d8-a6bf-63499cdfece2%40googlegroups.com
> >>  783c-41d8-a6bf-63499cdfece2%40googlegroups.com?utm_medium=
> email&utm_source=footer>.
> >>
> >> For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send e

Re: return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login when adding a superuser

2017-02-13 Thread Tim Graham
It looks like you're missing a migration to allow null values in the 
last_login column. If you ran "migrate --fake", then it's possible some 
migrations were "fake applied" and you'll need to "fake unapply" them and 
actually run them.

https://docs.djangoproject.com/en/stable/releases/1.8/#abstractuser-last-login-allows-null-values

On Monday, February 13, 2017 at 4:48:34 AM UTC-5, ludovic coues wrote:
>
> Have you tried to run makemigrations before migrate ?
>
> On 12 Feb 2017 7:33 p.m., "Adam" > 
> wrote:
>
>> Hi Antonis, this is the full message including the command:
>>
>> :~/udemystuff/test_project# python manage.py createsuperuser
>> /root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/template/utils.py:37:
>>  
>> RemovedInDjango110Warning: You haven't defined a TEMPLATES setting. You 
>> must do so before upgrading to Django 1.10. Otherwise Django will be unable 
>> to load templates.
>>   "unable to load templates.", RemovedInDjango110Warning)
>>
>> /root/udemystuff/test_project/test_project/urls.py:11: 
>> RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and 
>> will be removed in Django 1.10. Update your urlpatterns to be a list of 
>> django.conf.urls.url() instances instead.
>>   url(r'^admin/', include(admin.site.urls)),
>>
>> Username (leave blank to use 'root'): adams
>> Email address:
>> Password:
>> Password (again):
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>  
>> line 350, in execute_from_command_line
>> utility.execute()
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>  
>> line 342, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/base.py",
>>  
>> line 348, in run_from_argv
>> self.execute(*args, **cmd_options)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
>>  
>> line 52, in execute
>> return super(Command, self).execute(*args, **options)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/base.py",
>>  
>> line 399, in execute
>> output = self.handle(*args, **options)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
>>  
>> line 173, in handle
>> 
>> self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
>>  
>> line 165, in create_superuser
>> return self._create_user(username, email, password, **extra_fields)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
>>  
>> line 148, in _create_user
>> user.save(using=self._db)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py",
>>  
>> line 74, in save
>> super(AbstractBaseUser, self).save(*args, **kwargs)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
>>  
>> line 700, in save
>> force_update=force_update, update_fields=update_fields)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
>>  
>> line 728, in save_base
>> updated = self._save_table(raw, cls, force_insert, force_update, 
>> using, update_fields)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
>>  
>> line 812, in _save_table
>> result = self._do_insert(cls._base_manager, using, fields, update_pk, 
>> raw)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
>>  
>> line 851, in _do_insert
>> using=using, raw=raw)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/manager.py",
>>  
>> line 122, in manager_method
>> return getattr(self.get_queryset(), name)(*args, **kwargs)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/query.py",
>>  
>> line 1039, in _insert
>> return query.get_compiler(using=using).execute_sql(return_id)
>>   File 
>> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>>  
>> line 1064, in execute_sql
>> cursor.execute(sql, para

Setting The Admin Login.

2017-02-13 Thread Steve Burrus
 How do I 

*go about setting the username/password for the CURRENT version of the 
Django Server anyway? It used to be easier to do in earlier versions of 
Django. *

-- 
You received this message because you are subscribed to the Google Groups 
"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/f8e7f518-3aad-40de-86e1-23f30633c0bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting The Admin Login.

2017-02-13 Thread Tim Graham
I guess you're looking for the createsuperuser command: 
https://docs.djangoproject.com/en/stable/ref/django-admin/#createsuperuser

On Monday, February 13, 2017 at 4:28:45 PM UTC-5, Steve Burrus wrote:
>
>  How do I 
>
> *go about setting the username/password for the CURRENT version of the 
> Django Server anyway? It used to be easier to do in earlier versions of 
> Django. *
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/b7d58c4f-307c-4883-9ca6-f424c648223c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Admin keeps redirecting to login page repeatedly

2017-02-13 Thread Abdul Wahid
Hi Everyone,

Since last two nights, I am struggling a lot to resolve the issue as my 
Django admin section keeps redirecting to login page repeatedly.
I had tried every corner solution to resolve the issue, but failed to 
resolve it. 

Finally I am writing here in some hope that someone who already had the 
similar issue would help me to resolve it.

So I am using Django 1.9.4 and when I logged into admin section then its 
seems to be fine but when I reload the page or click on some button then it 
redirect me to login page, As per my investigation I found that I am 
getting 302 for *"admin/jsi18n"* see the below screenshot..



Below is the screenshot after reloading the above mentioned page..





I would really appreciate the help to resolve the issue and I need to move 
for production asap.


Thanks,

Abdul Wahid 

-- 
You received this message because you are subscribed to the Google Groups 
"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/56697709-0510-4cc6-9ee4-669d6f379a2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django doesn't load CSS

2017-02-13 Thread djangomailtotest
Wow, mate, you're the hero! Worked like a charm! 
Thank you very much!

-- 
You received this message because you are subscribed to the Google Groups 
"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/ad0ad9ef-cd2c-4ee6-b309-cf1c0f0a86b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How see raw SQL code produced by django?

2017-02-13 Thread Thomas Nyberg

Hello,

I have a question about regexes and sqlite3. I am executing a certain 
line of code:


>>> regex = 'NET | INCOME'
>>> Table.objects.filter(name__iregex=regex).

When I have it print out the SQL sent, I get the following (this is a 
simplified, but equivalent version):


SELECT *
FROM "table"
WHERE "table"."name"
REGEXP '(?i)' || 'NET | INCOME'
LIMIT 21

However if I execute that directly against the sqlite database i get the 
following error:


sqlite3.OperationalError: no such function: REGEXP

I thought that maybe this magic was handled in python's sqlite3 module, 
but if i do it there i get the same error. So basically my question is, 
can anyone tell me where this is transformed into regular sql? it 
obviously happens somehwere (I get no error when running in django after 
all), but I can't for the life of me figure out where.


Thanks a lot!

Thomas

PS: I have tried using the shell_plus --print-sql extension, but that 
shows me the same thing.


PPS: Obviously not django-related, but if anyone knows how to get a 
sqlite database to log all queries issued against it, that would also 
obviously solve this issue.


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


Re: How see raw SQL code produced by django?

2017-02-13 Thread Tim Graham


Here's where Django defines REGEXP: 
https://github.com/django/django/blob/2f10216f84b55920de25422842a66260219e393f/django/db/backends/sqlite3/base.py#L173

>From http://stackoverflow.com/a/8244670:

SQLite does not contain regular expression functionality by default.

It defines a REGEXP operator, but this will fail with an error message 
unless you or your framework define a user function 
 called regexp().

You can execute raw SQL on a Django connection using the technique 
documented at 
https://docs.djangoproject.com/en/stable/topics/db/sql/#connections-and-cursors.
On Monday, February 13, 2017 at 5:06:47 PM UTC-5, Thomas Nyberg wrote:
>
> Hello, 
>
> I have a question about regexes and sqlite3. I am executing a certain 
> line of code: 
>
>  >>> regex = 'NET | INCOME' 
>  >>> Table.objects.filter(name__iregex=regex). 
>
> When I have it print out the SQL sent, I get the following (this is a 
> simplified, but equivalent version): 
>
>  SELECT * 
>  FROM "table" 
>  WHERE "table"."name" 
>  REGEXP '(?i)' || 'NET | INCOME' 
>  LIMIT 21 
>
> However if I execute that directly against the sqlite database i get the 
> following error: 
>
>  sqlite3.OperationalError: no such function: REGEXP 
>
> I thought that maybe this magic was handled in python's sqlite3 module, 
> but if i do it there i get the same error. So basically my question is, 
> can anyone tell me where this is transformed into regular sql? it 
> obviously happens somehwere (I get no error when running in django after 
> all), but I can't for the life of me figure out where. 
>
> Thanks a lot! 
>
> Thomas 
>
> PS: I have tried using the shell_plus --print-sql extension, but that 
> shows me the same thing. 
>
> PPS: Obviously not django-related, but if anyone knows how to get a 
> sqlite database to log all queries issued against it, that would also 
> obviously solve this issue. 
>

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


Re: Django Admin keeps redirecting to login page repeatedly

2017-02-13 Thread Tim Graham
Can you create a minimal project that reproduces the problem? It seems like 
something in the request/response cycle (middleware maybe?) is effectively 
logging you out on each request.

On Monday, February 13, 2017 at 5:07:09 PM UTC-5, Abdul Wahid wrote:
>
> Hi Everyone,
>
> Since last two nights, I am struggling a lot to resolve the issue as my 
> Django admin section keeps redirecting to login page repeatedly.
> I had tried every corner solution to resolve the issue, but failed to 
> resolve it. 
>
> Finally I am writing here in some hope that someone who already had the 
> similar issue would help me to resolve it.
>
> So I am using Django 1.9.4 and when I logged into admin section then its 
> seems to be fine but when I reload the page or click on some button then it 
> redirect me to login page, As per my investigation I found that I am 
> getting 302 for *"admin/jsi18n"* see the below screenshot..
>
>
> 
>
> Below is the screenshot after reloading the above mentioned page..
>
>
> 
>
>
>
> I would really appreciate the help to resolve the issue and I need to move 
> for production asap.
>
>
> Thanks,
>
> Abdul Wahid 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/b4c512fc-d431-4eba-83a2-02fd5723f2b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting The Admin Login.

2017-02-13 Thread Steve R Burrus
I am sorry Tim but I checked oiut both "creat esuperuser" and "changepassword" 
commands but  it did no good! Can you please give me a more detailed solution? 
 

On Monday, February 13, 2017 3:42 PM, Tim Graham  
wrote:
 

 I guess you're looking for the createsuperuser command: 
https://docs.djangoproject.com/en/stable/ref/django-admin/#createsuperuser

On Monday, February 13, 2017 at 4:28:45 PM UTC-5, Steve Burrus wrote:
 How do I go about setting the username/password for the CURRENT version of the 
Django Server anyway? It used to be easier to do in earlier versions of Django.

 

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/Evyu_1IPZ2o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7d58c4f-307c-4883-9ca6-f424c648223c%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/844799351.4041439.1487024939747%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: How see raw SQL code produced by django?

2017-02-13 Thread Thomas Nyberg

On 02/13/2017 05:24 PM, Tim Graham wrote:



Here's where Django defines REGEXP:
https://github.com/django/django/blob/2f10216f84b55920de25422842a66260219e393f/django/db/backends/sqlite3/base.py#L173

From http://stackoverflow.com/a/8244670:

SQLite does not contain regular expression functionality by default.

It defines a REGEXP operator, but this will fail with an error message
unless you or your framework define a user function
 called regexp().

You can execute raw SQL on a Django connection using the technique
documented at
https://docs.djangoproject.com/en/stable/topics/db/sql/#connections-and-cursors.



Excellent thanks so much this clarifies a lot and is great info!

Cheers,
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/a03833d2-a64b-209a-3317-6691c11dce36%40gmx.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting The Admin Login.

2017-02-13 Thread Tim Graham
I'm not sure what you're trying to do.

On Monday, February 13, 2017 at 5:29:49 PM UTC-5, Steve Burrus wrote:
>
> I am sorry Tim but I checked oiut both "creat esuperuser" and 
> "changepassword" commands but  it did no good! Can you please give me a 
> more detailed solution? 
>
>
> On Monday, February 13, 2017 3:42 PM, Tim Graham  > wrote:
>
>
> I guess you're looking for the createsuperuser command: 
> https://docs.djangoproject.com/en/stable/ref/django-admin/#createsuperuser
>
> On Monday, February 13, 2017 at 4:28:45 PM UTC-5, Steve Burrus wrote:
>
>  How do I 
>
> *go about setting the username/password for the CURRENT version of the 
> Django Server anyway? It used to be easier to do in earlier versions of 
> Django. *
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/Evyu_1IPZ2o/unsubscribe.
> To unsubscribe from this group and all its topics, 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/b7d58c4f-307c-4883-9ca6-f424c648223c%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/5307d9ec-f69e-4000-a0b3-e86825896932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to save children before parents?

2017-02-13 Thread Melvyn Sopacua
On Sunday 12 February 2017 09:55:16 Mike Dewhirst wrote:
> A mixture has a number of ingredients and the proportions should
> (eventually) sum to 100%
> 
> Ingredients are substances connected to the mixture - also a substance
> -  via m2m relationships. Each m2m record carries an ingredient
> proportion value.
> 
> If a proportion changes the sum total changes after saving the mixture
> but cannot be displayed in the parent until the following save.

The trick is not to focus on saving, but on providing a consistent state when 
loading the model instance, similar as to what ImageField does with it's width 
and height fields.

Here's an example:
https://gist.github.com/melvyn-sopacua/1b4e4585ab15ffc176798c083470cf04
-- 
Melvyn Sopacua

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


Re: Is it possible to save children before parents?

2017-02-13 Thread Melvyn Sopacua
P.S. I left two bugs in there, for now I'll 
leave them in as an exercise for the 
reader.
-- 
Melvyn Sopacua

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


Re: Setting The Admin Login.

2017-02-13 Thread Steve R Burrus
We;ll Tim I like any other Django newb ie just wanna be able to go into the 
Django admin like I clearly remember doing with past versions of Django. Is 
there any more advice you can give me for this problem?   

On Monday, February 13, 2017 6:27 PM, Tim Graham  
wrote:
 

 I'm not sure what you're trying to do.

On Monday, February 13, 2017 at 5:29:49 PM UTC-5, Steve Burrus wrote:
I am sorry Tim but I checked oiut both "creat esuperuser" and "changepassword" 
commands but  it did no good! Can you please give me a more detailed solution? 
 

On Monday, February 13, 2017 3:42 PM, Tim Graham  wrote:
 

 I guess you're looking for the createsuperuser command: 
https://docs.djangoproject. com/en/stable/ref/django- admin/#createsuperuser

On Monday, February 13, 2017 at 4:28:45 PM UTC-5, Steve Burrus wrote:
 How do I go about setting the username/password for the CURRENT version of the 
Django Server anyway? It used to be easier to do in earlier versions of Django.

 

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/ 
topic/django-users/Evyu_ 1IPZ2o/unsubscribe.
To unsubscribe from this group and all its topics, 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/b7d58c4f- 307c-4883-9ca6-f424c648223c% 40googlegroups.com.
For more options, visit https://groups.google.com/d/ optout.


   
-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/Evyu_1IPZ2o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5307d9ec-f69e-4000-a0b3-e86825896932%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/1109209035.4161424.1487035939958%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setting The Admin Login.

2017-02-13 Thread Tim Graham
Use the createsuperuser command (manage.py createsuperuser) to create a 
user, then use that username and password to login.

Maybe you want to revisit the tutorial, 
https://docs.djangoproject.com/en/stable/intro/tutorial02/#creating-an-admin-user.

On Monday, February 13, 2017 at 8:33:17 PM UTC-5, Steve Burrus wrote:
>
> We;ll Tim I like any other Django newb ie just wanna be able to go into 
> the Django admin like I clearly remember doing with past versions of 
> Django. Is there any more advice you can give me for this problem?
>   
>
>
> On Monday, February 13, 2017 6:27 PM, Tim Graham  > wrote:
>
>
> I'm not sure what you're trying to do.
>
> On Monday, February 13, 2017 at 5:29:49 PM UTC-5, Steve Burrus wrote:
>
> I am sorry Tim but I checked oiut both "creat esuperuser" and 
> "changepassword" commands but  it did no good! Can you please give me a 
> more detailed solution? 
>
>
> On Monday, February 13, 2017 3:42 PM, Tim Graham  
> wrote:
>
>
> I guess you're looking for the createsuperuser command: 
> https://docs.djangoproject. 
> com/en/stable/ref/django- admin/#createsuperuser 
> 
>
> On Monday, February 13, 2017 at 4:28:45 PM UTC-5, Steve Burrus wrote:
>
>  How do I 
>
> *go about setting the username/password for the CURRENT version of the 
> Django Server anyway? It used to be easier to do in earlier versions of 
> Django. *
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/ 
> topic/django-users/Evyu_ 1IPZ2o/unsubscribe 
> .
> To unsubscribe from this group and all its topics, 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/b7d58c4f- 307c-4883-9ca6-f424c648223c% 40googlegroups.com 
> 
> .
>
> For more options, visit https://groups.google.com/d/ optout 
> .
>
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/Evyu_1IPZ2o/unsubscribe.
> To unsubscribe from this group and all its topics, 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/5307d9ec-f69e-4000-a0b3-e86825896932%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/6f1f53ba-8378-4419-aebf-989fd5c48e46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin keeps redirecting to login page repeatedly

2017-02-13 Thread Abdul Wahid
Hey Tim,

Thanks for the hint, You are right the culprit was the *"*
django_zappa.middleware.ZappaMiddleware*"   *Its working fine without this 
middleware but I require this middleware (Django Zappa) 
 as for AWS lambda which provides 
me serverless hosting. 

Please let me know if you know something about this middleware.

Thanks,
Abdul Wahid

On Tuesday, 14 February 2017 03:57:16 UTC+5:30, Tim Graham wrote:
>
> Can you create a minimal project that reproduces the problem? It seems 
> like something in the request/response cycle (middleware maybe?) is 
> effectively logging you out on each request.
>
> On Monday, February 13, 2017 at 5:07:09 PM UTC-5, Abdul Wahid wrote:
>>
>> Hi Everyone,
>>
>> Since last two nights, I am struggling a lot to resolve the issue as my 
>> Django admin section keeps redirecting to login page repeatedly.
>> I had tried every corner solution to resolve the issue, but failed to 
>> resolve it. 
>>
>> Finally I am writing here in some hope that someone who already had the 
>> similar issue would help me to resolve it.
>>
>> So I am using Django 1.9.4 and when I logged into admin section then its 
>> seems to be fine but when I reload the page or click on some button then it 
>> redirect me to login page, As per my investigation I found that I am 
>> getting 302 for *"admin/jsi18n"* see the below screenshot..
>>
>>
>> 
>>
>> Below is the screenshot after reloading the above mentioned page..
>>
>>
>> 
>>
>>
>>
>> I would really appreciate the help to resolve the issue and I need to 
>> move for production asap.
>>
>>
>> Thanks,
>>
>> Abdul Wahid 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"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/f3b3436a-f206-4c96-8dd2-01446774975b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to save children before parents?

2017-02-13 Thread Mike Dewhirst

Derek, Antonis, Ludovic and Melvyn

I've got a lot happening in the code because chemical mixtures and 
safety regulations are complex. I will attempt to radically simplify it 
in a new minimal project and prove/disprove things and report back under 
this thread.


Many thanks for the suggestions

Much appreciated

Mike

On 14/02/2017 12:14 PM, Melvyn Sopacua wrote:


P.S. I left two bugs in there, for now I'll leave them in as an 
exercise for the reader.


--

Melvyn Sopacua

--
You received this message because you are subscribed to the Google 
Groups "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/10404615.9y43U2G7Fx%40devstation 
.

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/c88bcaca-c356-f1a3-abaa-323ec9e1ec9f%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.