Re: Django - Populating more than one model from the same form ?

2016-07-09 Thread Paul
thanks, outside not in admin, I will check the links provided

On Saturday, July 9, 2016 at 10:52:38 PM UTC+3, ludovic coues wrote:
>
> If you are trying to do it outside of the admin, the previous link 
> might not be exactly what you are look for. The doc on inlines formset 
> [1] might be more usefull. It's the same thing, but as a generic form 
> instead of a part of the admin. 
>
>
> [1] 
> https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#inline-formsets
>  
>
> 2016-07-09 21:47 GMT+02:00 ludovic coues : 
>
> > Have you done the django tutorial ? 
> > 
> > Part 7 [1] Should answer your question. 
> > 
> > [1] https://docs.djangoproject.com/en/1.9/intro/tutorial07/ 
> > 
> > 2016-07-09 18:03 GMT+02:00  : 
> >> I have a 2 Models, Product and Image. Image has a foreign key to 
> Product. 
> >> 
> >> In the form I want to appear information from both the Product and the 
> >> Image, because are related. 
> >> 
> >> I use also GCBV for views, and model for forms. 
> >> 
> >> How can be done ? 
> >> 
> >> -- 
> >> 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/b4e9613b-e7b0-4a21-adb2-d3a3d468aa1f%40googlegroups.com.
>  
>
> >> For more options, visit https://groups.google.com/d/optout. 
> > 
> > 
> > 
> > -- 
> > 
> > Cordialement, Coues Ludovic 
> > +336 148 743 42 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
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/3199cfc6-7f6c-4f69-ac49-d26496694f7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateSyntaxError at /

2016-07-09 Thread Malik Rumi
God damn. That was it - something silly and obvious, but only to a fresh
set of eyes. Thank you!

On Sat, Jul 9, 2016 at 6:44 PM, James Schneider 
wrote:

>
> On Jul 9, 2016 6:38 PM, "Malik Rumi"  wrote:
> >
> >
> > Invalid template name in 'extends' tag: ''. Got this from the
> 'baseX.html' variable.
> >
> > The first line in index.html is:
> > {% extends baseX.html %}
> >
>
> Try adding quotes around "baseX.html", your referring to it as a variable,
> not as the name of the template.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Wm5gJTbSD8Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXZHCechLYWnP8ewkr9H%3D0asJne7KRMQjH1OsvXyYUgPQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

"Every time you see a black kid wearing a hoodie, you say: There's a thug.
If you see a white kid wearing hoodie, you say: There's Mark Zuckerberg,"
Jones told USA TODAY

last
year.

"I said, 'That's because of racism. And Prince said, 'Maybe so, *or maybe
you civil rights guys haven't created enough Mark Zuckerbergs.' "*

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


Re: TemplateSyntaxError at /

2016-07-09 Thread James Schneider
On Jul 9, 2016 6:38 PM, "Malik Rumi"  wrote:
>
>
> Invalid template name in 'extends' tag: ''. Got this from the
'baseX.html' variable.
>
> The first line in index.html is:
> {% extends baseX.html %}
>

Try adding quotes around "baseX.html", your referring to it as a variable,
not as the name of the template.

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


Django Tutor / Teacher

2016-07-09 Thread Malik Rumi
Where can I find a well qualified Django expert to work with me one on one 
on my site? I'm willing to pay, of course. I looked at Codementor, but once 
I picked several people, I got this "so and so has not been responding 
recently,...". I'd rather have someone in my time zone (California) and 
with good English skills. 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/ae8abc78-3244-45c5-a6e4-d50dfcbffe15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TemplateSyntaxError at /

2016-07-09 Thread Malik Rumi

Invalid template name in 'extends' tag: ''. Got this from the 'baseX.html' 
variable.

The first line in index.html is: 
{% extends baseX.html %}



I got this error when trying out a new template package I bought. I thought 
it was telling me something was wrong with the name of the base template 
being extended, but changing the name numerous times always brings the same 
error. 

I tried using a functional view instead, but I still got the same error. 

Debug Toolbar says:

Templates
>
> index.html
> /home/malikarumi/Projects/cannon/jamf/static/index.html
> ▶ Toggle context
> None
> 
>

