Monday, February 29, 2016

Re: New to Django

Thanks, really appreciate it!

On Monday, 29 February 2016 19:19:21 UTC-7, Lachlan Musicman wrote:
You will find there are two different pips on your computer - the default is obv 2.7. the most likely command you will need is pip3 (on ubuntu), but your best bet is to:

 - set up a virtualenv
 - set up your path to default to python 3.5.1

I would use the virtualenv solution personally.

There is also the quick and dirty "which python" then doing an ls -l | grep pip on the directory that python is in (/usr/bin for me)

Cheers
L.


------
The most dangerous phrase in the language is, "We've always done it this way."

- Grace Hopper

On 1 March 2016 at 11:59, Gary Dhillon <gary...@gmail.com> wrote:
I've installed Django and I keep getting no module named django when importing. I have python 3.5.1 and used pip to install django 1.9.2. Its showing up on my python 2.7 though. Any help 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...@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/3ea8f361-3642-4b16-97f0-77ce379a0a49%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/556c5a35-3b52-448d-8c4d-58d5da70a958%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: more than one field for aggregates? (ArrayAgg, StringAgg)

Hi Tomasz,

I suppose you could implement `ROW` as a custom expression[1] and use it in
your `ArrayAgg` aggregate as follow:

from django.contrib.postgres.aggregates import ArrayAgg
from django.db.models import Expression

class Row(Expression):
    template = 'ROW(%(expressions)s)'

    # ...

MyModel.objects.aggregate(
    ArrayAgg(Row(F('field1'), F('field2'))),
)


Cheers,
Simon

[1] https://docs.djangoproject.com/en/1.9/ref/models/expressions/#writing-your-own-query-expressions

Le lundi 29 février 2016 19:31:15 UTC-5, Tomasz Nowak a écrit :
Hi!

Module django.contrib.postgres.aggregates provides classes for ARRAY_AGG and STRING_AGG PostgreSQL aggregates.

Is it possible to provide more than one field to these aggregates?
Like in SQL, where you can provide more fields ("row" is optional):

ARRAY_AGG(row(table.field1, table.field2))

Best wishes,
Tomasz

--
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/e5a3e7a2-74b3-462c-8461-eba15aaf1bc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: New to Django

You will find there are two different pips on your computer - the default is obv 2.7. the most likely command you will need is pip3 (on ubuntu), but your best bet is to:

 - set up a virtualenv
 - set up your path to default to python 3.5.1

I would use the virtualenv solution personally.

There is also the quick and dirty "which python" then doing an ls -l | grep pip on the directory that python is in (/usr/bin for me)

Cheers
L.


------
The most dangerous phrase in the language is, "We've always done it this way."

- Grace Hopper

On 1 March 2016 at 11:59, Gary Dhillon <gary.dhil@gmail.com> wrote:
I've installed Django and I keep getting no module named django when importing. I have python 3.5.1 and used pip to install django 1.9.2. Its showing up on my python 2.7 though. Any help 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/3ea8f361-3642-4b16-97f0-77ce379a0a49%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/CAGBeqiNaKp2tW278LSaKTYEz_-rH_O5JTVKLRkJsB8UeZWOhTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

New to Django

I've installed Django and I keep getting no module named django when importing. I have python 3.5.1 and used pip to install django 1.9.2. Its showing up on my python 2.7 though. Any help 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/3ea8f361-3642-4b16-97f0-77ce379a0a49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: bootstrap django crispy forms



On Fri, Feb 26, 2016 at 7:39 AM, <clarksonchris81@gmail.com> wrote:

A simple upload button is proving difficult to implement bootstrap and css on.... My attempt is as follows:

     class DocumentForm(forms.Form):         docfile = forms.FileField(label='Choose')         def __init__(self, *args, **kwargs): # don't particularly know or care about this and the below component....           super(DocumentForm, self).__init__(*args, **kwargs) #but they are necessary to not get an error           ButtonHolder(             Div('docfile', style="background: black;", css_class="col-md-12", css_id="burton", template='home.html')             ), #the Div part is what I'm most interested in- in order to be able to style the button.

Furthermore, having set the "css_class" to "burton", I have tried referencing it in a normal css file:

     .burton{          ....        }

but that too is obviously misguided??

Can someone tell me where I'm going wrong?


I answered your other email that had a very similar set of incorrect syntax, and provided direction there.


--
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/CA%2Be%2BciVtx%3DeXQLH1R9H-HG9J93SQq0U9zd97km7yd%2BpssvnG%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Absolute beginner question -- recipes


