Re: Class Based Views : filter items by users

2017-07-07 Thread Nabil BOUDERBALA
Thank you, I have updated the template accordingly.
Regardin the views, I solved the issue through the function below :

def itemuserfunc(request, user):
template = get_template('dcf/user_item_list_noedit.html')
profile_owner = DcfUser.objects.filter(username=user)  # Assuming you have 
entry in your database
item_list = Item.objects.filter(user = profile_owner)
return template.render(Context({'item_list': item_list}))


On Thursday, July 6, 2017 at 11:56:06 AM UTC+2, Melvyn Sopacua wrote:
>
> Please show all relevant bits of the code (user_list is not part handed 
> off to the template).
>
>  
>
> But you could start but not naming 2 different variables inside 
> eachother's scope identical.
>
>  
>
> On Tuesday 04 July 2017 09:36:51 Nabil BOUDERBALA wrote:
>
>  
>
> > {% if user %}
>
> > {% for user in user_list %}
>
>  
>
> -- 
>
> 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/8c470566-95e3-4f00-826e-6abd7c38d3a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Vim plugin that does Django code completion?

2017-07-07 Thread Robert F.
Is there a Vim plugin that does code completion for Django?  I'd like to be 
able to type something like "foobar = models." and hit Tab and see a list 
of classes like CharField or Foreign key.  Alternately, I'd be OK with 
entering an abbreviation that would bring up the proper code snippet.  The 
Django documentation suggests YouCompleteMe but it appears to only handle 
Python code, not Django specifically.  Also, I haven't been able to get it 
to work on my Mac laptop.

I almost exclusively do editing of Django files on a remote Debian server 
from my Mac laptop.  I know PyCharm provides the ability to edit remote 
files and it has Vim emulation but it's pretty expensive and I'm not sure 
how closely the emulator emulates Vim.  SublimeText appears to have a 
"Djaneiro" package that does what I need but it looks like editing remote 
files is rather difficult with Sublime.  Doesn't Vim have better support 
for Django code completion that's comparable to these two applications?

-- 
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/166226ca-2fc6-4454-9baf-0d871c552a8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django music streaming app using audiotracks..

2017-07-07 Thread IaMtheMcee
Hi, I'm relatively new to django.. I'm trying to integrate the audiotracks 
package with my project. I'm trying to integrate the audiotracks package 
but I'm getting  NoReverseMatch error.
The documentation states..


















*Add ``audiotracks`` to your app~~~Edit 
``settings.py`` and add ``audiotracks`` to your list of``INSTALLED_APPS``. 
Then synchronize your database with::$ python manage.py syncdbEdit your 
ROOT_URLCONF_ and add a piece of code similar to::urlpatterns += 
patterns('',# Here we mount the app under /music. Feel free to use 
something elseurl("^music", include("audiotracks.urls")),# 
Some URLs require a Django username
url("^(?P[\w\._-]+)/music", include("audiotracks.urls")),
)Visit the URL ``/music/upload`` to upload your first track*.

the error occurs when i try to access music/upload..

here's the full traceback.


Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/music/upload

