Admin login returns 405 Not Allowed

2016-09-04 Thread Peter Laudenslager
Sorry - somehow posted too early.

For a moment I thought I had this sorted.  I had slightly different versions of 
Django between my development and production environments, and some of the 
static files for the admin pages had changed.  It made sense that when Nginx 
redirected the static file requests, the new resources weren't there.  Upgraded 
both environments to the latest Django (now 1.10.1), recollected static files, 
and got it to work.

Just to prove the point, I logged out, and tried to login with a different 
account, but got the 405 page again.  So I tried the first account again with 
no success.  Except for that one successful login, everything continues to 
return the 405 error.

>From the errors in the Django log, it still seems like I may be missing a 
>static file, or maybe a permissions problem on a directory, but no clear 
>pointer to a specific file or directory.

Anyone have any tips on how to troubleshoot this?

-- 
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/5fb3f079-5dc2-4ca5-bbc7-1dd49416568c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Admin login returns 405 Not Allowed

2016-09-04 Thread Peter Laudenslager
Hi All,

Having trouble moving my Django site into production.  I can hit pages for 
my application (no authentication required), and they all seem to work 
correctly.  When I connect to the default admin page, I see the correct 
login dialog box.  When I submit my credentials, I get a 405 Not Allowed 
page returned by Nginx.  I am sure that I have correct credentials, and 
would not expect this page returned even if my credentials were incorrect.

Steps to recreate:

   1. from my laptop browser, connect to www.mysite.com/admin
   2. see default django login screen
   3. type known good account credentials
   4. see 405 Not Allowed page returned

What I expect to happen:

Following steps 1-3 above, in step 4, I expect to see either the default 
Django admin screen, or the default Django failed login screen (looks just 
like the login, with an error message).

The admin login behaves correctly on my laptop, but not on the production 
server.

Configurations between laptop (development) and production:

   1. production uses Nginx 1.4.6 and Gunicorn 17.5 on Ubuntu Linux 14.04.5
   2. laptop is MacOS 10.11.6 running the Django 1.10.1 development server 
   (manage.py run server)
   3. I have collected static files (so far, they only exist for the 
   built-in admin) into a static directory in the root of the django project 
   (one level up from manage.py)


What I have tried:


-- 
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/b7bb7b56-cbec-4bc0-9c47-96b5175e390c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NIST’s new password rules - Digital Authentication Guidelines

2016-09-04 Thread Uri Even-Chen
Thank you, Tim. I appreciate your reply.


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    

On Sun, Sep 4, 2016 at 9:37 PM, Tim Graham  wrote:

> I suspect passwords were always salted and hashed, though things have
> improved over the years. In particular, PBKDF2 hashing was added in Django
> 1.4:
>
> https://docs.djangoproject.com/en/stable/releases/1.4/#
> improved-password-hashing
>
> On Sunday, September 4, 2016 at 10:58:13 AM UTC-4, uri wrote:
>>
>> Thank you, Tim. Although we are using Django 1.9 and I understand that
>> passwords are hashed and salted, it's interesting to know which version of
>> Django was the first one to hash and salt passwords? I didn't find it
>> documented there.
>>
>> Thanks,
>> Uri.
>>
>>
>> *Uri Even-Chen*
>> [image: photo] Phone: +972-54-3995700
>> Email: u...@speedy.net
>> Website: http://www.speedysoftware.com/uri/en/
>> 
>> 
>> 
>> 
>>
>> On Fri, Sep 2, 2016 at 3:35 PM, Tim Graham  wrote:
>>
>>> Hi,
>>>
>>> We have fairly comprehensive documentation about passwords:
>>> https://docs.djangoproject.com/en/stable/topics/auth/passwords/
>>>
>>> Let us know if you have unanswered questions after reading that.
>>>
>>> Tim
>>>
>>> On Friday, September 2, 2016 at 7:35:03 AM UTC-4, uri wrote:

 To Django users,

 Did you see this article: https://nakedsecurity
 .sophos.com/2016/08/18/nists-new-password-rules-what-you-need-to-know/

 Does Django comply with the password guidelines and from which Django
 version? Especially regarding the way the passwords are saved. I'm
 developing Speedy Net in Django and I want to make sure I can rely on
 Django in the way my users' passwords are saved in our database. I also
 increased the minimal password length to 8 characters, and removed the
 requirement for passwords to be alphanumeric.

 Thanks,
 Uri.

 *Uri Even-Chen*
 [image: photo] Phone: +972-54-3995700
 Email: u...@speedy.net
 Website: http://www.speedysoftware.com/uri/en/
 
 
 
 