On Mon, Feb 29, 2016 at 5:57 AM, Simon Gunacker <simon.gunacker@gmail.com> wrote:
Thank you Florian. After James pointed out that I can access my steps (and the ingredients in some way) by just passing the recipe object to the templates context, I thought of reducing the view to a DetailView again. But I have to somehow access the ingredients from my template for now ...


The related models using a 'through' table also have access to the 'through' table itself. With your current setup, I think you can do this:

<ul>
{% for steping in step.stepingredient_set.all %}
    <li>{{ steping.amount }} {{ steping.unit }} - {{ steping.ingredient }}</li>
{% empty %}
    <li>No ingredients needed for this step.</li>
{% endfor %}
</ul>

Optionally, for style points (and better human readability of the code), you can also add a 'related_name' parameter to the FK's in the 'through' table:

    step = models.ForeignKey(Step, null=True, related_name='step_ingredients')
    ingredient = models.ForeignKey(Ingredient, null=True, related_name='ingredient_steps')

That way, depending on the direction you are going, the call makes sense to a human:

<ul>
{% for steping in step.step_ingredients.all %}
    <li>{{ steping.amount }} {{ steping.unit }} - {{ steping.ingredient }}</li>
{% empty %}
    <li>No ingredients needed for this step.</li>
{% endfor %}
</ul>

I think that will work, although I haven't exactly tested this.

I'd highly recommend going with DetailView if you can. That makes your view a whopping 2 or 3 lines.

-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+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/CA%2Be%2BciWYj42TNJ4KeF4vFS6_wi0cghdCee%2Bu-_QJ0VP2uzyg-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: mathematical function and django connect



On Sun, Feb 28, 2016 at 2:06 PM, Xristos Xristoou <saxri89@gmail.com> wrote:
update my project now

my view.py code

def calc(request):
a = []
NList = []
y=0
member=0
member = request.POST.get ('member', False)
for i in range(int(member)):
input = request.POST.get ('input', False)
NList.append(int(input))
for k in NList:
if k is 1:
y = 1
elif (k > 1) and (k < 5):
y = (k - 1) + 2
a.append(y)
return render_to_response ('blog/calc.html', {'a' :a, 'member':member}, context_instance=RequestContext(request))


Have you verified that 'member' and 'input' are populated with values when the form is submitted? You should be able to put print() statements at various points in your code and watch the output on the dev server console. You should also check that the 'a' variable is populated just before it is placed into the context. 

Also, be careful using input as a variable name. That clashes with the input() function in Python 3. 

-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+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/CA%2Be%2BciXAzQNL4831UPxahzHQbn8nxsfB6ZWYkz9ofKRCPLtr-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

more than one field for aggregates? (ArrayAgg, StringAgg)

Hi!

Module django.contrib.postgres.aggregates provides classes for ARRAY_AGG and STRING_AGG PostgreSQL aggregates.

Is it possible to provide more than one field to these aggregates?
Like in SQL, where you can provide more fields ("row" is optional):

ARRAY_AGG(row(table.field1, table.field2))

Best wishes,
Tomasz

--
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/5b88ce16-d3b2-4508-864e-183b4ed98b1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re:

Hi Aaron,

I think this could be related to the version of your PostgreSQL server.

Django 1.9 dropped support for PostgreSQL 9.0[1] which doesn't support
GROUP BY selected primary keys[2].

Cheers,
Simon

[1] https://docs.djangoproject.com/en/1.9/releases/1.9/#dropped-support-for-postgresql-9-0
[2] https://github.com/django/django/commit/dc27f3ee0c3eb9bb17d6cb764788eeaf73a371d7

Le lundi 29 février 2016 15:56:07 UTC-5, Aaron C. de Bruyn a écrit :
A simple annotation broke when I migrated by app from Django 1.8.x to 1.9.2, and I can't figure out why for the life of me.

Calling Company.objects.all().annotate(ticketcount=Count('srservice'))

throws an error "ProgrammingError: column "company.owner_id" must appear in the GROUP BY clause or be used in an aggregate function"

Rolling back to Django 1.8.5 fixes the problem.
The DB backend is Postgres.

Please ignore the horrible DB schema.  It's not mine.  It's an introspection of a horrible Windows ticketing app.


Am I missing something?

-A

--
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/1c40f831-b730-40c5-9009-7cfac291e45f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How force DJANGo choice MEDIA_URL or STATIC_URL in template?


I need choice base url MEDIA_URL (/media/) - for uploaded user picture, or STATIC_URL (/static/) - picture by default