That's when I figured out that the error was with baseX itself. The 
traceback points to line 141 in loader_tags.py, which is the get_parent 
function:


def get_parent(self, context):
parent = self.parent_name.resolve(context)
if not parent:
error_msg = "Invalid template name in 'extends' tag: %r." % 
parent
if self.parent_name.filters or\
isinstance(self.parent_name.var, Variable):
error_msg += " Got this from the '%s' variable." %\
self.parent_name.token
raise TemplateSyntaxError(error_msg)
if isinstance(parent, Template):
# parent is a django.template.Template
return parent
if isinstance(getattr(parent, 'template', None), Template):
# parent is a django.template.backends.django.Template
return parent.template
return self.find_template(parent, context)



Both baseX and index are in the same folder. Somehow Django has decided my 
baseX is not a django.template.django.Template. I don't know what makes a 
template qualify as a django.Template, and wasn't able to find anything on 
that. baseX is a pre-made template I liked and bought online. The designer 
doesn't know anything about Django. As far as I can tell, it is just html, 
css, and javascript, like any other template. It is bootstrap, just like 
the template I was using before. I have searched around, there's lots of 
stuff about templates in general, but I haven't found anything on this 
particular issue. 

I did come across django-bootstrap3, but I see no reason why that's 
required to use bootstrap. I didn't have it with the previous bootstrap 
theme I was using and that worked. 

Your insights appreciated.
ubuntu 15.10, Python 2.7.10, Django 1.9.1, Bootstrap 3.3.6

-- 
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/6c528bab-c13e-4a37-8fab-eb6bfd11c263%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - Populating more than one model from the same form ?

2016-07-09 Thread ludovic coues
If you are trying to do it outside of the admin, the previous link
might not be exactly what you are look for. The doc on inlines formset
[1] might be more usefull. It's the same thing, but as a generic form
instead of a part of the admin.


[1] 
https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#inline-formsets

2016-07-09 21:47 GMT+02:00 ludovic coues :
> Have you done the django tutorial ?
>
> Part 7 [1] Should answer your question.
>
> [1] https://docs.djangoproject.com/en/1.9/intro/tutorial07/
>
> 2016-07-09 18:03 GMT+02:00  :
>> I have a 2 Models, Product and Image. Image has a foreign key to Product.
>>
>> In the form I want to appear information from both the Product and the
>> Image, because are related.
>>
>> I use also GCBV for views, and model for forms.
>>
>> How can be done ?
>>
>> --
>> 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/b4e9613b-e7b0-4a21-adb2-d3a3d468aa1f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Re: Django - Populating more than one model from the same form ?

2016-07-09 Thread ludovic coues
Have you done the django tutorial ?

Part 7 [1] Should answer your question.

[1] https://docs.djangoproject.com/en/1.9/intro/tutorial07/

2016-07-09 18:03 GMT+02:00  :
> I have a 2 Models, Product and Image. Image has a foreign key to Product.
>
> In the form I want to appear information from both the Product and the
> Image, because are related.
>
> I use also GCBV for views, and model for forms.
>
> How can be done ?
>
> --
> 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/b4e9613b-e7b0-4a21-adb2-d3a3d468aa1f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Re: no django reverse match

2016-07-09 Thread ludovic coues
After reading your message, I don't know what the app should do, and
what happen currently.
I don't know if there is an error or not. Some part are missing like
the imports, app_name in urls.py or the url for message_board:list.


As a sidenote, I will suggest you to look the authentication views [1]
and the generic forms view [2]. These should make your life easier :)

[1] 
https://docs.djangoproject.com/en/1.9/topics/auth/default/#all-authentication-views
[2] 
https://docs.djangoproject.com/en/1.9/topics/class-based-views/generic-editing/#model-forms