>>> --
>>> 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/ms
>>> gid/django-users/dc7489bb-c0d4-49ff-b371-d4958b4bc2ed%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/4ea4160b-b91e-4f69-8470-c7f88ad7c03e%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/CAMQ2MsFyQrgV3JNc%2BUgkpKQYfhgvCFpNn2nPcZ4QZeCRpNUN9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Binding a ModelForm to an existing instance

2016-09-04 Thread Carlos Mermingas
I have a ModelForm:

class ArticleForm(forms.ModelForm):

class Meta:

model = Article

fields = ['url',]


The Article model has a url field which is unique. I want users to enter a URL. 
If the Article already exists, it gets reused. Otherwise, a new instance is 
created.


And the corresponding view:


 1 @login_required

 2 def get_article(request):

 3if request.method == 'POST':

 4# Should I get a new instance here?

 5form = ArticleForm(request.POST, instance=None)

 6if form.is_valid():

 7article, created = 
Article.objects.get_or_create(url=form.cleaned_data['url']) 

 9# Some more work goes here

10return redirect(reverse('articles:list'))

11else:

12form = ArticleForm()

13return render(request, 'articles/get_article.html', {'form': form})


The form is validating the uniqueness of the model, which is great. The dilemma 
I am having is that I would like to bind the form to the existing instance in 
line 4. But at that point, the form has not been cleaned, so I wouldn't want to 
hit the database with it.


*What's the proper pattern to do this?*


Thanks a lot!

-- 
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/b9fc0fed-d8f6-44e8-8687-11d94669d2a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to design URL pattern to get the field value using request.query_params.get in the view

2016-09-04 Thread ADEWALE ADISA
show your url configuration
On Sep 4, 2016 3:59 PM, "Afiz S"  wrote:

> Hi All,
>
> I have very new to Django. Can anyone tell me how to the data from URL to
> view.
>
> in this below example I am trying to get year param from the URL.
>
> def get_queryset(self):
> queryset = Battles.objects.all()
> year = self.request.query_params.get('year',None)
> if year is not None:
> queryset = queryset.filter(year__exact=year)
> return queryset
>
> --
> 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/693bbae5-0ffc-4737-86be-a9cee202e68e%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/CAMGzuy846bY8QiT9-WEBhmzx%3DL%2Bx_OPJOpVKPFvCLuoFHpJ-ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NIST’s new password rules - Digital Authentication Guidelines

2016-09-04 Thread Tim Graham
I suspect passwords were always salted and hashed, though things have 
improved over the years. In particular, PBKDF2 hashing was added in Django 
1.4:

https://docs.djangoproject.com/en/stable/releases/1.4/#improved-password-hashing

On Sunday, September 4, 2016 at 10:58:13 AM UTC-4, uri wrote:
>
> Thank you, Tim. Although we are using Django 1.9 and I understand that 
> passwords are hashed and salted, it's interesting to know which version of 
> Django was the first one to hash and salt passwords? I didn't find it 
> documented there.
>
> Thanks,
> Uri.
>
>
> *Uri Even-Chen*   
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net 
> Website: http://www.speedysoftware.com/uri/en/
>   
>   
>   
>
> On Fri, Sep 2, 2016 at 3:35 PM, Tim Graham  > wrote:
>
>> Hi,
>>
>> We have fairly comprehensive documentation about passwords: 
>> https://docs.djangoproject.com/en/stable/topics/auth/passwords/
>>
>> Let us know if you have unanswered questions after reading that.
>>
>> Tim
>>
>> On Friday, September 2, 2016 at 7:35:03 AM UTC-4, uri wrote:
>>>
>>> To Django users,
>>>
>>> Did you see this article: 
>>> https://nakedsecurity.sophos.com/2016/08/18/nists-new-password-rules-what-you-need-to-know/
>>>
>>> Does Django comply with the password guidelines and from which Django 
>>> version? Especially regarding the way the passwords are saved. I'm 
>>> developing Speedy Net in Django and I want to make sure I can rely on 
>>> Django in the way my users' passwords are saved in our database. I also 
>>> increased the minimal password length to 8 characters, and removed the 
>>> requirement for passwords to be alphanumeric.
>>>
>>> Thanks,
>>> Uri.
>>>
>>> *Uri Even-Chen*   
>>> [image: photo] Phone: +972-54-3995700
>>> Email: u...@speedy.net
>>> Website: http://www.speedysoftware.com/uri/en/
>>>   
>>>   
>>>   
>>> 
>>>
>> -- 
>> 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/dc7489bb-c0d4-49ff-b371-d4958b4bc2ed%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/4ea4160b-b91e-4f69-8470-c7f88ad7c03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Blank field object just for headings in form object