I am try next:

p><img src="{% if account.accountuserinfo.picture %}MEDIA{% else %}STATIC{% endif %}_URL{{ account.accountuserinfo.picture_url }}" alt="picture_for_{{ account.name }}" id="account_picture"></p>

, but result is MEDIA_URL(STATIC_URL) and path to file.

I am next try:

{% templatetag openvariable %} url 'entry_list' {% templatetag closevariable %}

but result is {{ MEDIA_URL }} or {{ STATIC_URL }} (not working)

may by anyone known how solved this problem
---------------------------------------------------

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/72159edf-e841-41ce-8513-571b142d4f24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Error running Django tutorial

I found the problem.

When the mysite\urls.py file is created, it has this line already in it.

from django.conf.urls import url

The tutorial asks you to add the following lines to the file.

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

I must did not notice that the 'include' was different, and so I had not placed it into the file.  I changed the file to add the 'include' and everything worked.

Thank you for the help.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+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/baedaefb-d570-4154-9ed1-95fba413ff71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
A simple annotation broke when I migrated by app from Django 1.8.x to 1.9.2, and I can't figure out why for the life of me.

Calling Company.objects.all().annotate(ticketcount=Count('srservice'))

throws an error "ProgrammingError: column "company.owner_id" must appear in the GROUP BY clause or be used in an aggregate function"

Rolling back to Django 1.8.5 fixes the problem.
The DB backend is Postgres.

Please ignore the horrible DB schema.  It's not mine.  It's an introspection of a horrible Windows ticketing app.


Am I missing something?

-A

--
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%2BrGrHkeqoH642%3DA%3D0w4DnC%3D2T8xzfignQOjh5BLLMto5f3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Error running Django tutorial

Can you attach your entire project's code in a ZIP file? I'm curious to test this myself...


On Monday, February 29, 2016 at 9:23:20 PM UTC+1, Mike Kipling wrote:
I added polls to settings.py :
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls.apps.PollsConfig',
]

Then I tried the migration:
C:\Data\Django_Code\FirstApp\mysite>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, sessions, contenttypes, auth
Running migrations:
  No migrations to apply.

Then I started the server and tried going to the address, but got the same results:
C:\Data\Django_Code\FirstApp\mysite>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
February 29, 2016 - 14:16:37
Django version 1.9.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /polls/
[29/Feb/2016 14:16:46] "GET /polls/ HTTP/1.1" 404 1921

I am working on a Windows OS, so I thought that perhaps changing the '/' in the mysite\urls.py to '\\' might help, but it did not.

--
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/bc913fc7-fe00-427f-87c7-cd5d52783551%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: empty request object

Yes, I'm an idiot. I had commented out the middleware when debugging
and forgot to put them back.