2016-07-09 13:52 GMT+02:00  :
> this is my  login view ...
>
>
> def login(request):
> # c = {}
> # c.update(csrf(request))
> return render(request, 'envato.rathemes.com/infinity/topbar/login.html')
>
>
> def auth_view(request):
> username = request.POST.get('username', '')
> password = request.POST.get('password', '')
> user = auth.authenticate(username=username, password=password)
> if user is not None:
> auth.login(request, user)
> return redirect('message_board:list')
> else:
> return HttpResponse('notauthenticateplease login with correct
> detail', status=403)
>
>
> Im trying to go on new app and the urls for new app is this --
>
>
> urlpatterns = [
> url(r'^message_board/$', views.message, name='message'),
> url(r'^message_board/post_new$', views.post_new, name='post_new'),
> #url(r'^message_board/post_detail$', views.post_detail,
> name='post_detail')
> url(r'^message_board/post_detail/(?P\d+)/$', views.post_detail,
> name='post_detail'),
> ]
>
>
> and message board view is this -
>
>
>
> def message(request):
> posts = Post.objects.order_by('-created_date')
> return render(request, 'post_list.html', {'xyz': posts})
>
>
> @login_required
> def post_new(request):
> if request.method == "POST":
> form = PostForm(request.POST)
> if form.is_valid():
> post = form.save(commit=False)
> post.author = request.user
> post.published_date = timezone.now()
> post.save()
> return redirect('message_board:list')
> else:
> form = PostForm()
> return render(request, 'post_edit.html', {'form': form})
>
>
>
>
>
> please help me please..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/832b97b8-0d25-4718-86ee-7ae87599f163%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Change link on img in template using forms

2016-07-09 Thread Dariusz Mysior
How in template.html change link  on . 

Zdjecie: Teraz: avatar/n.jpg

In forms.py like below I see that I can change label name, but how can I do 
this with  ???

class MysiteUserForm(forms.ModelForm):
#age  = 
forms.IntegerField(min_value=1, max_value=99, 
widget=forms.NumberInput(attrs={}))
#avatar  = 
forms.ImageField()
class Meta:
model = MysiteUser
fields = ['sex','age','province','city','martial_status','religion',
'kids','education',
  'are_smoke','are_drink','avatar']
labels = {
'avatar': _('Zdjecie'),
}


-- 
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/7674fe46-895a-4991-ac8e-47c0210220e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible Bug in RegexURLResolver

2016-07-09 Thread Markus Holtermann

Hey,

I did indeed not consider the multi-threading behavior on uwsgi when
writing that. Can you post this to django-develop...@googlegroups.com
and open a ticket for that. I'd love to get someone else's input.

Thanks

/Markus

On Sat, Jul 09, 2016 at 08:36:44AM -0700, a.bra...@rataran.com wrote:

Hello everyone.

I'm using django (1, 10, 0, u'beta', 1).

When I try to reverse url in shell everything goes fine.

When under nginx/uwsgi with many concurrent request I get

... /local/lib/python2.7/site-packages/django/urls/resolvers.py", line 241,
in reverse_dict
   return self._reverse_dict[language_code]
KeyError: 'it'

After a wile I figured out that RegexURLResolver is memoized by
get_resolver and so it acts like a singleton for a certain number of
requests.

Analyzing the code of  RegexURLResolver I found that the method _poupulate
will return directly if it has been called before and not yet finished.

   ...
   def _populate(self):
   if self._populating:
   return
   self._populating = True
   ...

if used for recursive call in a single thread this will not hurt, but in my
case in uwsgi multi thread mode I got the error.

here is my quick and dirty fix:

class RegexURLResolver(LocaleRegexProvider):
   def __init__(self, regex, urlconf_name, default_kwargs=None,
app_name=None, namespace=None):

   ...

   self._populating = False
   self.RLock = threading.RLock()

   ...

  def _populate(self):
   if self._populating:
   self.RLock.acquire()
   self.RLock.release()
   return
   self._populating = True
   self.RLock.acquire()

   ...

   self._populating = False
   self.RLock.release()


Does anyone know if there is a better solution?

Tank You


--
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/147ab225-7ec9-4bf3-a5e1-61a945154c29%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/20160709162551.GC11144%40inel.local.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


Re: Django Admin - customize use jquery inside and custom fields.

2016-07-09 Thread sevenrrainbow
Thanks.