2016-09-04 Thread Shane Fagan
Hi,

I asked this question on Stackoverflow but didn't get any answers so 
hopefully someone can give me an answer here. The Stackoverflow is 
http://stackoverflow.com/questions/39317812/django-forms-form-header-field To 
start I'm creating fields on the fly for a question sheet project that 
takes in admin created questions. The issue is I need to do a heading for 
sections for walking people through the form. 

Any ideas? I was thinking of creating a field object to use but I didn't 
get much from the docs since it's pretty much a stub that focuses more on 
overloading the current fields and doing custom validation..etc. 

Regards,
Shane

-- 
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/8abc46b4-6706-45cc-8942-100bb9ada943%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query annotation with date difference

2016-09-04 Thread Peter of the Norse
I would use the DB NOW() function for this.  https://docs.djangoproject.com/en/1.9/ref/models/database-functions/#nowfrom django.db.models.functions import Now.annotate(ratio=(F(‘due_date')-Now())/F('Interval'))On Aug 3, 2016, at 3:34 PM, Constantine Covtushenko  wrote:Sorry, I did not specify.I have been using 'Postgresql' with 'psycopg2 v.2.6.2'.They gave me those results.Also here is a sql query given from log:SELECT "test_app_entity"."id", "test_app_entity"."due_date", "test_app_entity"."interval", (("test_app_entity"."due_date" - '2016-08-03T21:31:58.325549+00:00'::timestamptz) / "test_app_entity"."interval") AS "ratio" FROM "test_app_entity"; args=(datetime.datetime(2016, 8, 3, 21, 31, 58, 325549, tzinfo=),)That is all that I can say at the moment.On Thu, Aug 4, 2016 at 12:20 AM, Yoann Duriaud  wrote:Thanks, unfortunately not so great on my side:I added in the query (forgetting the division for now):.annotate(ratio=ExpressionWrapper(F('due_date')-timezone.now(), DateTimeField()))which leads to the following statement in the query: ("contentstatus"."due_date" - 2016-08-03 21:05:10.743799+00:00) AS "ratio"This is not a valid SQL statement (at least for SQLite) and leads to the following error message when the query is evaluated:Exception Type:TypeError




  Exception Value:
  expected string or bytes-like objectAny idea what I get this behavior?YoannLe samedi 30 juillet 2016 22:41:21 UTC+2, Yoann Duriaud a écrit :Hello,I would like to annotate a query with the following _expression_: ([Due Date] - [Now])/[Interval]. [Due Date] and [Interval] are fields from the database, while [Now] should be "equal" to timezone.now().So this would look like:.annotate(ratio=(F('due_date')-timezone.now())/F('Interval'))but this does not work. Does someone know how the _expression_ should be written (if it is indeed feasible with Django ORM)?Thanks for your help!Yoann

-- 
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/038837c5-6b5b-4ae9-895a-b6b54282d978%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/CAK52boX3b%2Bb6okqsKVXX%3DxQ7HUss9qL_BRbL8rpWFGE%3Ds2xL9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Peter of the Norserahmc...@radio1190.org






-- 
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/3520A304-1CF3-4569-8F73-033BD1D108E1%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Django form Datetime field valid error after add django.middleware.locale.LocaleMiddleware'

2016-09-04 Thread 广宏伟


I use django version 1.10, When a add LocaleMiddleware into settings.py, 
form valid error. I have been makemessage and compile it

Here is my model and form, 