On Mon, Feb 29, 2016 at 10:09 AM, knbk <marten.knbk@gmail.com> wrote:
> That would happen if the AuthenticationMiddleware hasn't run. In what
> context is request.user missing?
>
> On Monday, February 29, 2016 at 3:54:24 PM UTC+1, Larry....@gmail.com wrote:
>>
>> So does anyone know why there would be a no user attr? I would expect
>> this:
>>
>> (Pdb) request.user
>> <django.utils.functional.SimpleLazyObject object at 0x10c424850>
>>
>> But I get this:
>>
>> (Pdb) request.user
>> *** AttributeError: 'WSGIRequest' object has no attribute 'user'
>>
>> On Sat, Feb 27, 2016 at 6:31 PM, Larry Martell <larry....@gmail.com>
>> wrote:
>> > Yes, you are absolutely correct. Thanks for directing me away from
>> > that red herring. But it seems request.user no longer exists.
>> >
>> > There is code that does this:
>> >
>> > if request.user.is_authenticated():
>> >
>> > which throws:
>> >
>> > AttributeError: "'WSGIRequest' object has no attribute 'user'"
>> >
>> > On Sat, Feb 27, 2016 at 5:48 PM, knbk <marte...@gmail.com> wrote:
>> >> I was referring to the wrong release notes. The rights one can be found
>> >> in
>> >> the 1.8 release notes in the miscellaneous section[1]:
>> >>
>> >>> HttpRequest now has a simplified repr (e.g. <WSGIRequest: GET
>> >>> '/somepath/'>). This won't change the behavior of
>> >>> theSafeExceptionReporterFilter class.
>> >>
>> >>
>> >> Printing the request in your debugger is nothing more than calling repr
>> >> on
>> >> the request and displaying the result. The conclusion is the same: the
>> >> request is not empty, but the string representation of the request has
>> >> changed. This is unrelated to whatever issue you're facing.
>> >>
>> >> [1] https://docs.djangoproject.com/en/1.9/releases/1.8/#miscellaneous
>> >>
>> >> On Saturday, February 27, 2016 at 11:21:18 PM UTC+1,
>> >> Larry....@gmail.com
>> >> wrote:
>> >>>
>> >>> On Sat, Feb 27, 2016 at 5:14 PM, knbk <marte...@gmail.com> wrote:
>> >>> > The `__repr__` method on HttpRequest was simplified in 1.9[1]. It is
>> >>> > not
>> >>> > an
>> >>> > accurate description of what is actually contained in the request,
>> >>> > and I
>> >>> > doubt it has anything to do with the actual issues you're facing.
>> >>> >
>> >>> > [1]
>> >>> >
>> >>> >
>> >>> > https://docs.djangoproject.com/en/1.9/releases/1.9/#httprequest-details-in-error-reporting
>> >>>
>> >>> I am printing the request object from the debugger:
>> >>>
>> >>> (Pdb) request
>> >>> <WSGIRequest: GET '/'>
>> >>>
>> >>> This is not in the debug page. I'm pretty sure it's empty as when I
>> >>> call login(request) I get a blank page with a 200 back.
>> >>>
>> >>> >
>> >>> > On Saturday, February 27, 2016 at 11:09:28 PM UTC+1,
>> >>> > Larry....@gmail.com
>> >>> > wrote:
>> >>> >>
>> >>> >> On Sat, Feb 27, 2016 at 5:02 PM, James Schneider
>> >>> >> <jrschn...@gmail.com> wrote:
>> >>> >> >
>> >>> >> > On Feb 27, 2016 1:55 PM, "Larry Martell" <larry....@gmail.com>
>> >>> >> > wrote:
>> >>> >> >>
>> >>> >> >> Anyone have any insights on this? Is there anything special I
>> >>> >> >> need
>> >>> >> >> to
>> >>> >> >> do get the request structure? The way this 1.9 site is now, it
>> >>> >> >> doesn't
>> >>> >> >> work at all because the request structure is not getting passed
>> >>> >> >> in.
>> >>> >> >>
>> >>> >> >
>> >>> >> > I'd be most suspicious of middle ware not handling the request
>> >>> >> > correctly.
>> >>> >>
>> >>> >> I tried removing all the middleware, but I got the same result.
>> >>> >> This
>> >>> >> is the middleware that was in place:
>> >>> >>
>> >>> >> 'django.middleware.security.SecurityMiddleware',
>> >>> >> 'django.contrib.sessions.middleware.SessionMiddleware',
>> >>> >> 'django.middleware.common.CommonMiddleware',
>> >>> >> 'django.middleware.csrf.CsrfViewMiddleware',
>> >>> >> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> >>> >>
>> >>> >> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>> >>> >> 'django.contrib.messages.middleware.MessageMiddleware',
>> >>> >> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> >>> >> 'django.middleware.security.SecurityMiddleware',
>> >>> >>
>> >>> >>
>> >>> >> > Have you tried moving to a fresh venv to ensure Django and other
>> >>> >> > packages
>> >>> >> > aren't damaged?
>> >>> >> >
>> >>> >> > Can you replicate the issue on a separate test server?
>> >>> >>
>> >>> >> No, I haven't tried either one yet. I guess I will have to do that,
>> >>> >> but I really would like to just get this setup working.

--
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/CACwCsY63rjWxpF-O2KP0tKzmYkcD7vJCw0OinSnCds%2BarDwxfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: parallel test running throwing pickleError

Sorry i forgot to mention that, i have installed the tblib. this is my pip list output

Django (1.10.dev20160216200705, /home/girish/Documents/Github/django)
fancycompleter (0.4)
ordereddict (1.1)
pdbpp (0.8.3)
pip (8.0.3)
py (1.4.31)
Pygments (2.1.2)
pytest (2.8.7)
setuptools (18.2)
tblib (1.2.0)
wheel (0.24.0)
wmctrl (0.3)


On Monday, February 29, 2016 at 11:07:37 PM UTC+5:30, Simon Charette wrote:
Hi Girish,

I think you didn't to install the `tblib` package[1].

Cheers,
Simon

[1] https://docs.djangoproject.com/en/1.9/ref/django-admin/#cmdoption-test--parallel