On Friday, July 8, 2016 at 7:59:23 PM UTC+3, luisza14 wrote:
>
> See https://docs.djangoproject.com/en/1.9/topics/forms/media/
>
> 2016-07-08 10:58 GMT-06:00 Luis Zárate :
>
>>
>> 2016-07-08 10:24 GMT-06:00 :
>>
>>> and save the new im
>>
>>
>> You can start reading how to set css and js to form and admin site.
>>
>> See
>>
>>
>>
>> -- 
>> "La utopía sirve para caminar" Fernando Birri
>>
>>
>>
>
>
> -- 
> "La utopía sirve para caminar" Fernando Birri
>
>
>

-- 
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/cadf16cb-6063-49f6-ac4d-66d83e888cde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - File or Image Delete

2016-07-09 Thread sevenrrainbow
This way the Image is removed from database, not from the server.

On Friday, July 8, 2016 at 6:41:57 PM UTC+3, Mstislav Kazakov wrote:
>
> Just pass empty value in file field.
> If blank=True and null=True, everything should work fine and image will be 
> removed.
>
> пятница, 8 июля 2016 г., 17:23:42 UTC+5 пользователь sevenr...@gmail.com 
> написал:
>>
>> The user has the possibility to add/delete image and documents.
>>
>>
>> I used GCBV UpdateView and a FormModel for this. 
>>
>>
>> How can I offer the possibility to the user to delete the file/image ?
>>
>

-- 
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/bdd2edd2-d232-416e-9ff4-b5b3519e6c1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django - Populating more than one model from the same form ?

2016-07-09 Thread sevenrrainbow
I have a 2 Models, Product and Image. Image has a foreign key to Product.

In the form I want to appear information from both the Product and the 
Image, because are related.

I use also GCBV for views, and model for forms.

How can be done ?

-- 
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/b4e9613b-e7b0-4a21-adb2-d3a3d468aa1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Username in password_reset_email

2016-07-09 Thread jorrit787
I want to include a reminder of a user's username in the password reset 
email, but I can't seem to include the username variable in the context. 
I'm trying to include it via the extra_email_context parameter in the URL 
pattern, but that doesn't work:

url(r'^password_reset/$', django_auth_views.password_reset, {'template_name': 
'common/password_reset_form.html',
 
'email_template_name':
 
'common/password_reset_email.html',
 
'extra_email_context': {'username': user.username},
 
'post_reset_redirect': 'common:password_reset_done'},
 
name='password_reset'),


Is there any other way to make this work?

-- 
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/e014d2aa-6ec6-481d-8c97-033787d1983d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Possible Bug in RegexURLResolver

2016-07-09 Thread a . branco
Hello everyone.

I'm using django (1, 10, 0, u'beta', 1).

When I try to reverse url in shell everything goes fine.

When under nginx/uwsgi with many concurrent request I get 

... /local/lib/python2.7/site-packages/django/urls/resolvers.py", line 241, 
in reverse_dict
return self._reverse_dict[language_code]
KeyError: 'it'

After a wile I figured out that RegexURLResolver is memoized by 
get_resolver and so it acts like a singleton for a certain number of 
requests.

Analyzing the code of  RegexURLResolver I found that the method _poupulate 
will return directly if it has been called before and not yet finished.

...
def _populate(self):
if self._populating:
return
self._populating = True
...  

if used for recursive call in a single thread this will not hurt, but in my 
case in uwsgi multi thread mode I got the error.

here is my quick and dirty fix:

class RegexURLResolver(LocaleRegexProvider):
def __init__(self, regex, urlconf_name, default_kwargs=None, 
app_name=None, namespace=None):

...

self._populating = False
self.RLock = threading.RLock()

...

   def _populate(self):
if self._populating:
self.RLock.acquire()
self.RLock.release()
return
self._populating = True
self.RLock.acquire()

...

self._populating = False
self.RLock.release()


Does anyone know if there is a better solution?

Tank You


-- 
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/147ab225-7ec9-4bf3-a5e1-61a945154c29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST header in shared server

2016-07-09 Thread James Schneider
On Jun 27, 2016 6:59 PM, "Luis Zárate"  wrote:
>
> Hi,
>
> I am having some issue with gunicorn/nginx configuration. I have a shared
server that support several sites (all based in Django)  with the same ip
address.
>
> Invalid HTTP_HOST header: 'www.mysite.com'. You may need to add '
www.mysite.com' to ALLOWED_HOSTS.
>