class User(AbstractUser):
> ...   
> is_first_login = models.BooleanField(default=False)
> date_expired = models.DateTimeField(default=date_expired_default, 
> blank=True, null=True, verbose_name='Date expired')
> created_by = models.CharField(max_length=30, default='')
>
>
> class UserAddForm(ModelForm):
> class Meta:
> model = User
> fields = [
> 'username', 'name', 'email', 'groups', 'wechat',
> 'phone', 'enable_otp', 'role', 'date_expired', 'comment',
> ]
>
> help_texts = {
> 'username': '* required',
> 'email': '* required',
> }
>
>
And settings.py

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.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]


 
I also ask on 
stackoverflow 
http://stackoverflow.com/questions/39318887/django-form-datetime-field-valid-error-after-add-django-middleware-locale-locale

-- 
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/55301a88-6aba-4494-a060-bca69bc37bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


FileField with UUID filename

2016-09-04 Thread Jon Ribbens
I have a model which basically just represents a file. I want to use a UUID 
as the filename. I could do the following:

def _get_filename(instance, filename):
return str(uuid.uuid4())

class File(Model):
   content = FileField(db_index=True, upload_to=_get_filename)
   filetype = CharField("MIME Type", max_length=256)

which does work however it is sub-optimal in a couple of ways:

   - the UUID is stored as a VARCHAR in the database
   - the UUID is not used as the primary key
   - there is a pointless additional integer field as the primary key
   - you can't even add unique=True to the field

So I was wondering:

   - why does FileField refuse to allow its use in a unique index or as the 
   primary key?
   - how can I get FileField to use a UUID field in the database?

Any thoughts would be greatly 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+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/396e0394-3112-46db-9499-0cfbb8eb780a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Serving very large pdf files with django

2016-09-04 Thread Avraham Serour
if you need to server the pdf then it will be downloaded to the user
computer, even if you are visualizing in browser with js.

What you can do is show screenshots of the pdf pages, then you would be
serving individual jpgs for each page and not a single 100mb file.

You can create previews for each page using something like imagemagick as
mentioned before and create a layout to view that using django template.



On Sun, Sep 4, 2016 at 9:52 AM, <06use...@gmail.com> wrote:

> Hello,
>
> Maybe you could use ImageMagick to show one page of the pdf as an image ?
> This is what I have implemented on my project : first page of pdf files can
> be pre-viewed before user uploads the whole file (if needed). In your case,
> pre-viewing could be parametrized to show page ‘n’ of the pdf file,
> probably. In my project, pre-viewing image is generated when pdf file is
> uploaded and saved by admin in myproject/media/files directory. Once pdf
> files are in media directory, users can preview those pdf files and tnen
> upload them, if needed (only first page can be pre-viewed by user. This is
> an implementation choice).
>
>
> http://www.imagemagick.org/script/index.php
>
>
> 
>
> Implementation principles/credit can be found here :
>
> http://www.yaconiello.com/blog/auto-generating-pdf-covers/
>
>
> 
>
> I am attaching the signals file_post_save file_pre_save, for information.
>
>
> Cheers.
>
> Django 1.8
> Python 3.4
>
>
> Note : to install ImageMagick:
>
> sudo apt-get install libmagickwand-dev imagemagick libmagickcore-dev
>
> The convert command allows to convert any page of pdf file into png image
> (for instance), eg :
>
> convert -thumbnail 1280 test.pdf[0] test_1280.png
> Several parameters exist to tune image quality (in my case, need to use
> density, trim and quality).
>
>
>
> *models.p**y*
>
> […]
>
> ###
>
> # SIGNALS #
>
> ###
>
> from django.db.models.signals import post_save, pre_delete
>
> from django.dispatch import receiver
>
> from myproject.settings import MEDIA_ROOT
>
> import subprocess
>
>
> # What to do after a File is saved - receiver definition
>
> def file_post_save(sender, instance=False, **kwargs):
>
> # This post save function creates a thumbnail for the File
>
> file = File.objects.get(pk=instance.pk)
>
> command = "convert -density 300 -trim -thumbnail %s %s%s[0]
> -quality 100 %s%s" % (file.thumbnail_size, MEDIA_ROOT, file.file,
> MEDIA_ROOT, file.thumbnail)
>
> proc = subprocess.Popen(command,
>
> shell=True,
>
> stdin=subprocess.PIPE,
>
> stdout=subprocess.PIPE,
>
> stderr=subprocess.PIPE,
>
> )
>
> stdout_value = proc.communicate()[0]
>
> post_save.connect(file_post_save, sender=File,
> dispatch_uid="file_post_save_uid")
>
>
>
> # What to do before a File is deleted - receiver definition
>
> def file_pre_delete(sender, instance=False, **kwargs):
>
> # This pre delete function deletes file and thumbnail from
> media directory
>
> file = File.objects.get(pk=instance.pk)
>
> command = "rm %s%s %s%s" % (MEDIA_ROOT, file.file,
> MEDIA_ROOT, file.thumbnail)
>
> proc = subprocess.Popen(command,
>
> shell=True,
>
> stdin=subprocess.PIPE,
>
> stdout=subprocess.PIPE,
>
> stderr=subprocess.PIPE,
>
> )
>
> stdout_value = proc.communicate()[0]
>
> pre_delete.connect(file_pre_delete, sender=File,
> dispatch_uid="file_pre_delete_uid")
>
> --
> 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/e409aafa-3133-47b1-b465-7d74501d0cac%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/CAFWa6tLODtEQ_5Tde-Axe3khKKzDCa58%3D-u3%2Bnk7vx3F6uQ