Le lundi 29 février 2016 12:13:08 UTC-5, girish ramnani a écrit :
when running the django test in parallel using the runner.py .
_pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleImportFailure'>: attribute lookup ModuleImportFailure on unittest.loader failed

error is thrown, and when the runner is run using a single process. the test suite executes.

I am using a new virtualenv with django installed in editable mode.

--
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/e1ebd082-ab92-4ae4-8da8-7165ceb4fd2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Error running Django tutorial

I added polls to settings.py :
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls.apps.PollsConfig',
]

Then I tried the migration:
C:\Data\Django_Code\FirstApp\mysite>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, sessions, contenttypes, auth
Running migrations:
  No migrations to apply.

Then I started the server and tried going to the address, but got the same results:
C:\Data\Django_Code\FirstApp\mysite>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
February 29, 2016 - 14:16:37
Django version 1.9.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /polls/
[29/Feb/2016 14:16:46] "GET /polls/ HTTP/1.1" 404 1921

I am working on a Windows OS, so I thought that perhaps changing the '/' in the mysite\urls.py to '\\' might help, but it did not.

--
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/8cc60a51-0c12-4404-a03a-5f6a857f533e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Error running Django tutorial

Well that's strange... The problem appears to be that your polls.urls file is not getting included in your project's URLConf (since the error message in your first post says that the only URL tried was admin/ ). I'm not sure if adding the app to INSTALLED_APPS is necessary for an app's URLConf to be able to be included, but it's worth a try. In FirstApp/settings.py add 'polls' to the list of INSTALLED_APPS so that it looks something like this:

INSTALLED_APPS = [
   
'django.contrib.admin',
   
'django.contrib.auth',
   
'django.contrib.contenttypes',
   
'django.contrib.sessions',
   
'django.contrib.messages',
   
'django.contrib.staticfiles',
   
'polls.apps.PollsConfig',
]



Otherwise it does seem like it could be a file refresh problem.


On Monday, February 29, 2016 at 4:03:42 PM UTC+1, Mike Kipling wrote:
Jorr,

No, I did not modify the settings.py file, because the tutorial specifically states: 

Note

Ignore the warning about unapplied database migrations for now; we'll deal with the database shortly.


Here is a link to the tutorial: https://docs.djangoproject.com/en/1.9/intro/tutorial01/





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+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/d00ca4a7-856e-4045-bc99-7b03c037b46f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Why not working ?

Please be more specific. What isn't working? What is the desired vs actual result?

On Monday, February 29, 2016 at 8:39:54 AM UTC-8, setivo...@gmail.com wrote:

my model
.........................

class Translator(models.Model):
    """
    Model for dictionaries tranlations
    """

    def dispatch_dictionary_media_files(instance, filename):
        return 'app_dictionaries/{0}/{1}'.format(instance.name.__str__(), filename)

    author = models.ForeignKey(settings.AUTH_USER_MODEL)
    name = models.CharField('Name of translator', max_length=50, unique=True)
    language_origin = models.CharField('Origin language', max_length=30, choices=LANGUAGES)
    language_translation = models.CharField('Language of translation', max_length=30, choices=LANGUAGES)
    picture = models.ImageField('Picture for translator', upload_to=dispatch_dictionary_media_files, blank=True, null=True)
    description = models.TextField('Description of translator', null=True, blank=True)
    slug_name = models.SlugField('Name for link', unique=True)
    rating = models.DecimalField('Rating', max_digits=4, decimal_places=2, editable=False, default=0)
    date_added = models.DateTimeField('Date added', auto_now_add=True)


my admin.py
--------------------------------------

class AdminTranslator(admin.ModelAdmin):
    fieldsets = [
        ('Requred fields', {
            'fields': ['name', 'author', ('slug_name', 'language_translation')],
        }),
        ('Not required fields', {
            'classes': ('collapse',),
            'fields': ['description', 'picture'],
            'description': 'It is fields nor required. And you may skip it.',
        }),
    ]
    date_hierarchy = 'date_added'
    actions_on_top = True
    actions_on_bottom = True
    empty_value_display = '-empty-'
    prepopulated_fields = {"slug_name": ("name",)}

    inlines = [AddTranslationInline]

    # -----------------------------------------
    list_display = ['name', 'author', 'language_origin', 'language_translation', 'rating', 'was_added_recently', 'date_added']
    list_filter = ['date_added']
    search_fields = ['name']

admin.site.register(Translator, AdminTranslator)






--
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/bfc00154-a4f5-482b-98fd-ab4fb6ee46cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Ajax + Django + jQuery + HTML5