This would indicate that you are reaching at least one of your Django
instances. It's likely that Nginx does not have a matching virtual host
(VH) configuration and is using one of your available sites as the fallback
default.

> I checked and all projects have ALLOWED_HOSTS well configured, so I read
with attention the exception and notice that all exception are send by the
same gunicon socket
> 'gunicorn.socket': /gunicorn.sock>.
>
> So, I think are a nginx bad configuration, but I don't know what is wrong.
>

Have you looked at the logs for Nginx? It should indicate which (VH) is
handling each request. If the wrong VH is matching, then it would explain
your error message.

If the right VH is matching, then you need to ensure that the VH is
pointing at the correct gunicorn instance. The gunicorn logs should also
indicate which instance is being called.

>
> I followed this tutorial
>
http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
>
> I use this attach file as script to create new projects in my server.
>

The install script doesn't help a while lot, since we'd have to read and
replace the variables in our heads. The  relevant portions of the config
files would be much more useful.

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


Re: NoReverseMatch at /accounts/accounts/auth/

2016-07-09 Thread ludovic coues
A full stacktrace and the content of urls.py would be nice.


2016-07-09 13:46 GMT+02:00  :
> I tried my best to solve this but i couldn't please help me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/27bcddf9-9ba2-4fab-bb18-ce9a81048ae9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


NoReverseMatch at /accounts/accounts/auth/

2016-07-09 Thread ashutosh13103496
I tried my best to solve this but i couldn't please help me 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/27bcddf9-9ba2-4fab-bb18-ce9a81048ae9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
from django.utils import timezone

from models import Post
from .forms import PostForm


@login_required
def message(request):
posts = Post.objects.order_by('-created_date')
return render(request, 'post_list.html', {'xyz': posts})


@login_required
def post_new(request):
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('message_board:list')
else:
form = PostForm()
return render(request, 'post_edit.html', {'form': form})


def post_detail(request, pk=None):
print request, pk
post = get_object_or_404(Post, pk=pk)
return render(request, 'post_detail.html', {'post': post})


no django reverse match

2016-07-09 Thread ashutosh13103496
this is my  login view ...


def login(request):
# c = {}
# c.update(csrf(request))
return render(request, 'envato.rathemes.com/infinity/topbar/login.html')


def auth_view(request):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return redirect('message_board:list')
else:
return HttpResponse('notauthenticateplease login with correct 
detail', status=403)


Im trying to go on new app and the urls for new app is this --


urlpatterns = [
url(r'^message_board/$', views.message, name='message'),
url(r'^message_board/post_new$', views.post_new, name='post_new'),
#url(r'^message_board/post_detail$', views.post_detail, name='post_detail')
url(r'^message_board/post_detail/(?P\d+)/$', views.post_detail, 
name='post_detail'),
]  


and message board view is this -



def message(request):
posts = Post.objects.order_by('-created_date')
return render(request, 'post_list.html', {'xyz': posts})


@login_required
def post_new(request):
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('message_board:list')
else:
form = PostForm()
return render(request, 'post_edit.html', {'form': form})





please help me please..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/832b97b8-0d25-4718-86ee-7ae87599f163%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how should i make a non downloadable image in my django website

2016-07-09 Thread Michal Petrucha
On Sat, Jul 09, 2016 at 12:24:25PM +0200, ludovic coues wrote:
> If the image is displayed, the user can use a screen capture tool to get it.
> 
> You can make it harder for your user to get the image by putting a
> transparent image on top of the displayed image. You can put the image
> as a background on a div. You can cut the image in many part and
> display a grid of these image without border so the user can only get
> a piece of the image at a time. You can also play with canvas or put a
> video of the image with a single frame.
> 
> You can also mix all these method.
> Be creative.
> Also, going further that way will give you less readable, harder to
> maintain code and poorer performance as your image need to be
> processed. There is also slight chance your user will hate you and you
> might have trouble to sleep at night.
> 
> If you choose to pursue that way, good luck and have fun :)
> And keep in mind that once you introduce enough difficulty, it will be
> easier to take a screen capture.
> https://xkcd.com/538/

