Tuesday, January 31, 2017

Re: Limiting choices in a lookup by exclusion

django doesn't have an ne operator in the orm. You want to use a negated Q object for your limit_choices_to. try:

from django.db.models import Q

phone = models.ManyToManyField(Phone, limit_choices_to = ~Q(type_id = 'C'))

On Wednesday, February 1, 2017 at 6:17:52 AM UTC+2, Gordon Burgess wrote:

I have this code, and with Django 1.10 it works as expected:

class Location(models.Model):
    name = models.CharField(max_length = 32, unique = True)
    street = models.CharField(max_length = 32)
    detail = models.CharField(max_length = 32, blank = True, null = True)
    city = models.CharField(max_length = 32)
    state = USStateField()
    zip = USZipCodeField()
    phone = models.ManyToManyField(Phone, limit_choices_to = {'type_id':'H'})

but what I'd like to do is restrict the choices of phone numbers for Locations to those that aren't 'C' (cell phones) - I've found some hints, but they're all for older versions of Django - it seems like:

    phone = models.ManyToManyField(Phone, limit_choices_to = {'type_id__ne':'C'})

ought to work - but this provokes a TypeError:

Related Field got invalid lookup: ne

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/37b94253-fd0e-479f-8c0d-ffe262b1dcd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stuck at Tutorial 1