Django Version: 1.11.3
Python Version: 3.6.0
Installed Applications:
['account',
 'music',
 'audiotracks',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template 
C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django_audiotracks-0.2.5-py3.6.egg\audiotracks\templates\audiotracks\base.html,
 
error at line 25
   Reverse for 'user_index' with arguments '('addemo1',)' not found. 2 
pattern(s) tried: ['music/tracks/(?P\\d)/?$', 
'music/tracks$']   15 :   .errorlist { color: red; list-style: none; 
display: inline; }
   16 : 
   17 : {% block extra_head %}{% endblock %}
   18 :   
   19 :   
   20 : 
   21 :   {% block subnav %}
   22 :   {% if user.is_authenticated %}
   23 :   
   24 : {% trans 'Latest 
tracks' %}
   25 : {% 
trans 'Your tracks' %}
   26 : {% trans 'Upload 
track' %}
   27 :   
   28 :   {% else %}
   29 :    
   30 :   {% endif %}
   31 :   {% endblock %}
   32 : 
   33 :   {% if messages %}
   34 :   
   35 : {% for message in messages %}


Traceback:

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py"
 
in inner
  41. response = get_response(request)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py"
 
in _legacy_get_response
  249. response = self._get_response(request)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py"
 
in _get_response
  187. response = self.process_exception_by_middleware(e, 
request)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py"
 
in _get_response
  185. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\decorators.py"
 
in _wrapped_view
  23. return view_func(request, *args, **kwargs)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\decorators\csrf.py"
 
in wrapped_view
  58. return view_func(*args, **kwargs)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django_audiotracks-0.2.5-py3.6.egg\audiotracks\views.py"
 
in upload_track
  109. return render(request, "audiotracks/new.html", {'form': form})

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\shortcuts.py"
 
in render
  30. content = loader.render_to_string(template_name, context, 
request, using=using)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\loader.py"
 
in render_to_string
  68. return template.render(context, request)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\backends\django.py"
 
in render
  66. return self.template.render(context)

File 
"C:\Users\Alexander\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\base.py"
 
in render
  207. return self._render(context)

File 
"C:\Users\Al

Re: Vim plugin that does Django code completion?

2017-07-07 Thread Phang Mulianto
Hi

You can use plugin on vim using snipmate. You can create your own
autocomplete or using others created snip available for vim.

Hope helps.



On 7 Jul 2017 11:27 pm, "Robert F."  wrote:

> Is there a Vim plugin that does code completion for Django?  I'd like to
> be able to type something like "foobar = models." and hit Tab and see a
> list of classes like CharField or Foreign key.  Alternately, I'd be OK with
> entering an abbreviation that would bring up the proper code snippet.  The
> Django documentation suggests YouCompleteMe but it appears to only handle
> Python code, not Django specifically.  Also, I haven't been able to get it
> to work on my Mac laptop.
>
> I almost exclusively do editing of Django files on a remote Debian server
> from my Mac laptop.  I know PyCharm provides the ability to edit remote
> files and it has Vim emulation but it's pretty expensive and I'm not sure
> how closely the emulator emulates Vim.  SublimeText appears to have a
> "Djaneiro" package that does what I need but it looks like editing remote
> files is rather difficult with Sublime.  Doesn't Vim have better support
> for Django code completion that's comparable to these two applications?
>
> --
> 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/166226ca-2fc6-4454-9baf-0d871c552a8f%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/CA%2BSr5mT3euLNtWuhgn%2B8umCdxCM4MtG0mp5BZ1FxYj3MRmv4uA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Vim plugin that does Django code completion?

2017-07-07 Thread James Schneider
On Jul 7, 2017 8:27 AM, "Robert F."  wrote:

Is there a Vim plugin that does code completion for Django?  I'd like to be
able to type something like "foobar = models." and hit Tab and see a list
of classes like CharField or Foreign key.  Alternately, I'd be OK with
entering an abbreviation that would bring up the proper code snippet.  The
Django documentation suggests YouCompleteMe but it appears to only handle
Python code, not Django specifically.  Also, I haven't been able to get it
to work on my Mac laptop.

I almost exclusively do editing of Django files on a remote Debian server
from my Mac laptop.  I know PyCharm provides the ability to edit remote
files and it has Vim emulation but it's pretty expensive and I'm not sure
how closely the emulator emulates Vim.  SublimeText appears to have a
"Djaneiro" package that does what I need but it looks like editing remote
files is rather difficult with Sublime.  Doesn't Vim have better support
for Django code completion that's comparable to these two applications?


PyCharm's Vim emulation is quite excellent. For me, PyCharm pro is worth
the money for the extra Django integration. The community version is also
quite good, the only place I really missed the pro version is in the
template tags. The code completion works great as long as you mark your
project directories as source locations correctly.

For editing remote files, you may want to look into using sshfs to mount
your project directly locally. It's basically a file share mounted over
SSH, so everything is encrypted in transit.

http://www.miscdebris.net/blog/2009/06/29/installing-sshfs-on-mac-os-x/

Typically though, I'm editing/running files locally, then pushing them to
the server via git.

-James

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


Re: Vim plugin that does Django code completion?

2017-07-07 Thread Robert F.
Thanks Mulianto and James.  To James, perhaps I don't have a good workflow 
which is why the ability to edit files on a remote server is also a 
necessity.  I grew tired of having to build a development environment on 
both my Mac laptop and my Debian server where my Django app runs so now I 
just log into my dev server and do all my editing there using Vim.  I don't 
have time to setup up a local Debian server using Vagrant and Ansible and 
even if I did, I suspect PyCharm would still think of that local VM as a 
remote server.  I'm not sure.  These environments can easily become 
complicated and confusing to a Django noob like me.  I'm not really sure 
what the optimal development environment setup should be.

On Friday, July 7, 2017 at 10:46:58 AM UTC-7, James Schneider wrote:
>
>
>
> On Jul 7, 2017 8:27 AM, "Robert F." > 
> wrote:
>
> Is there a Vim plugin that does code completion for Django?  I'd like to 
> be able to type something like "foobar = models." and hit Tab and see a 
> list of classes like CharField or Foreign key.  Alternately, I'd be OK with 
> entering an abbreviation that would bring up the proper code snippet.  The 
> Django documentation suggests YouCompleteMe but it appears to only handle 
> Python code, not Django specifically.  Also, I haven't been able to get it 
> to work on my Mac laptop.
>
> I almost exclusively do editing of Django files on a remote Debian server 
> from my Mac laptop.  I know PyCharm provides the ability to edit remote 
> files and it has Vim emulation but it's pretty expensive and I'm not sure 
> how closely the emulator emulates Vim.  SublimeText appears to have a 
> "Djaneiro" package that does what I need but it looks like editing remote 
> files is rather difficult with Sublime.  Doesn't Vim have better support 
> for Django code completion that's comparable to these two applications?
>
>
> PyCharm's Vim emulation is quite excellent. For me, PyCharm pro is worth 
> the money for the extra Django integration. The community version is also 
> quite good, the only place I really missed the pro version is in the 
> template tags. The code completion works great as long as you mark your 
> project directories as source locations correctly.
>
> For editing remote files, you may want to look into using sshfs to mount 
> your project directly locally. It's basically a file share mounted over 
> SSH, so everything is encrypted in transit.
>
> http://www.miscdebris.net/blog/2009/06/29/installing-sshfs-on-mac-os-x/
>
> Typically though, I'm editing/running files locally, then pushing them to 
> the server via git.
>
> -James
>

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


Google analytics and request.resolver_match.url_name

2017-07-07 Thread Alex Riina
I'm getting familiar with google analytics and stumbled 
upon 
https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#modifying_page_urls
 
in which the google docs recommend regexing out some unique ids. In django, 
it's a lot simpler to get something like /user/account/ from 
/user/USER_ID/account/ by using

  ga('set', 'page', "{{ request.resolver_match.url_name }}");


Is there any reason I should rethink that?

-- 
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/17291c67-0126-4e1a-a497-50846b9eeed0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Channels: Sudden & Mysterious 400 Bad Request

2017-07-07 Thread jamie . bliss
I'm using Nginx -> Daphne -> Redis -> manage.py runworker. Nginx and daphne 
are both producing a 400 Bad Request to simple GET requests. I'm not seeing 
the request in the worker log (-v 3). Redis answers to `redis-cli ping`.

Daphne logs look like it just served the request normally. Worker logs are 
empty.

I'm trying this both through a browser against nginx, and through curl 
against daphne directly. Identical responses.

I thought it I had it working, but I guess I broke it.

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


Django Channels compatibility with Google App/Compute Engine?

2017-07-07 Thread Alex Z
Hello! I'm really new here, and also relatively new to Django, and I've 
been researching different ways to incorporate real-time updates with 
Django without specifically using AJAX. I dug around and found out about 
Django Channels, and I'm learning the basics right now. What I'm trying to 
do is develop a card game app, and I wanted each player to be able to play 
a card on their computer, and it would show up for everyone else playing 
(on different computers) without refreshing the page. I think I can figure 
something out to accomplish this with Django Channels, but I have a 
different issue: is Django Channels easily compatible with Google 
App/Compute Engine? I want to deploy it using Google Compute Engine, but I 
couldn't find many resources on the topic or any that answered my 
questions. For example, how would I deploy my Django app with a specific 
channel layer (Redis, RabbitMQ, etc.)? What other precautions should I take 
before I deploy a Django project that uses Channels? Any input on this 
would be fantastic, even any information on deploying a Django project that 
uses Channels via Google Compute Engine. Thanks!

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