Also keep in mind that as long as the browser is able to somehow
retrieve the image and display it in the page, it is by definition
downloadable (because that's how the browser gets it). So with most of
these approaches, the only thing an interested user would have to do
would be to open the developer tools in their browser, and look at the
log of HTTP requests.

-- 
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/20160709115150.GH22177%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: how should i make a non downloadable image in my django website

2016-07-09 Thread ludovic coues
If the image is displayed, the user can use a screen capture tool to get it.

You can make it harder for your user to get the image by putting a
transparent image on top of the displayed image. You can put the image
as a background on a div. You can cut the image in many part and
display a grid of these image without border so the user can only get
a piece of the image at a time. You can also play with canvas or put a
video of the image with a single frame.

You can also mix all these method.
Be creative.
Also, going further that way will give you less readable, harder to
maintain code and poorer performance as your image need to be
processed. There is also slight chance your user will hate you and you
might have trouble to sleep at night.

If you choose to pursue that way, good luck and have fun :)
And keep in mind that once you introduce enough difficulty, it will be
easier to take a screen capture.
https://xkcd.com/538/

2016-07-09 6:53 GMT+02:00 deepak manupati :
> how should i make a non downloadable image in my django website
>
> --
> 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/b22b97f8-626f-43a6-a4f8-1089b9a2c69b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


Re: Django TCP Socket Communication

2016-07-09 Thread Anil reddy reddy M
And I want use Celery with rabbitmq Broker in this process.

On Saturday, July 9, 2016 at 12:28:37 PM UTC+5:30, Anil reddy reddy M wrote:
>
> Hi,
> Yeah, I am ready
>
> On Thursday, June 16, 2016 at 5:12:52 PM UTC+5:30, Sergiy Khohlov wrote:
>>
>> Have ready  this kind of application  using  django + postgis. At this 
>> moment protocols Cabon and teltronika are supported. Are you interested ? 
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Thu, Jun 16, 2016 at 2:37 PM, Jani Tiainen  wrote:
>>
>>> Oops, apparently you hijacked over year old thread... 
>>>
>>> On 16.06.2016 13:45, Anil reddy reddy M wrote:
>>>
>>> Hi, 
>>>
>>>  I made a TCP Server Socket  programming in python, it's nicely 
>>> communicating with micro controller, and also i can store latitude 
>>> ,longitude values in MySqldb from GPS output. Now I want develop a web 
>>> application for vechile  tracking. How can i do this stuff in django.  I 
>>> would be thankful   for all  the help i can get! 
>>>
>>>
>>>
>>> Just make models to match tables and then use Django as you wish. There 
>>> isn't nothing magical there. 
>>>
>>> For starting point you can use inspectdb to create initial models from 
>>> your database which you then can refine to suit your needs.
>>>
>>>
>>>
>>>
>>> On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai 
>>> wrote: 

 Hello,

 it's a bit hard to understand what you exactly want to achieve. How can 
 you communicate with the microcontroller? Do you connect to one of its TCP 
 ports, and send it data, I assume. Is it done with a well-known protocol, 
 like HTTP, or some custom one?

 You say that it opens a port every 5 seconds to a server. Where is that 
 server? Is it on the same machine as you Django based application? How 
 does 
 the microcontroller and the server communicate with each other?

 There are so many architectural questions here before you get to a web 
 application, and I'm afraid you original question cannot be answered 
 before 
 we see the whole picture.

 Best,
 Gergely
 On 28 Mar 2015 11:06, "bobdxcool"  wrote:

> But is that compatible with django ?
>
> On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] 
> <[hidden 
> email] > wrote:
>
>> Have you looked at the ‘socket’ python library ? 
>>
>> François 
>>
>> > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email] 
>> > wrote: 
>> > 
>> > I am new to TCP socket programming. I have a django based server 
>> > communicating with a microcontroller. Now, I want to implement TCP 
>> based 
>> > socket on the server side in order to communicate with the TCP 
>> socket on the 
>> > microcontroller. Can anyone give me an idea on how to do this ? 
>> What 
>> > libraries should I use on my django server The microprocessor 
>> basically 
>> > opens the socket every 5 seconds and sends a notification to the 
>> server. I 
>> > on the server side should be able to read this and pump data back 
>> to the 
>> > microprocessor using this socket which was opened by the 
>> microprocessor. 
>> > 
>> > 
>> > 
>> > -- 
>> > View this message in context: 
>> 
>> http://python.6.x6.nabble.com/
>> Django-TCP-Socket-Communication-tp5090792.html
>> > Sent from the django-users mailing list archive at Nabble.com. 
>> > 
>> > -- 
>> > 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 [hidden email] 
>> . 
>> > To post to this group, send email to [hidden email] 
>> . 
>> > Visit this group at 
>> http://groups.google.com/group/django-users. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/1427483125637-5090792.post%40n6.nabble.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 [hidden email] 
>> . 
>> To post to this group, send email to [hidden email] 
>> . 
>> Visit 