On Sun, Feb 28, 2016 at 9:46 PM, <setivolkylany@gmail.com> wrote:
>
> I need get path to local file in <input type='file'> for ImageField.
> Next, transfer path to my view thought Ajax request, update in database and
> almost all.
>
> I need will make it manually, for my goals.
>
> May be, anyone known how it make?
>
> I am tried already django-ajaximage, Ajaxfileupload and many other, but it
> not working correct for me.

You cannot retrieve the path of the submitted file server side, it is
simply not possible - browsers will not share that information with
you, neither via HTTP requests, nor by poking at the DOM with
javascript.

If it is absolutely necessary, you must provide a second text input
and have the user manually put the information in there. Bear in mind
that there would be no way of verifying that what the user put in that
box is at all correct.

Can you explain what you are trying to do rather than what is going
wrong, because I think that would be illuminating.

Cheers

Tom

--
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/CAFHbX1L2dMrH%3DdUDuUaTN9J84Emnj0BA8woNkzbMDUgNqR75Rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: parallel test running throwing pickleError

Hi Girish,

I think you didn't to install the `tblib` package[1].

Cheers,
Simon

[1] https://docs.djangoproject.com/en/1.9/ref/django-admin/#cmdoption-test--parallel

Le lundi 29 février 2016 12:13:08 UTC-5, girish ramnani a écrit :
when running the django test in parallel using the runner.py .
_pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleImportFailure'>: attribute lookup ModuleImportFailure on unittest.loader failed

error is thrown, and when the runner is run using a single process. the test suite executes.

I am using a new virtualenv with django installed in editable mode.

--
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/e2e0d7b3-d4a1-48d7-b27e-dae61145d294%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

parallel test running throwing pickleError

when running the django test in parallel using the runner.py .
_pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleImportFailure'>: attribute lookup ModuleImportFailure on unittest.loader failed

error is thrown, and when the runner is run using a single process. the test suite executes.

I am using a new virtualenv with django installed in editable mode.

--
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/24c081f7-60c1-4b6f-8d04-e8ac48c7223d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Why not working ?


my model
.........................

class Translator(models.Model):
    """
    Model for dictionaries tranlations
    """

    def dispatch_dictionary_media_files(instance, filename):
        return 'app_dictionaries/{0}/{1}'.format(instance.name.__str__(), filename)

    author = models.ForeignKey(settings.AUTH_USER_MODEL)
    name = models.CharField('Name of translator', max_length=50, unique=True)
    language_origin = models.CharField('Origin language', max_length=30, choices=LANGUAGES)
    language_translation = models.CharField('Language of translation', max_length=30, choices=LANGUAGES)
    picture = models.ImageField('Picture for translator', upload_to=dispatch_dictionary_media_files, blank=True, null=True)
    description = models.TextField('Description of translator', null=True, blank=True)
    slug_name = models.SlugField('Name for link', unique=True)
    rating = models.DecimalField('Rating', max_digits=4, decimal_places=2, editable=False, default=0)
    date_added = models.DateTimeField('Date added', auto_now_add=True)


my admin.py
--------------------------------------

class AdminTranslator(admin.ModelAdmin):
    fieldsets = [
        ('Requred fields', {
            'fields': ['name', 'author', ('slug_name', 'language_translation')],
        }),
        ('Not required fields', {
            'classes': ('collapse',),
            'fields': ['description', 'picture'],
            'description': 'It is fields nor required. And you may skip it.',
        }),
    ]
    date_hierarchy = 'date_added'
    actions_on_top = True
    actions_on_bottom = True
    empty_value_display = '-empty-'
    prepopulated_fields = {"slug_name": ("name",)}

    inlines = [AddTranslationInline]

    # -----------------------------------------
    list_display = ['name', 'author', 'language_origin', 'language_translation', 'rating', 'was_added_recently', 'date_added']
    list_filter = ['date_added']
    search_fields = ['name']

admin.site.register(Translator, AdminTranslator)






--
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/d08afe6f-b993-4129-83f7-b8853f3f66e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: empty request object

That would happen if the AuthenticationMiddleware hasn't run. In what context is request.user missing?

On Monday, February 29, 2016 at 3:54:24 PM UTC+1, Larry....@gmail.com wrote:
So does anyone know why there would be a no user attr? I would expect this:

(Pdb) request.user
<django.utils.functional.SimpleLazyObject object at 0x10c424850>

But I get this:

(Pdb) request.user
*** AttributeError: 'WSGIRequest' object has no attribute 'user'