how to design URL pattern to get the field value using request.query_params.get in the view

2016-09-04 Thread Afiz S
Hi All, 

I have very new to Django. Can anyone tell me how to the data from URL to 
view.

in this below example I am trying to get year param from the URL. 

def get_queryset(self):
queryset = Battles.objects.all()
year = self.request.query_params.get('year',None)
if year is not None:
queryset = queryset.filter(year__exact=year)
return queryset

-- 
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/693bbae5-0ffc-4737-86be-a9cee202e68e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Let a User add a Video not a image as a post?

2016-09-04 Thread Sylvain GROS-DESORMEAUX
Hi, have you even tried to search using google?

https://pypi.python.org/pypi/django-embed-video

https://djangopackages.org/grids/g/video/

https://github.com/jazzband/django-embed-video

You're welcome.

2016-09-01 10:53 GMT-04:00 djangorobert :

> I have researched this issue with django for years now and seems that no
> body in the django community knows how to do this which is a suprise
> because there are many smart people but not one has been able to solve this
> mystery?
>
>
> What i'm aiming for is to let a user upload a vido format
>
> and then in the template display there posts
>
> does anyone know how to put it in html5 but along with django in the
> view.py ?
>
>
> thanks any help or code 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+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/e5004b13-722d-4565-8c7f-dcc9297a9c6c%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/CAOSN4BUEECydRg3ohFE1NnRpM%3D5wLZv-wQL-i6AjW%2BhrpWtPgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NIST’s new password rules - Digital Authentication Guidelines

2016-09-04 Thread Uri Even-Chen
Thank you, Tim. Although we are using Django 1.9 and I understand that
passwords are hashed and salted, it's interesting to know which version of
Django was the first one to hash and salt passwords? I didn't find it
documented there.

Thanks,
Uri.


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    

On Fri, Sep 2, 2016 at 3:35 PM, Tim Graham  wrote:

> Hi,
>
> We have fairly comprehensive documentation about passwords: https://docs.
> djangoproject.com/en/stable/topics/auth/passwords/
>
> Let us know if you have unanswered questions after reading that.
>
> Tim
>
> On Friday, September 2, 2016 at 7:35:03 AM UTC-4, uri wrote:
>>
>> To Django users,
>>
>> Did you see this article: https://nakedsecurity
>> .sophos.com/2016/08/18/nists-new-password-rules-what-you-need-to-know/
>>
>> Does Django comply with the password guidelines and from which Django
>> version? Especially regarding the way the passwords are saved. I'm
>> developing Speedy Net in Django and I want to make sure I can rely on
>> Django in the way my users' passwords are saved in our database. I also
>> increased the minimal password length to 8 characters, and removed the
>> requirement for passwords to be alphanumeric.
>>
>> Thanks,
>> Uri.
>>
>> *Uri Even-Chen*
>> [image: photo] Phone: +972-54-3995700
>> Email: u...@speedy.net
>> Website: http://www.speedysoftware.com/uri/en/
>> 
>> 
>> 
>> 
>>
> --
> 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/dc7489bb-c0d4-49ff-b371-d4958b4bc2ed%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/CAMQ2MsHRkV9B67vMT2hqeoQqPc0drUt14dUJU3D%2Bp8oDM2e5RQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.