Re: Django TCP Socket Communication

2016-07-09 Thread Anil reddy reddy M
Hi,
Yeah, I am ready

On Thursday, June 16, 2016 at 5:12:52 PM UTC+5:30, Sergiy Khohlov wrote:
>
> Have ready  this kind of application  using  django + postgis. At this 
> moment protocols Cabon and teltronika are supported. Are you interested ? 
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Thu, Jun 16, 2016 at 2:37 PM, Jani Tiainen  > wrote:
>
>> Oops, apparently you hijacked over year old thread... 
>>
>> On 16.06.2016 13:45, Anil reddy reddy M wrote:
>>
>> Hi, 
>>
>>  I made a TCP Server Socket  programming in python, it's nicely 
>> communicating with micro controller, and also i can store latitude 
>> ,longitude values in MySqldb from GPS output. Now I want develop a web 
>> application for vechile  tracking. How can i do this stuff in django.  I 
>> would be thankful   for all  the help i can get! 
>>
>>
>>
>> Just make models to match tables and then use Django as you wish. There 
>> isn't nothing magical there. 
>>
>> For starting point you can use inspectdb to create initial models from 
>> your database which you then can refine to suit your needs.
>>
>>
>>
>>
>> On Saturday, March 28, 2015 at 7:21:24 PM UTC+5:30, Gergely Polonkai 
>> wrote: 
>>>
>>> Hello,
>>>
>>> it's a bit hard to understand what you exactly want to achieve. How can 
>>> you communicate with the microcontroller? Do you connect to one of its TCP 
>>> ports, and send it data, I assume. Is it done with a well-known protocol, 
>>> like HTTP, or some custom one?
>>>
>>> You say that it opens a port every 5 seconds to a server. Where is that 
>>> server? Is it on the same machine as you Django based application? How does 
>>> the microcontroller and the server communicate with each other?
>>>
>>> There are so many architectural questions here before you get to a web 
>>> application, and I'm afraid you original question cannot be answered before 
>>> we see the whole picture.
>>>
>>> Best,
>>> Gergely
>>> On 28 Mar 2015 11:06, "bobdxcool"  wrote:
>>>
 But is that compatible with django ?

 On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] 
 <[hidden 
 email] > wrote:

> Have you looked at the ‘socket’ python library ? 
>
> François 
>
> > On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email] 
> > wrote: 
> > 
> > I am new to TCP socket programming. I have a django based server 
> > communicating with a microcontroller. Now, I want to implement TCP 
> based 
> > socket on the server side in order to communicate with the TCP 
> socket on the 
> > microcontroller. Can anyone give me an idea on how to do this ? What 
> > libraries should I use on my django server The microprocessor 
> basically 
> > opens the socket every 5 seconds and sends a notification to the 
> server. I 
> > on the server side should be able to read this and pump data back to 
> the 
> > microprocessor using this socket which was opened by the 
> microprocessor. 
> > 
> > 
> > 
> > -- 
> > View this message in context: 
> 
> http://python.6.x6.nabble.com/
> Django-TCP-Socket-Communication-tp5090792.html
> > Sent from the django-users mailing list archive at Nabble.com. 
> > 
> > -- 
> > 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 [hidden email] 
> . 
> > To post to this group, send email to [hidden email] 
> . 
> > Visit this group at 
> http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/1427483125637-5090792.post%40n6.nabble.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 [hidden email] 
> . 
> To post to this group, send email to [hidden email] 
> . 
> Visit this group at http://groups.google.com/group/django-users. 
> To view this discussion on the web visit 
> 
> https://groups.google.com/d/
>