Hi, 

  I tried doing exactly everything as told in Tutorial 1 (https://docs.djangoproject.com/en/1.10/intro/tutorial01/)
  I use idle to write the polls.py and urls.py
  Do i totally overwrite the code already in those file or leave them alone and add on the codes in the tutorial. 

  Because i always get this when i start run the server again. What could possibly be the error?



Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03C7D978>
Traceback (most recent call last):
  File "c:\django\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "c:\django\django\core\management\commands\runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "c:\django\django\core\management\base.py", line 356, in check
    include_deployment_checks=include_deployment_checks,
  File "c:\django\django\core\management\base.py", line 343, in _run_checks
    return checks.run_checks(**kwargs)
  File "c:\django\django\core\checks\registry.py", line 78, in run_checks
    new_errors = check(app_configs=app_configs)
  File "c:\django\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "c:\django\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "c:\django\django\urls\resolvers.py", line 247, in check
    for pattern in self.url_patterns:
  File "c:\django\django\utils\functional.py", line 31, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\django\django\urls\resolvers.py", line 398, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "c:\django\django\utils\functional.py", line 31, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\django\django\urls\resolvers.py", line 391, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\mysite\mysite\urls.py", line 20, in <module>
    url(r'^polls/', include('polls.urls')),
  File "c:\django\django\conf\urls\__init__.py", line 39, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 658, in exec_module
  File "<frozen importlib._bootstrap_external>", line 764, in get_code
  File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\mysite\polls\urls.py", line 1
    Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
             ^
SyntaxError: invalid syntax

--
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+unsubscribe@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/CAF_57Gsq7nM5bJNGhhdoomQV9ywJ6pN5AgOfdGVYXe2jzFn4sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Link to urls containing slug

Hi Matthew

I think I might not have explained my issue fully.
Within my jobs models.py I have the following:
def get_absolute_url(self):
        kwargs = {
                  'job_id': self.job_id,
                  'slug': self.slug,
                       }
        return reverse('job_detail', kwargs=kwargs)

I have the following urls patterns:
url(r'^$', views.JobListView.as_view(), name='job_list'),
url(r'^(?P<job_id>[-\w]*)/(?P<slug>[-\w]*)/$', views.JobDetail.as_view(), name='job_detail'),

At this stage everything works fine so that clicking on a job in the job list takes you through to the detail for that job.
I have then created an application form for the jobs as follows:
def job_application(request, job_id, slug):
    # Retrieve job by id
    job = get_object_or_404(Job, job_id=job_id)
    sent = False

    if request.method == 'POST':
        # Form was submitted
        form = JobForm(request.POST)
        if form.is_valid():
            # Form fields passed validation
            cd = form.cleaned_data
            job_url = request.build_absolute_uri(job.get_absolute_url())
            subject = '{} ({}) Application for  "{}"'.format(cd['name'], cd['email'], job.title)
            message = 'Application for "{}" at {}\n\n{}\'s comments: {}'.format(job.title,  job_url, cd['name'], cd['comments'])
            from_email = ''
            to_list = ['']
            send_mail(subject, message, from_email, to_list)
            sent = True
    else:
        form = JobForm()
    return render(request, 'jobs/job_application.html', {'job': job, 'form': form, 'sent': sent})

The url for this form is:
url(r'^(?P<job_id>[-\w]*)/(?P<slug>[-\w]*)/job_application/$', views.job_application, name='job_application'),

I can go to this link directly in my browser as follows:
What I am looking to achieve is a link within the job detail page for that specific job that takes you through to the application fom for that job.

Any advice gratefully appreciated.

On 31 January 2017 at 16:32, Matthew Pava <Matthew.Pava@iss.com> wrote:

Hi David,

Please make sure you have a get_absolute_url method on your JobApplication model in order for that to work and that you passing job_application in through the context in the template.

If you don't have that method, you could use the {% url %} tag, but you would have to provide the pk and slug as arguments.

<a href="{% url  'job_application' pk=job_application.job_id slug=job_application.slug %}">{{ job_application }}</a>

 

Good luck!

 

From: 'David Turner' via Django users [mailto:django-users@googlegroups.com]
Sent: Tuesday, January 31, 2017 9:09 AM
To: django-users@googlegroups.com
Subject: Re: Link to urls containing slug

 

I had tried that but unfortunately it doesn't work but thanks anyway.

 

On 31/01/2017 14:57, Matthew Pava wrote:

Assuming I'm understanding your question correctly, all you need to do is reference get_absolute_url in your template.

Something like so:

 

<a href="{{ job_application.get_absolute_url }}">{{ job_application }}</a>

 

From: 'dtdave' via Django users [mailto:django-users@googlegroups.com]
Sent: Tuesday, January 31, 2017 8:46 AM
To: Django users
Subject: Link to urls containing slug

 

Within my model I have the following that links through to a detail page.

def get_absolute_url(self):

        

        kwargs = {

                  'job_id': self.job_id,

                  'slug': self.slug,

                       }

        return reverse('job_detail', kwargs=kwargs)

 

Everything works fine with this.

 

Within my urls.py I have the following:

url(r'^$', views.JobListView.as_view(), name='job_list'),

url(r'^(?P<job_id>[-\w]*)/(?P<slug>[-\w]*)/$', views.JobDetail.as_view(), name='job_detail'),

url(r'^(?P<job_id>[-\w]*)/(?P<slug>[-\w]*)/job_application/$', views.job_application, name='job_application'),

 

Then within my views.py the following:

def job_application(request, job_id, slug):

    # Retrieve job by id

    job = get_object_or_404(Job, job_id=job_id)

    """Other code here""""

 

However, I am having problems linking to this from my template in my detail page.

What structure should I be using to link to the job application from the job detail page?

 

I can access the url by going to 

http://localhost:8000/jobs/1/name-of-job/job_application/

 

Any advice would be appreciated

--
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+unsubscribe@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/0e6db077-52a8-4f23-862c-888ae0995e91%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/hlWrp8tzpXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/5e1e214b640c4d4f8c7c5e1d5cf0850b%40ISS1.ISS.LOCAL.
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+unsubscribe@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/5412da70-2ee1-9259-1f28-71e85e6e4ab9%40gmail.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/hlWrp8tzpXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/1ef6a4df22b3475fa5dff71b074e4e54%40ISS1.ISS.LOCAL.

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+unsubscribe@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/CALwQ%2B-vEGUqdE4MHdV5rHxfNdfScFD%2BN5HP49QuUjW%2Br0Z%3DTbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django 1.9 ./manage.py migrate error

That works for me. You save my life. Thank you!

On Friday, June 3, 2016 at 12:26:04 PM UTC-4, Tejesh Papineni wrote:
its working when already have a db because views.py are using Models from already existing db. But when creating new db, code in views.py is trying to access Models that have not yet been built using ./manage.py migrate. My solution is to comment code in views.py that accesses Models or try except with OperationalError , then run migrations (which will work now). Afterwards revert to old views.py code.

On Monday, March 7, 2016 at 4:20:16 AM UTC+5:30, Xuton Ion wrote:
Hi, thanks for the reply.
So, did you have a db in the project? I cloned the project again and tried to create the db from the model, but using your suggestion doesn't work.
I can only get 1.9 working if I already have a db from 1.8, but not creating a new one from scratch.

Neither the first or second line runs, they both exit with the same error. Table doesn't exist

On Monday, 18 January 2016 08:08:38 UTC+13, Marisa DeMeglio wrote:
Ok I had to run these commands to make it work:

$manage.py makemigrations <app_name> 
$migrate --fake-initial.

(for reference: django 1.9.1 / sqlite / OSX / python 3.4)

On Sunday, January 17, 2016 at 9:48:22 AM UTC-8, Marisa DeMeglio wrote:
Did you ever figure this out? I just upgraded from Django 1.8 to 1.9 and I'm having the same issue.

On Saturday, December 12, 2015 at 10:01:39 PM UTC-8, Xuton Ion wrote:
Thanks for the assistance so far.

Reading https://docs.djangoproject.com/en/1.9/topics/migrations/ it says I should be able to run migrate to apply migrations.
But does this mean I have to manually do something, or should that work the same as it did on 1.8?

I am assuming that it should also be able to create the database from the model with just running that one command.

When creating a new project the migrate line runs fine, so it seems to be something specific to the project. I cant share the project though

On Saturday, 12 December 2015 19:14:55 UTC+2, Tim Graham wrote:
Is there a reason you can't use migrations? --run-syncdb is really only meant for huge projects (hundreds or thousands of models) where migrations are too slow. Not sure why it's not working though. You'd have to project a sample project for me to debug further.

On Saturday, December 12, 2015 at 11:53:37 AM UTC-5, Xuton Ion wrote:
No, I haven't added any migrations. 

I did try with --run-syncdb though, and still had the same error though

On Saturday, 12 December 2015 16:26:15 UTC+2, Tim Graham wrote:
Does your application have migrations? Quoting the 1.9 release notes, "Automatic syncing of apps without migrations is removed. Migrations are compulsory for all apps unless you pass the --run-syncdb option to migrate."

On Saturday, December 12, 2015 at 8:42:58 AM UTC-5, Xuton Ion wrote:
Hi

I seem to have an issue with running migrate and have been googling all day without any luck

I have an app which works and runs on 1.8
After cloning the repo and creating a new ve, I ended up with Django 1.9

Running the ./manage.py migrate creates the database, but none of the tables from the model. It returns
django.db.utils.OperationalError: no such table: table_name

If I delete the db.sqlite3 (still in dev so not postgress yet), deactivate my ve and use my ve with django 1.8, the migrate line runs fine. 
If I then re-activate my ve with 1.9, everything works fine. I can make changes and run makemigrations, and it works. But the initial state seems to not work

Anyone else have the same issue, or have some advice for me?

--
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+unsubscribe@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/3cfe5ec1-1643-415c-a299-80bd8135b711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Limiting choices in a lookup by exclusion


I have this code, and with Django 1.10 it works as expected:

class Location(models.Model):
    name = models.CharField(max_length = 32, unique = True)
    street = models.CharField(max_length = 32)
    detail = models.CharField(max_length = 32, blank = True, null = True)
    city = models.CharField(max_length = 32)
    state = USStateField()
    zip = USZipCodeField()
    phone = models.ManyToManyField(Phone, limit_choices_to = {'type_id':'H'})

but what I'd like to do is restrict the choices of phone numbers for Locations to those that aren't 'C' (cell phones) - I've found some hints, but they're all for older versions of Django - it seems like:

    phone = models.ManyToManyField(Phone, limit_choices_to = {'type_id__ne':'C'})

ought to work - but this provokes a TypeError:

Related Field got invalid lookup: ne

Thanks!

Re: Send mail bug needs password passed as bytearray

Really? I should look at moving to python 3 but my understanding was that python 2.7 would be supported until Django 2.0 according to the docs

On Wednesday, February 1, 2017 at 1:21:21 PM UTC+13, Tim Graham wrote:
Oh, I see, you're using bytearray to try to workaround the issue. Well, Django master no longer supports Python 2.7, that's why force_str() was removed. Is there a problem with Django master and Python 3?

On Tuesday, January 31, 2017 at 7:16:41 PM UTC-5, ell...@makecollective.co.nz wrote:
Neither.

I haven't seen anything with webfaction and I have used webfaction in the past on several projects and not had any trouble.

On Wednesday, February 1, 2017 at 12:12:56 PM UTC+13, Tim Graham wrote:
I've never seen a password as a bytearray. Is there webfaction documentation about this?

On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, ell...@makecollective.co.nz wrote:
myMail = EmailMessage('subject', 'message', 'some...@address.com', ['mye...@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

--
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+unsubscribe@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/40d9f4eb-b7e6-4120-b6d1-0254577ec36a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: video tutorial dating site

One of the first results when Googling 'Django video tutorials' is
this: https://www.quora.com/Are-there-any-good-Django-video-tutorials

There are many links provided there.

-A

On Tue, Jan 31, 2017 at 5:28 PM, <engrosswebhost@gmail.com> wrote:
> am new using python(django) i built an app lately but i want to build a
> dating site using django. I will be comfortable with video tutorials. Any
> help please???
>
> --
> 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+unsubscribe@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/2818f361-d0d0-46bb-bd5d-02d643f45232%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+unsubscribe@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/CAEE%2BrGrq8_tnhy2NWTz9Y6wVM_5f1k1bBXTDX%3Dp1s-WVi5TrJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

video tutorial dating site

am new using python(django) i built an app lately but i want to build a dating site using django. I will be comfortable with video tutorials. Any help please???

--
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+unsubscribe@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/2818f361-d0d0-46bb-bd5d-02d643f45232%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Send mail bug needs password passed as bytearray

Oh, I see, you're using bytearray to try to workaround the issue. Well, Django master no longer supports Python 2.7, that's why force_str() was removed. Is there a problem with Django master and Python 3?

On Tuesday, January 31, 2017 at 7:16:41 PM UTC-5, ell...@makecollective.co.nz wrote:
Neither.

I haven't seen anything with webfaction and I have used webfaction in the past on several projects and not had any trouble.

On Wednesday, February 1, 2017 at 12:12:56 PM UTC+13, Tim Graham wrote:
I've never seen a password as a bytearray. Is there webfaction documentation about this?

On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, ell...@makecollective.co.nz wrote:
myMail = EmailMessage('subject', 'message', 'some...@address.com', ['mye...@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

--
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+unsubscribe@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/4a1f44d9-4310-4b4c-a9a2-a688f6d75111%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Send mail bug needs password passed as bytearray

Neither.

I haven't seen anything with webfaction and I have used webfaction in the past on several projects and not had any trouble.

On Wednesday, February 1, 2017 at 12:12:56 PM UTC+13, Tim Graham wrote:
I've never seen a password as a bytearray. Is there webfaction documentation about this?

On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, ell...@makecollective.co.nz wrote:
myMail = EmailMessage('subject', 'message', 'some...@address.com', ['mye...@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

--
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+unsubscribe@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/a1218ddb-4b8b-4cac-a23b-df25f8419903%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Send mail bug needs password passed as bytearray

I've never seen a password as a bytearray. Is there webfaction documentation about this?

On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, ell...@makecollective.co.nz wrote:
myMail = EmailMessage('subject', 'message', 'some...@address.com', ['mye...@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

--
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+unsubscribe@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/0bbf3721-2571-40a5-bb05-c970c96c9e8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How to make django sqlite database connection readonly.

You just need to read doc: https://docs.djangoproject.com/en/1.10/topics/db/multi-db/

在 2017年1月31日星期二 UTC+13上午5:19:02,Chetan Gupta写道:
Hi,

I am new to django.
My requirement is django application i have 3 db connection.
I want 2 db connection is readonly.

Please let me know how to do that.

Regards
Chetan

--
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+unsubscribe@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/764088e3-a473-418f-99be-8901636db07d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Making email required

I want to make the email field required in the user admin add and
change pages. Following some posts I read on stackoverflow I did this:

class MyUserCreationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(MyUserCreationForm, self).__init__(*args, **kwargs)
# make user email field required
self.fields['email'].required = True

class UserAdmin(BaseUserAdmin):
form = MyUserCreationForm
add_form = MyUserCreationForm
add_fieldsets = ((None, {'fields': ('username', 'email',
'password1', 'password2'), 'classes': ('wide',)}),)

admin.site.unregister(User)
admin.site.register(User, UserAdmin)

This works fine in add user, but in change user I get the user's
encrypted password shown in the password field, instead of what you
normally see:

algorithm: pbkdf2_sha256 iterations: 24000 salt: ****** hash:
**************************************
Raw passwords are not stored, so there is no way to see this user's
password, but you can change the password using this form.

And when I try to save from the change screen it says "Please correct
the errors below." even though there are no errors shown.

How can I fix these issues in the change form?

--
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+unsubscribe@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/CACwCsY4vTD5igQojT3iyKW7gDpStPRtA6_YMEvPzUi8QotaHiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Send mail bug needs password passed as bytearray

myMail = EmailMessage('subject', 'message', 'someemail@address.com', ['myemail@address.com'])
myMail.send()

The error I'm getting:

  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py", line 342, in send


    return self.get_connection(fail_silently).send_messages([self])


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages


    new_conn_created = self.open()


  File "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 67, in open


    self.connection.login(self.username, self.password)


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 607, in login


    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 571, in encode_cram_md5


    response = user + " " + hmac.HMAC(password, challenge).hexdigest()


  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 75, in __init__


    self.outer.update(key.translate(trans_5C))


TypeError: character mapping must return integer, None or unicode


There was solution from this ticket with the same problem. But then the fixed commit was removed here.

The settings needed to send emails now

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = bytearray('******', 'utf-8')
EMAIL_PORT = 587

So 2 questions:

Am I missing something simple?

Is this a bug and needs a ticket?

Cheers

--
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+unsubscribe@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/87c6ac90-d579-4588-a4d2-f0f0e674095b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.