On Sat, Feb 27, 2016 at 6:31 PM, Larry Martell <larry....@gmail.com> wrote:
> Yes, you are absolutely correct. Thanks for directing me away from
> that red herring. But it seems request.user no longer exists.
>
> There is code that does this:
>
> if request.user.is_authenticated():
>
> which throws:
>
> AttributeError: "'WSGIRequest' object has no attribute 'user'"
>
> On Sat, Feb 27, 2016 at 5:48 PM, knbk <marte...@gmail.com> wrote:
>> I was referring to the wrong release notes. The rights one can be found in
>> the 1.8 release notes in the miscellaneous section[1]:
>>
>>> HttpRequest now has a simplified repr (e.g. <WSGIRequest: GET
>>> '/somepath/'>). This won't change the behavior of
>>> theSafeExceptionReporterFilter class.
>>
>>
>> Printing the request in your debugger is nothing more than calling repr on
>> the request and displaying the result. The conclusion is the same: the
>> request is not empty, but the string representation of the request has
>> changed. This is unrelated to whatever issue you're facing.
>>
>> [1] https://docs.djangoproject.com/en/1.9/releases/1.8/#miscellaneous
>>
>> On Saturday, February 27, 2016 at 11:21:18 PM UTC+1, Larry....@gmail.com
>> wrote:
>>>
>>> On Sat, Feb 27, 2016 at 5:14 PM, knbk <marte...@gmail.com> wrote:
>>> > The `__repr__` method on HttpRequest was simplified in 1.9[1]. It is not
>>> > an
>>> > accurate description of what is actually contained in the request, and I
>>> > doubt it has anything to do with the actual issues you're facing.
>>> >
>>> > [1]
>>> >
>>> > https://docs.djangoproject.com/en/1.9/releases/1.9/#httprequest-details-in-error-reporting
>>>
>>> I am printing the request object from the debugger:
>>>
>>> (Pdb) request
>>> <WSGIRequest: GET '/'>
>>>
>>> This is not in the debug page. I'm pretty sure it's empty as when I
>>> call login(request) I get a blank page with a 200 back.
>>>
>>> >
>>> > On Saturday, February 27, 2016 at 11:09:28 PM UTC+1, Larry....@gmail.com
>>> > wrote:
>>> >>
>>> >> On Sat, Feb 27, 2016 at 5:02 PM, James Schneider
>>> >> <jrschn...@gmail.com> wrote:
>>> >> >
>>> >> > On Feb 27, 2016 1:55 PM, "Larry Martell" <larry....@gmail.com> wrote:
>>> >> >>
>>> >> >> Anyone have any insights on this? Is there anything special I need
>>> >> >> to
>>> >> >> do get the request structure? The way this 1.9 site is now, it
>>> >> >> doesn't
>>> >> >> work at all because the request structure is not getting passed in.
>>> >> >>
>>> >> >
>>> >> > I'd be most suspicious of middle ware not handling the request
>>> >> > correctly.
>>> >>
>>> >> I tried removing all the middleware, but I got the same result. This
>>> >> is the middleware that was in place:
>>> >>
>>> >>     'django.middleware.security.SecurityMiddleware',
>>> >>     'django.contrib.sessions.middleware.SessionMiddleware',
>>> >>     'django.middleware.common.CommonMiddleware',
>>> >>     'django.middleware.csrf.CsrfViewMiddleware',
>>> >>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> >>     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>> >>     'django.contrib.messages.middleware.MessageMiddleware',
>>> >>     'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> >>     'django.middleware.security.SecurityMiddleware',
>>> >>
>>> >>
>>> >> > Have you tried moving to a fresh venv to ensure Django and other
>>> >> > packages
>>> >> > aren't damaged?
>>> >> >
>>> >> > Can you replicate the issue on a separate test server?
>>> >>
>>> >> No, I haven't tried either one yet. I guess I will have to do that,
>>> >> but I really would like to just get this setup working.

--
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/d9ea027a-4e64-4e43-a5f9-8fe484710574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Error running Django tutorial

Jorr,

No, I did not modify the settings.py file, because the tutorial specifically states: 

Note

Ignore the warning about unapplied database migrations for now; we'll deal with the database shortly.


Here is a link to the tutorial: https://docs.djangoproject.com/en/1.9/intro/tutorial01/





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+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/faaf04fa-6c50-4648-9ef6-d2f1b3c1e497%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Translate permissions Django



El lunes, 29 de febrero de 2016, 14:14:42 (UTC+1), Marcos Serrano escribió:
Hello,

How yo translate the default permissions django. Keywords (Add, Delete ... ) 


I tried to do something like this but it has not worked for me.

Thx.

--
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/300eb70b-2965-4010-92ee-cc860856a5fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: empty request object

So does anyone know why there would be a no user attr? I would expect this:

(Pdb) request.user
<django.utils.functional.SimpleLazyObject object at 0x10c424850>

But I get this:

(Pdb) request.user
*** AttributeError: 'WSGIRequest' object has no attribute 'user'

On Sat, Feb 27, 2016 at 6:31 PM, Larry Martell <larry.martell@gmail.com> wrote:
> Yes, you are absolutely correct. Thanks for directing me away from
> that red herring. But it seems request.user no longer exists.
>
> There is code that does this:
>
> if request.user.is_authenticated():
>
> which throws:
>
> AttributeError: "'WSGIRequest' object has no attribute 'user'"
>
> On Sat, Feb 27, 2016 at 5:48 PM, knbk <marten.knbk@gmail.com> wrote:
>> I was referring to the wrong release notes. The rights one can be found in
>> the 1.8 release notes in the miscellaneous section[1]:
>>
>>> HttpRequest now has a simplified repr (e.g. <WSGIRequest: GET
>>> '/somepath/'>). This won't change the behavior of
>>> theSafeExceptionReporterFilter class.
>>
>>
>> Printing the request in your debugger is nothing more than calling repr on
>> the request and displaying the result. The conclusion is the same: the
>> request is not empty, but the string representation of the request has
>> changed. This is unrelated to whatever issue you're facing.
>>
>> [1] https://docs.djangoproject.com/en/1.9/releases/1.8/#miscellaneous
>>
>> On Saturday, February 27, 2016 at 11:21:18 PM UTC+1, Larry....@gmail.com
>> wrote:
>>>
>>> On Sat, Feb 27, 2016 at 5:14 PM, knbk <marte...@gmail.com> wrote:
>>> > The `__repr__` method on HttpRequest was simplified in 1.9[1]. It is not
>>> > an
>>> > accurate description of what is actually contained in the request, and I
>>> > doubt it has anything to do with the actual issues you're facing.
>>> >
>>> > [1]
>>> >
>>> > https://docs.djangoproject.com/en/1.9/releases/1.9/#httprequest-details-in-error-reporting
>>>
>>> I am printing the request object from the debugger:
>>>
>>> (Pdb) request
>>> <WSGIRequest: GET '/'>
>>>
>>> This is not in the debug page. I'm pretty sure it's empty as when I
>>> call login(request) I get a blank page with a 200 back.
>>>
>>> >
>>> > On Saturday, February 27, 2016 at 11:09:28 PM UTC+1, Larry....@gmail.com
>>> > wrote:
>>> >>
>>> >> On Sat, Feb 27, 2016 at 5:02 PM, James Schneider
>>> >> <jrschn...@gmail.com> wrote:
>>> >> >
>>> >> > On Feb 27, 2016 1:55 PM, "Larry Martell" <larry....@gmail.com> wrote:
>>> >> >>
>>> >> >> Anyone have any insights on this? Is there anything special I need
>>> >> >> to
>>> >> >> do get the request structure? The way this 1.9 site is now, it
>>> >> >> doesn't
>>> >> >> work at all because the request structure is not getting passed in.
>>> >> >>
>>> >> >
>>> >> > I'd be most suspicious of middle ware not handling the request
>>> >> > correctly.
>>> >>
>>> >> I tried removing all the middleware, but I got the same result. This
>>> >> is the middleware that was in place:
>>> >>
>>> >> 'django.middleware.security.SecurityMiddleware',
>>> >> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> >> 'django.middleware.common.CommonMiddleware',
>>> >> 'django.middleware.csrf.CsrfViewMiddleware',
>>> >> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> >> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>> >> 'django.contrib.messages.middleware.MessageMiddleware',
>>> >> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> >> 'django.middleware.security.SecurityMiddleware',
>>> >>
>>> >>
>>> >> > Have you tried moving to a fresh venv to ensure Django and other
>>> >> > packages
>>> >> > aren't damaged?
>>> >> >
>>> >> > Can you replicate the issue on a separate test server?
>>> >>
>>> >> No, I haven't tried either one yet. I guess I will have to do that,
>>> >> but I really would like to just get this setup working.

--
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/CACwCsY4SPocxSzDrtoij3D9XifLrOsKA7GhJPcFpNajYd_jg%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.