Re: Input Widget with multiple input_type attr

2017-10-20 Thread mohammad k
forms.CharField(widget=forms.HiddenField)

On Oct 21, 2017 12:45 AM, "gugsrs"  wrote:

Hello,

I am having some problems with django 1.11 widgets, I was using
django-widget-tweaks to help rendering form fields,
but now when I set a type="hidden" attribute to an Input Field, django
creates the widget with both type="text" and type="hidden" attributes.
That happens because when the widget is initialized [1] it's input_type is
set from the attrs.
But when the widget is rendered and the method get_context is called, it
uses the old input_type attr, and not the new one that is sent[2] in attrs.

Is this some kind of bug or am I missing something?

Regards,

Gustavo

[1] https://github.com/django/django/blob/1.11.6/django/
forms/widgets.py#L271
[2] https://github.com/django/django/blob/1.11.6/django/
forms/widgets.py#L276

-- 
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/cac48b38-6709-4307-b097-33c3c1076594%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/CACOk0TxyT4p-n9%3D1b3d8nc40R3EHwpwfKiMfq4DxGORpBh6Syg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Insert data into multiple models

2017-10-23 Thread mohammad k
you can use model signals


On Mon, Oct 23, 2017 at 4:15 PM, Mukul Mantosh 
wrote:

> I have two models (User and Employee). I want to create a new user and
> make a reference between employee and user.
>
>
> *User Table*
> 1. Name
> 2. E-Mail
> 3. Date of Birth
> 4. Contact Number
>
>
> *Employee Table*
> 1. EmployeeID
> 2. Address
> 3. Country
> 4. Profile Photo
> 5. *user_id*
>
> *Problem Statement:  *When i create a new user then automatically it
> should create a new record in employee table with *user_id* referencing
> to the user table and without writing two SQL Statements and should also
> follow the database transaction property(ACID).
>
>
> --
> 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/124695ae-e1f1-4252-8bbb-272cb438243b%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/CACOk0TxA3cwExG_3V6gJix9RAJW8-CrJ_DpkCS8txfZS9SiC6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Insert data into multiple models

2017-10-23 Thread mohammad k
https://docs.djangoproject.com/en/1.11/topics/signals/


On Mon, Oct 23, 2017 at 8:22 PM, mohammad k  wrote:

> you can use model signals
>
>
> On Mon, Oct 23, 2017 at 4:15 PM, Mukul Mantosh 
> wrote:
>
>> I have two models (User and Employee). I want to create a new user and
>> make a reference between employee and user.
>>
>>
>> *User Table*
>> 1. Name
>> 2. E-Mail
>> 3. Date of Birth
>> 4. Contact Number
>>
>>
>> *Employee Table*
>> 1. EmployeeID
>> 2. Address
>> 3. Country
>> 4. Profile Photo
>> 5. *user_id*
>>
>> *Problem Statement:  *When i create a new user then automatically it
>> should create a new record in employee table with *user_id* referencing
>> to the user table and without writing two SQL Statements and should also
>> follow the database transaction property(ACID).
>>
>>
>> --
>> 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/ms
>> gid/django-users/124695ae-e1f1-4252-8bbb-272cb438243b%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/124695ae-e1f1-4252-8bbb-272cb438243b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CACOk0TzFTG128GL-3dxpKRkyS61F6e4euxgusm4MimXtJw_FEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Input Widget with multiple input_type attr

2017-10-24 Thread mohammad k
forms.TextInput(attrs={'type': 'hidden'})

On Tue, Oct 24, 2017 at 7:08 PM, gugsrs  wrote:

> But isn't there any other way to change that attribute from my template
> for example?
>
> Thank you for the reply.
>
> On Saturday, October 21, 2017 at 4:19:21 AM UTC-2, k2527806 wrote:
>>
>> forms.CharField(widget=forms.HiddenField)
>>
>> On Oct 21, 2017 12:45 AM, "gugsrs"  wrote:
>>
>> Hello,
>>
>> I am having some problems with django 1.11 widgets, I was using
>> django-widget-tweaks to help rendering form fields,
>> but now when I set a type="hidden" attribute to an Input Field, django
>> creates the widget with both type="text" and type="hidden" attributes.
>> That happens because when the widget is initialized [1] it's input_type
>> is set from the attrs.
>> But when the widget is rendered and the method get_context is called, it
>> uses the old input_type attr, and not the new one that is sent[2] in attrs.
>>
>> Is this some kind of bug or am I missing something?
>>
>> Regards,
>>
>> Gustavo
>>
>> [1] https://github.com/django/django/blob/1.11.6/django/form
>> s/widgets.py#L271
>> [2] https://github.com/django/django/blob/1.11.6/django/form
>> s/widgets.py#L276
>>
>> --
>> 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/cac48b38-6709-4307-b097-33c3c1076594%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/43a48b04-a2b1-46d6-a16e-6ce82a4393d0%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/CACOk0Twd1vT-WgL9Q7PZoqUdbXm-kC7VM4-bHgD7J494vMXTFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
try that in your views

form = Dog_Form(request.POST)
if form.is_valid():
form_save = form.save(commit=False)
form_save.user = request.user # user is logged in
form.save()


On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang  wrote:

> Let's say I have a model called 'Dogs'.  Users can create instances of
> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>
> 1. When User1 creates an instance of Dogs, how do I automatically assign
> that instance to User1?  I tried using a model field like this but it
> doesn't pick the user automatically:
>
> user = models.ForeignKey(User, unique=False)
>
> 2. After the instance has been created, how do I make the instance only
> editable and removable by the user who made it?  Basically, if User1
> creates an instance of Dogs, only User1 can edit and delete that instance.
>
> 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/dedbfe8b-1013-4844-b142-1e8615a1ef9a%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/CACOk0TxYqmKr-724S7PdgNgHZovJquj4JLMZUQpEdDpxgLOvBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
for question 2 :

def get_queryset(self):  # the user want to edit this post must be
owner this post
post_qs = super(UpdatePost, self).get_queryset()
return post_qs.filter(user=self.request.user)

On Tue, Oct 24, 2017 at 8:04 PM, mohammad k  wrote:

> try that in your views
>
> form = Dog_Form(request.POST)
> if form.is_valid():
> form_save = form.save(commit=False)
> form_save.user = request.user # user is logged in
> form.save()
>
>
> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang  wrote:
>
>> Let's say I have a model called 'Dogs'.  Users can create instances of
>> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>
>> 1. When User1 creates an instance of Dogs, how do I automatically assign
>> that instance to User1?  I tried using a model field like this but it
>> doesn't pick the user automatically:
>>
>> user = models.ForeignKey(User, unique=False)
>>
>> 2. After the instance has been created, how do I make the instance only
>> editable and removable by the user who made it?  Basically, if User1
>> creates an instance of Dogs, only User1 can edit and delete that instance.
>>
>> 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/ms
>> gid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CACOk0TwgM9u%3DcioPKzvzYVtAc21JqQV5W5zpcoL4N%2BkE7gTSrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
class Upload(FormView):
http_method_names = ['get', 'post']
template_name = 'public/upload.html'
success_url = reverse_lazy('upload')
form_class = UploadForms

def get(self, request, *args, **kwargs):
form = self.form_class(user=request.user)
return render(request, self.template_name, {'form': form})

def post(self, request, *args, **kwargs):
form = self.form_class(request.POST, request.FILES,
user=request.user)
if form.is_valid():
data = form.save(commit=False)
data.user = request.user
data.save()
messages.add_message(request, messages.SUCCESS,
self.success_message)
return redirect(self.success_url)
return render(request, self.template_name, {'form': form})

On Wed, Oct 25, 2017 at 3:22 AM, Jack Zhang  wrote:

> Thanks for your response.  This is an off-topic question but I can't
> figure out how to get 'request' working.  I'm using the CreateView generic
> class, so there's no space to insert 'request'.  This is what my code looks
> like.  When I try to run it, it tells me that request is not found.
>
> class ListingCreateView(LoginRequiredMixin, CreateView):
> model = BuyerListing
>
> form_class = PostListing(self.request.POST)
> if form.is_valid():
> form_save = form.save(commit=False)
> form_save.user = request.user # user is logged in
> form.save()
>
> def get_queryset(self):  # the user want to edit this post must be
> owner this post
> post_qs = super(PostListing, self).get_queryset()
> return post_qs.filter(user=self.request.user)
>
> On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>>
>> try that in your views
>>
>> form = Dog_Form(request.POST)
>> if form.is_valid():
>> form_save = form.save(commit=False)
>> form_save.user = request.user # user is logged in
>> form.save()
>>
>>
>> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang  wrote:
>>
>>> Let's say I have a model called 'Dogs'.  Users can create instances of
>>> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>>
>>> 1. When User1 creates an instance of Dogs, how do I automatically assign
>>> that instance to User1?  I tried using a model field like this but it
>>> doesn't pick the user automatically:
>>>
>>> user = models.ForeignKey(User, unique=False)
>>>
>>> 2. After the instance has been created, how do I make the instance only
>>> editable and removable by the user who made it?  Basically, if User1
>>> creates an instance of Dogs, only User1 can edit and delete that instance.
>>>
>>> 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...@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/dedbfe8b-1013-4844-b142-1e8615a1ef9a%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/950d853a-ade3-4d27-8e23-a47c6b70c80e%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/CACOk0TxLHOc_r_c_53650JR57NmKm%3DDDtAOt%2BayWr0k8V5rwKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
use FormView

https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-editing/#formview

On Wed, Oct 25, 2017 at 1:21 PM, mohammad k  wrote:

> class Upload(FormView):
> http_method_names = ['get', 'post']
> template_name = 'public/upload.html'
> success_url = reverse_lazy('upload')
> form_class = UploadForms
>
> def get(self, request, *args, **kwargs):
> form = self.form_class(user=request.user)
> return render(request, self.template_name, {'form': form})
>
> def post(self, request, *args, **kwargs):
> form = self.form_class(request.POST, request.FILES,
> user=request.user)
> if form.is_valid():
> data = form.save(commit=False)
> data.user = request.user
> data.save()
> messages.add_message(request, messages.SUCCESS,
> self.success_message)
> return redirect(self.success_url)
> return render(request, self.template_name, {'form': form})
>
> On Wed, Oct 25, 2017 at 3:22 AM, Jack Zhang  wrote:
>
>> Thanks for your response.  This is an off-topic question but I can't
>> figure out how to get 'request' working.  I'm using the CreateView generic
>> class, so there's no space to insert 'request'.  This is what my code looks
>> like.  When I try to run it, it tells me that request is not found.
>>
>> class ListingCreateView(LoginRequiredMixin, CreateView):
>> model = BuyerListing
>>
>> form_class = PostListing(self.request.POST)
>> if form.is_valid():
>> form_save = form.save(commit=False)
>> form_save.user = request.user # user is logged in
>> form.save()
>>
>> def get_queryset(self):  # the user want to edit this post must be
>> owner this post
>> post_qs = super(PostListing, self).get_queryset()
>> return post_qs.filter(user=self.request.user)
>>
>> On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>>>
>>> try that in your views
>>>
>>> form = Dog_Form(request.POST)
>>> if form.is_valid():
>>> form_save = form.save(commit=False)
>>> form_save.user = request.user # user is logged in
>>> form.save()
>>>
>>>
>>> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang  wrote:
>>>
>>>> Let's say I have a model called 'Dogs'.  Users can create instances of
>>>> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>>>
>>>> 1. When User1 creates an instance of Dogs, how do I automatically
>>>> assign that instance to User1?  I tried using a model field like this but
>>>> it doesn't pick the user automatically:
>>>>
>>>> user = models.ForeignKey(User, unique=False)
>>>>
>>>> 2. After the instance has been created, how do I make the instance only
>>>> editable and removable by the user who made it?  Basically, if User1
>>>> creates an instance of Dogs, only User1 can edit and delete that instance.
>>>>
>>>> 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...@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/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40goog
>>>> legroups.com
>>>> <https://groups.google.com/d/msgid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> 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/ms
>> gid/django-users/950d853a-ade3-4d27-8e23-a47c6b70c80e%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/950d853a-ade3-4d27-8e23-a47c6b70c80e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> 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/CACOk0TzRtASzQuPsHFWSmef%3D_P8bdb-H-Y_YEaG6vJfg0sBiKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
that your code :
class CreatePost(CreateView):
model = Post

def form_valid(self, form):
form.instance.user = self.request.user
return super(CreatePost, self).form_valid(form)

On Wed, Oct 25, 2017 at 1:22 PM, mohammad k  wrote:

> use FormView
>
> https://docs.djangoproject.com/en/1.11/ref/class-based-
> views/generic-editing/#formview
>
> On Wed, Oct 25, 2017 at 1:21 PM, mohammad k  wrote:
>
>> class Upload(FormView):
>> http_method_names = ['get', 'post']
>> template_name = 'public/upload.html'
>> success_url = reverse_lazy('upload')
>> form_class = UploadForms
>>
>> def get(self, request, *args, **kwargs):
>> form = self.form_class(user=request.user)
>> return render(request, self.template_name, {'form': form})
>>
>> def post(self, request, *args, **kwargs):
>> form = self.form_class(request.POST, request.FILES,
>> user=request.user)
>> if form.is_valid():
>> data = form.save(commit=False)
>> data.user = request.user
>> data.save()
>> messages.add_message(request, messages.SUCCESS,
>> self.success_message)
>> return redirect(self.success_url)
>> return render(request, self.template_name, {'form': form})
>>
>> On Wed, Oct 25, 2017 at 3:22 AM, Jack Zhang 
>> wrote:
>>
>>> Thanks for your response.  This is an off-topic question but I can't
>>> figure out how to get 'request' working.  I'm using the CreateView generic
>>> class, so there's no space to insert 'request'.  This is what my code looks
>>> like.  When I try to run it, it tells me that request is not found.
>>>
>>> class ListingCreateView(LoginRequiredMixin, CreateView):
>>> model = BuyerListing
>>>
>>> form_class = PostListing(self.request.POST)
>>> if form.is_valid():
>>> form_save = form.save(commit=False)
>>> form_save.user = request.user # user is logged in
>>> form.save()
>>>
>>> def get_queryset(self):  # the user want to edit this post must be
>>> owner this post
>>> post_qs = super(PostListing, self).get_queryset()
>>> return post_qs.filter(user=self.request.user)
>>>
>>> On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>>>>
>>>> try that in your views
>>>>
>>>> form = Dog_Form(request.POST)
>>>> if form.is_valid():
>>>> form_save = form.save(commit=False)
>>>> form_save.user = request.user # user is logged in
>>>> form.save()
>>>>
>>>>
>>>> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang  wrote:
>>>>
>>>>> Let's say I have a model called 'Dogs'.  Users can create instances of
>>>>> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>>>>
>>>>> 1. When User1 creates an instance of Dogs, how do I automatically
>>>>> assign that instance to User1?  I tried using a model field like this but
>>>>> it doesn't pick the user automatically:
>>>>>
>>>>> user = models.ForeignKey(User, unique=False)
>>>>>
>>>>> 2. After the instance has been created, how do I make the instance
>>>>> only editable and removable by the user who made it?  Basically, if User1
>>>>> creates an instance of Dogs, only User1 can edit and delete that instance.
>>>>>
>>>>> 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...@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/dedbfe8b-1013
>>>>> -4844-b142-1e8615a1ef9a%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread mohammad k
when you submited form, form_valid will called in CreateView and give you a
instance of user form submited (form parameter in form_valid function) and
you set user to logged user (self.request.user)

On Wed, Oct 25, 2017 at 7:25 PM, Jack  wrote:

> I tried using FormView but kept running into errors.  I used your second
> response and it worked!  I don't fully understand the code, but it seems to
> work flawlessly.
>
> Thank you so much! I own you a big one.
>
> On Wednesday, October 25, 2017 at 5:57:04 AM UTC-4, k2527806 wrote:
>>
>> that your code :
>> class CreatePost(CreateView):
>> model = Post
>>
>> def form_valid(self, form):
>> form.instance.user = self.request.user
>> return super(CreatePost, self).form_valid(form)
>>
>> On Wed, Oct 25, 2017 at 1:22 PM, mohammad k  wrote:
>>
>>> use FormView
>>>
>>> https://docs.djangoproject.com/en/1.11/ref/class-based-views
>>> /generic-editing/#formview
>>>
>>> On Wed, Oct 25, 2017 at 1:21 PM, mohammad k  wrote:
>>>
>>>> class Upload(FormView):
>>>> http_method_names = ['get', 'post']
>>>> template_name = 'public/upload.html'
>>>> success_url = reverse_lazy('upload')
>>>> form_class = UploadForms
>>>>
>>>> def get(self, request, *args, **kwargs):
>>>> form = self.form_class(user=request.user)
>>>> return render(request, self.template_name, {'form': form})
>>>>
>>>> def post(self, request, *args, **kwargs):
>>>> form = self.form_class(request.POST, request.FILES,
>>>> user=request.user)
>>>> if form.is_valid():
>>>> data = form.save(commit=False)
>>>> data.user = request.user
>>>> data.save()
>>>> messages.add_message(request, messages.SUCCESS,
>>>> self.success_message)
>>>> return redirect(self.success_url)
>>>> return render(request, self.template_name, {'form': form})
>>>>
>>>> On Wed, Oct 25, 2017 at 3:22 AM, Jack Zhang  wrote:
>>>>
>>>>> Thanks for your response.  This is an off-topic question but I can't
>>>>> figure out how to get 'request' working.  I'm using the CreateView generic
>>>>> class, so there's no space to insert 'request'.  This is what my code 
>>>>> looks
>>>>> like.  When I try to run it, it tells me that request is not found.
>>>>>
>>>>> class ListingCreateView(LoginRequiredMixin, CreateView):
>>>>> model = BuyerListing
>>>>>
>>>>> form_class = PostListing(self.request.POST)
>>>>> if form.is_valid():
>>>>> form_save = form.save(commit=False)
>>>>> form_save.user = request.user # user is logged in
>>>>> form.save()
>>>>>
>>>>> def get_queryset(self):  # the user want to edit this post must be
>>>>> owner this post
>>>>> post_qs = super(PostListing, self).get_queryset()
>>>>> return post_qs.filter(user=self.request.user)
>>>>>
>>>>> On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>>>>>>
>>>>>> try that in your views
>>>>>>
>>>>>> form = Dog_Form(request.POST)
>>>>>> if form.is_valid():
>>>>>> form_save = form.save(commit=False)
>>>>>> form_save.user = request.user # user is logged in
>>>>>> form.save()
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang 
>>>>>> wrote:
>>>>>>
>>>>>>> Let's say I have a model called 'Dogs'.  Users can create instances
>>>>>>> of Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>>>>>>
>>>>>>> 1. When User1 creates an instance of Dogs, how do I automatically
>>>>>>> assign that instance to User1?  I tried using a model field like this 
>>>>>>> but
>>>>>>> it doesn't pick the user automatically:
>>>>>>>
>>>>>>> user = models.ForeignKey(User, unique=False)
>>>&

Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
use this code for ManytoMany fields in django admin :

filter_horizontal = ('groups', 'user_permissions',)

On Fri, Nov 3, 2017 at 1:45 PM, Paul  wrote:

> I have a Product model, an Image Model and a Category Model.
>
> A Product can have multiple Images(Foreign Key) and a Product can be in
> multiple Categories a Category can contain multiple Products.
>
> A Category can have multiple subcategories(key to itself).
>
>
> class Category(MetaData):
>  parent = models.ForeignKey('self', blank=True, null=True, 
> verbose_name='parent
> category', on_delete=models.CASCADE)
>
> class ProductMetaData):
>   categories = models.ManyToManyField(Category)
>
> class ProductImage(models.Model):
>   product = models.ForeignKey(Product, related_name='image', on_delete=
> models.CASCADE)
>
>
>
> In Product Django Admin:
>
> class ProductDocumentInline(admin.TabularInline):
>  model = ProductDocument class ProductAdmin(MetaData):
>  inlines = [ProductImageInline]
>  fieldsets = (
>  ('Product Data', {
>  'fields': ('name', 'short_description', 'description')
>  }),
>  ('SEO', {
>  'classes': ('collapse',),
>  'fields': ('meta_title', 'meta_description', 'slug', 'canonical')
>  }),
>  ('MetaData', {
>  'classes': ('collapse',),
>  'fields': (('created_at', 'created_by'), ('updated_at', 'updated_by'))
>  }),
>  )
>  readonly_fields = ('created_at', 'updated_at', 'created_by', 'updated_by'
> )
>  list_display = ('name', 'updated_at')
>  ordering = ('-updated_at',)
>  search_fields = ('name',)
>
>
> admin.site.register(Product, ProductAdmin)
> admin.site.register(ProductImage)
>
>
>
> Issues:
>
>1.
>
>If I don't customize fieldsets (grouped, ordered) the Categories
>appear like default in the middle of the form. If there are customized as
>in my example they don't appear.
>2.
>
>If they don't appear Products without Categories can be created and I
>don't want that. I want a product to have at least one category.
>3.
>
>Now the inline Images appear below all Product fields.
>
> I want the Categories to appear first, then normal fields for
> Product(grouped,ordered), Images inline and at the end the SEO and metadata
> fields. How can this 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/37bf83ae-cdca-4c73-8ace-747386513e53%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/CACOk0Tz4qDf_jb%2BRN8VRZyc3gxWaXY%2By-tV%3DfpgQY4DHPE-f%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManytoMany field in Django admin not appearing

2017-11-05 Thread mohammad k
class UserAdminPanel(admin.ModelAdmin):
inlines = (UserPlaylist, UserVideos, UserComment, UserReplays, )
list_per_page = 20
fieldsets = (
(None, {'fields': ('username', )}),
(_('Personal info'), {'fields': ('first_name', 'last_name',
'email')}),
(_('Permissions'), {'fields': ('is_active', 'is_staff',
'is_superuser',
   'groups', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'password1', 'password2'),
}),
)
list_display = [
'username',
'email',
'last_name',
'user_reg',  # refer to Registration model
'is_staff',
]
list_filter = ('date_joined', 'is_staff', 'is_superuser', 'is_active',
'groups')
search_fields = [
'date_joined',
'email',
'first_name',
'last_name',
'username',
]
ordering = ['-date_joined', 'username']
filter_horizontal = ('groups', 'user_permissions',)

On Mon, Nov 6, 2017 at 12:32 AM, mohammad k  wrote:

> use this code for ManytoMany fields in django admin :
>
> filter_horizontal = ('groups', 'user_permissions',)
>
> On Fri, Nov 3, 2017 at 1:45 PM, Paul  wrote:
>
>> I have a Product model, an Image Model and a Category Model.
>>
>> A Product can have multiple Images(Foreign Key) and a Product can be in
>> multiple Categories a Category can contain multiple Products.
>>
>> A Category can have multiple subcategories(key to itself).
>>
>>
>> class Category(MetaData):
>>  parent = models.ForeignKey('self', blank=True, null=True, 
>> verbose_name='parent
>> category', on_delete=models.CASCADE)
>>
>> class ProductMetaData):
>>   categories = models.ManyToManyField(Category)
>>
>> class ProductImage(models.Model):
>>   product = models.ForeignKey(Product, related_name='image', on_delete=
>> models.CASCADE)
>>
>>
>>
>> In Product Django Admin:
>>
>> class ProductDocumentInline(admin.TabularInline):
>>  model = ProductDocument class ProductAdmin(MetaData):
>>  inlines = [ProductImageInline]
>>  fieldsets = (
>>  ('Product Data', {
>>  'fields': ('name', 'short_description', 'description')
>>  }),
>>  ('SEO', {
>>  'classes': ('collapse',),
>>  'fields': ('meta_title', 'meta_description', 'slug', 'canonical')
>>  }),
>>  ('MetaData', {
>>  'classes': ('collapse',),
>>  'fields': (('created_at', 'created_by'), ('updated_at', 'updated_by'))
>>  }),
>>  )
>>  readonly_fields = ('created_at', 'updated_at', 'created_by',
>> 'updated_by')
>>  list_display = ('name', 'updated_at')
>>  ordering = ('-updated_at',)
>>  search_fields = ('name',)
>>
>>
>> admin.site.register(Product, ProductAdmin)
>> admin.site.register(ProductImage)
>>
>>
>>
>> Issues:
>>
>>1.
>>
>>If I don't customize fieldsets (grouped, ordered) the Categories
>>appear like default in the middle of the form. If there are customized as
>>in my example they don't appear.
>>2.
>>
>>If they don't appear Products without Categories can be created and I
>>don't want that. I want a product to have at least one category.
>>3.
>>
>>Now the inline Images appear below all Product fields.
>>
>> I want the Categories to appear first, then normal fields for
>> Product(grouped,ordered), Images inline and at the end the SEO and metadata
>> fields. How can this 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/ms
>> gid/django-users/37bf83ae-cdca-4c73-8ace-747386513e53%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/37bf83ae-cdca-4c73-8ace-747386513e53%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CACOk0Ty8qYBHRiGY6VajbH5mh2o67gOw%3DwgJob0ktrx52-c8WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.11 run error

2017-11-22 Thread mohammad k
If you use virtualenv, first of all activate the virtualenv

On Nov 22, 2017 8:12 PM, "ngn zone"  wrote:

Hello all,

  I am new to Django. I am trying to run a project and when I run "python
manage.py makemigrations " I get the following error message.
What am I doing wrong?


python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 9, in 
dotenv.read_dotenv()
AttributeError: 'module' object has no attribute 'read_dotenv'

-- 
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/7b296ad6-ef80-4186-a82b-a49345448bee%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/CACOk0TzPjfdSNyhUGwZoX5Kp2JEoWSP3Ar%3Dgjpn%3DmsRsCYSMqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make my form send a POST request to a specified view?

2017-11-23 Thread mohammad k
login_register.html :

 
 {% csrf_token %}
 {{ registration_form.as_p }}
 Register
 


On Nov 24, 2017 1:42 AM, "Tom Tanner"  wrote:

> My page has a registration form at `"/login_register/"`. I want the form
> to send a POST request to `"/register/"`. Here's my code so far.
>
> `urls.py`:
> url("^login_register/$", views.login_register, name="login_register"),
> url("^register/$", views.register, name="register"),
>
>
> `views.py`:
> def login_register(request, template="pages/login_register.html"):
>  '''
>  Display registration and login forms
>  '''
>  registration_form= RegisterForm()
>  return render(request, template, {"registration_form": registration_form
> })
>
>
> def register(request):
>  '''
>  Process user registration
>  '''
>  if request.method=="POST":
># Some code here
>
>
> `pages/login_register.html`:
>  # For this example, I only include the registration form's HTML
>  Register
>  
>  {% csrf_token %}
>  {{ registration_form.as_p }}
>  Register
>  
>
>
> When I hit "Register" on the form, my browser sends a POST request to
> "login_register/". I want it to send a POST request to "register/". How do
> I do 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/72030063-8482-4723-9f2c-b25b17656a43%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/CACOk0TwKO_D4fZh6cW3gULXTfs%2BcDrU88SShiW1SA9c8NZHz%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I limit my login form to just email and password?

2017-11-26 Thread mohammad k
forms.py :

class LoginUserForm(forms.Form):
email = forms.CharField(
widget=forms.EmailInput(attrs={'autofocus': True, 'placeholder':
'Email'}),
required=True,
label='Email :',
max_length=255
)
password = forms.CharField(
widget=forms.PasswordInput(attrs={'placeholder': 'Password'}),
label=_('Password :'),
required=True,
max_length=50,
)

def clean(self, *args, **kwargs):
email = self.cleaned_data.get('email', None)
password = self.cleaned_data.get('password', None)
if email and password:
try:
loginuser = User.objects.get(email=email)
except ObjectDoesNotExist:
raise forms.ValidationError(_('Email or Password are
Wrong!'))
if not loginuser.is_active:
raise forms.ValidationError(_('This User Does not Active.'))
if not loginuser.check_password(password):
raise forms.ValidationError(_('Email or Password are
Wrong!'))
registration = Registration.objects.filter(user=loginuser,
is_registered=True)
if not registration.exists():
reg_email(
to_list=[loginuser.email],
subject='Email Registration for djangotutorial.ir',
code=signing.dumps({'id': loginuser.id}, salt=salt) +
'/?reg_code=' + signing.dumps({'username': loginuser.username, 'id':
loginuser.id, 'email': loginuser.email}, salt=salt)
)
raise forms.ValidationError(_('This Account is not
Registered!. Email has been sent. check your email'))
login(self.request, loginuser)
return super(LoginUserForm, self).clean()

def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
super(LoginUserForm, self).__init__(*args, **kwargs)


views.py :

class LoginUser(FormView):
"""Generate User Login Page By http://site_domain/login/ Based on
public/registration/login.html Template"""
template_name = 'public/registration/login.html'
form_class = LoginUserForm
success_url = reverse_lazy('home')

def get(self, request, *args, **kwargs):
"""When The Get Request Incoming."""
if request.user.is_authenticated:
return redirect(self.success_url)
return render(request, self.template_name, {'form':
self.form_class()})

def post(self, request, *args, **kwargs):
"""When The Post Request Incoming. User Submit Login Form."""
next_url = request.GET.get('next', None)
form = self.form_class(request.POST or None, request=request)
if form.is_valid():
if next_url:
return redirect(next_url)
return redirect(self.success_url)
return render(request, self.template_name, {'form': form})

On Sun, Nov 26, 2017 at 11:13 PM, Matemática A3K 
wrote:

>
>
> On Sun, Nov 26, 2017 at 12:55 AM, Tom Tanner <
> dontsendemailher...@gmail.com> wrote:
>
>> My `models.py` has this:
>> class MyUser(AbstractBaseUser):
>>  email= models.CharField(max_length=254, unique=True)
>>  USERNAME_FIELD= "email"
>>
>> My `forms.py` has this:
>> class LoginForm(AuthenticationForm):
>>  email= forms.EmailField(label=_("Email"), max_length=254)
>>
>>  class Meta:
>>   model= MyUser
>>   fields= ("email",)
>>
>> The form on the template has three fields: Username, Password and Email,
>> in that Order. I want only Email and Password to show up in the form. How
>> do I do that?
>>
> https://docs.djangoproject.com/en/1.11/topics/forms/
> modelforms/#selecting-the-fields-to-use
>
>> --
>> 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/ms
>> gid/django-users/4e9a3109-3dd0-4754-91f2-44731154920c%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%2BFDnhLt-rz93nqAhOYE_VgWPFCU2pCKjL7qZu2z0u9%3DkBxY-
> w%40mail.gmail.com
> 

Re: How to configure NGINX to run Django app in a subpath?

2017-11-26 Thread mohammad k
https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html

On Sun, Nov 26, 2017 at 11:26 PM, Luca Moiana  wrote:

> Hi,
>
> Sorry for the slight OT but after days of search I have no clue.
>
>
> Following this DigitalOcean tutorial
> 
>  I
> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my
> root,
>
> Now I'd like to change and have something like this:
>
> mydomain.com -> static HTML
> mydomain.com/pmapp -> Django app
>
> I created two server blocks in NGINX, one for my static website:
>
> server {
>
> listen 80;
>
> listen [::]:80;
>
>
>
> root /var/www/html/officinecartografiche.it;
>
> index index.html index.htm index.nginx-debian.html;
>
>
>
> server_name www.officinecartografiche.it, officinecartografiche.it
> , 207.154.206.172;
>
>
>
> location / {
>
> try_files $uri $uri/ =404;
>
>}
>
> }
>
>  and one for my django app:
>
> server {
>
> listen 80;
>
> listen [::]:80;
>
> server_name www.officinecartografiche.it, officinecartografiche.it,
> 207.154.206.172;
>
> location = /favicon.ico { access_log off; log_not_found off; }
>
> location /static/ {
>
> root /home/geouser/pmapp;
>
> }
>
>
>
> location /pmapp {
>
> #include proxy_params;
>
> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>
> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/
> http://$host/pmapp/;
>
> proxy_set_header SCRIPT_NAME /pmapp;
>
> }
>
> }
>
> and added this to settings.py:
>
> FORCE_SCRIPT_NAME = *'/pmapp'*
>
>
> WHAT AM I DOING WRONG??
>
> THANKS FOR YOUR HELP!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/b1ee39d2-fd04-4727-88e1-e130def5dd37%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/CACOk0TxFHYe4%2Boye79qfacv9%3Dc13CGVbjPgNYxhR2gU22KsFow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Translation

2017-08-30 Thread mohammad k
read django-translatin-manager docs

On Wed, Aug 30, 2017 at 11:50 AM,  wrote:

> Hi,
>
> I have a django application developed with static files from AngularJS. I
> need to translate the site to French and give option to users to select
> language. I have used django-translatin-manager for loading translation
> entries using admin panel. But I don't know how to setup active language
> for the django site. Please help me on this. 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/fb457e34-150f-4d7a-94c9-bc75f1a39426%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/CACOk0TxTM9HC5J1x8ik02e%2BaVnEAuJKDWe%2BE1_nkhJydn5YGvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
and in url.py beside settings.py use code like that :
url('^polls/',include('polls.urls')),

On Wed, Aug 30, 2017 at 4:29 PM, mohammad k  wrote:

> from django.conf.urls import url
> from . import views
>
> app_name = 'polls'
> urlpatterns = [
> url(r'^$', views.IndexView.as_view(), name='index'),
> url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
> url(r'^(?P[0-9]+)/results/$', views.ResultView.as_view(),
> name='results'),
> url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
> ]
>
> you have to create a url.py for each app in them folder
>
> On Wed, Aug 30, 2017 at 4:27 PM, mohammad k  wrote:
>
>> like that :
>> app_name = 'polls' in polls folder and in url.py
>>
>> On Wed, Aug 30, 2017 at 4:26 PM, mohammad k  wrote:
>>
>>> you have Different app in your project yes ?
>>> you have to use app_name in url.py in each app
>>>
>>> On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner 
>>> wrote:
>>>
>>>> This has bamboozled me some. And the best thing I've found on-line
>>>> doesn't seem to apply:
>>>>
>>>> https://stackoverflow.com/questions/26944908/django-url-mapp
>>>> ing-how-to-remove-app-name-from-url-paths
>>>>
>>>> Let me summarise.
>>>>
>>>> I have a site that I've been building and testing with djangos
>>>> development server of course. And it implements URLS like:
>>>>
>>>> http://127.0.0.1:8000/list/Model
>>>> http://127.0.0.1:8000/add/Model
>>>> http://127.0.0.1:8000/edit/Model/nn
>>>> http://127.0.0.1:8000/view/Model/nn
>>>> http://127.0.0.1:8000/delete/Model/nn
>>>>
>>>> Works like a dream, so I'm deploying, locally first, under lighttpd and
>>>> uwsgi. That is working fine too. Sort of,
>>>>
>>>> These are all reached with links in my templates like yo:
>>>>
>>>> {% url 'list' model %}
>>>> {% url 'add' model %}
>>>> {% url 'edit' model pk %}
>>>> {% url 'view' model pk %}
>>>> {% url 'delete' model pk %}
>>>>
>>>> because in urls.py they all have "name"s defined like that.
>>>>
>>>> All honky dory.
>>>>
>>>> Now after deploying everything works nicely, but those same links point
>>>> to:
>>>>
>>>> http://mysite.tld/app/list/Model
>>>> http://mysite.tld/app/add/Model
>>>> http://mysite.tld/app/edit/Model/nn
>>>> http://mysite.tld/app/view/Model/nn
>>>> http://mysite.tld/app/delete/Model/nn
>>>>
>>>> That is the app name is inserted. Odd. And undesired if not a crisis.
>>>>
>>>> But here's what bamboozles me. I can replace "app" in the url with any
>>>> string at all, "x" say and the site continues to work but those URLs now
>>>> point to :
>>>>
>>>> http://mysite.tld/x/list/Model
>>>> http://mysite.tld/x/add/Model
>>>> http://mysite.tld/x/edit/Model/nn
>>>> http://mysite.tld/x/view/Model/nn
>>>> http://mysite.tld/x/delete/Model/nn
>>>>
>>>> For what it's worth I don't want to quote urls.py and every other bit
>>>> of possible config here of course, I am mainly interested to know if
>>>> someone has insights that aren't shared in that SO link above as none of
>>>> what is shared there seems to apply.
>>>>
>>>> For anyone really keen on code explorations urls.py is here:
>>>>
>>>> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py
>>>>
>>>> and the whole site is there too.
>>>>
>>>> What I want to understand is why this "app" suddenly appears in my URLs
>>>> and how I can control it (remove it ideally). But I have looked at urls.py
>>>> long enough and scratched my head and not found it. settings.py is right
>>>> next to if you need to inspect it.
>>>>
>>>> Kind regards,
>>>>
>>>> Bernd.
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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/ms
>>>> gid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> 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/CACOk0Tz0HjZegO3Ea3vYKyfj1XZSfAndh0ABhNaLn1bOVNnHKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
like that :
app_name = 'polls' in polls folder and in url.py

On Wed, Aug 30, 2017 at 4:26 PM, mohammad k  wrote:

> you have Different app in your project yes ?
> you have to use app_name in url.py in each app
>
> On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner 
> wrote:
>
>> This has bamboozled me some. And the best thing I've found on-line
>> doesn't seem to apply:
>>
>> https://stackoverflow.com/questions/26944908/django-url-mapp
>> ing-how-to-remove-app-name-from-url-paths
>>
>> Let me summarise.
>>
>> I have a site that I've been building and testing with djangos
>> development server of course. And it implements URLS like:
>>
>> http://127.0.0.1:8000/list/Model
>> http://127.0.0.1:8000/add/Model
>> http://127.0.0.1:8000/edit/Model/nn
>> http://127.0.0.1:8000/view/Model/nn
>> http://127.0.0.1:8000/delete/Model/nn
>>
>> Works like a dream, so I'm deploying, locally first, under lighttpd and
>> uwsgi. That is working fine too. Sort of,
>>
>> These are all reached with links in my templates like yo:
>>
>> {% url 'list' model %}
>> {% url 'add' model %}
>> {% url 'edit' model pk %}
>> {% url 'view' model pk %}
>> {% url 'delete' model pk %}
>>
>> because in urls.py they all have "name"s defined like that.
>>
>> All honky dory.
>>
>> Now after deploying everything works nicely, but those same links point
>> to:
>>
>> http://mysite.tld/app/list/Model
>> http://mysite.tld/app/add/Model
>> http://mysite.tld/app/edit/Model/nn
>> http://mysite.tld/app/view/Model/nn
>> http://mysite.tld/app/delete/Model/nn
>>
>> That is the app name is inserted. Odd. And undesired if not a crisis.
>>
>> But here's what bamboozles me. I can replace "app" in the url with any
>> string at all, "x" say and the site continues to work but those URLs now
>> point to :
>>
>> http://mysite.tld/x/list/Model
>> http://mysite.tld/x/add/Model
>> http://mysite.tld/x/edit/Model/nn
>> http://mysite.tld/x/view/Model/nn
>> http://mysite.tld/x/delete/Model/nn
>>
>> For what it's worth I don't want to quote urls.py and every other bit of
>> possible config here of course, I am mainly interested to know if someone
>> has insights that aren't shared in that SO link above as none of what is
>> shared there seems to apply.
>>
>> For anyone really keen on code explorations urls.py is here:
>>
>> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py
>>
>> and the whole site is there too.
>>
>> What I want to understand is why this "app" suddenly appears in my URLs
>> and how I can control it (remove it ideally). But I have looked at urls.py
>> long enough and scratched my head and not found it. settings.py is right
>> next to if you need to inspect it.
>>
>> Kind regards,
>>
>> Bernd.
>>
>>
>>
>>
>> --
>> 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/ms
>> gid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CACOk0TxJLH8usGm%2B8sYCwcCp6A83T5ERZg5vXcYUpXJAPK2vZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
you have Different app in your project yes ?
you have to use app_name in url.py in each app

On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner 
wrote:

> This has bamboozled me some. And the best thing I've found on-line doesn't
> seem to apply:
>
> https://stackoverflow.com/questions/26944908/django-url-
> mapping-how-to-remove-app-name-from-url-paths
>
> Let me summarise.
>
> I have a site that I've been building and testing with djangos development
> server of course. And it implements URLS like:
>
> http://127.0.0.1:8000/list/Model
> http://127.0.0.1:8000/add/Model
> http://127.0.0.1:8000/edit/Model/nn
> http://127.0.0.1:8000/view/Model/nn
> http://127.0.0.1:8000/delete/Model/nn
>
> Works like a dream, so I'm deploying, locally first, under lighttpd and
> uwsgi. That is working fine too. Sort of,
>
> These are all reached with links in my templates like yo:
>
> {% url 'list' model %}
> {% url 'add' model %}
> {% url 'edit' model pk %}
> {% url 'view' model pk %}
> {% url 'delete' model pk %}
>
> because in urls.py they all have "name"s defined like that.
>
> All honky dory.
>
> Now after deploying everything works nicely, but those same links point to:
>
> http://mysite.tld/app/list/Model
> http://mysite.tld/app/add/Model
> http://mysite.tld/app/edit/Model/nn
> http://mysite.tld/app/view/Model/nn
> http://mysite.tld/app/delete/Model/nn
>
> That is the app name is inserted. Odd. And undesired if not a crisis.
>
> But here's what bamboozles me. I can replace "app" in the url with any
> string at all, "x" say and the site continues to work but those URLs now
> point to :
>
> http://mysite.tld/x/list/Model
> http://mysite.tld/x/add/Model
> http://mysite.tld/x/edit/Model/nn
> http://mysite.tld/x/view/Model/nn
> http://mysite.tld/x/delete/Model/nn
>
> For what it's worth I don't want to quote urls.py and every other bit of
> possible config here of course, I am mainly interested to know if someone
> has insights that aren't shared in that SO link above as none of what is
> shared there seems to apply.
>
> For anyone really keen on code explorations urls.py is here:
>
> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py
>
> and the whole site is there too.
>
> What I want to understand is why this "app" suddenly appears in my URLs
> and how I can control it (remove it ideally). But I have looked at urls.py
> long enough and scratched my head and not found it. settings.py is right
> next to if you need to inspect it.
>
> Kind regards,
>
> Bernd.
>
>
>
>
> --
> 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/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.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/CACOk0Tz1oBdnusZLeyHpcYSsVhSynKNOSsd%3DQdNoHuzQmkWdJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
i can't do that sorry man
Tell me more clearly, so I may help you better

On Wed, Aug 30, 2017 at 5:16 PM, Daniel Roseman 
wrote:

> On Wednesday, 30 August 2017 12:42:01 UTC+1, Bernd Wechner wrote:
>>
>> This has bamboozled me some. And the best thing I've found on-line
>> doesn't seem to apply:
>>
>> https://stackoverflow.com/questions/26944908/django-url-mapp
>> ing-how-to-remove-app-name-from-url-paths
>>
>> Let me summarise.
>>
>> I have a site that I've been building and testing with djangos
>> development server of course. And it implements URLS like:
>>
>> http://127.0.0.1:8000/list/Model
>> http://127.0.0.1:8000/add/Model
>> http://127.0.0.1:8000/edit/Model/nn
>> http://127.0.0.1:8000/view/Model/nn
>> http://127.0.0.1:8000/delete/Model/nn
>>
>> Works like a dream, so I'm deploying, locally first, under lighttpd and
>> uwsgi. That is working fine too. Sort of,
>>
>> These are all reached with links in my templates like yo:
>>
>> {% url 'list' model %}
>> {% url 'add' model %}
>> {% url 'edit' model pk %}
>> {% url 'view' model pk %}
>> {% url 'delete' model pk %}
>>
>> because in urls.py they all have "name"s defined like that.
>>
>> All honky dory.
>>
>> Now after deploying everything works nicely, but those same links point
>> to:
>>
>> http://mysite.tld/app/list/Model
>> http://mysite.tld/app/add/Model
>> http://mysite.tld/app/edit/Model/nn
>> http://mysite.tld/app/view/Model/nn
>> http://mysite.tld/app/delete/Model/nn
>>
>> That is the app name is inserted. Odd. And undesired if not a crisis.
>>
>> But here's what bamboozles me. I can replace "app" in the url with any
>> string at all, "x" say and the site continues to work but those URLs now
>> point to :
>>
>> http://mysite.tld/x/list/Model
>> http://mysite.tld/x/add/Model
>> http://mysite.tld/x/edit/Model/nn
>> http://mysite.tld/x/view/Model/nn
>> http://mysite.tld/x/delete/Model/nn
>>
>> For what it's worth I don't want to quote urls.py and every other bit of
>> possible config here of course, I am mainly interested to know if someone
>> has insights that aren't shared in that SO link above as none of what is
>> shared there seems to apply.
>>
>> For anyone really keen on code explorations urls.py is here:
>>
>> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py
>>
>> and the whole site is there too.
>>
>> What I want to understand is why this "app" suddenly appears in my URLs
>> and how I can control it (remove it ideally). But I have looked at urls.py
>> long enough and scratched my head and not found it. settings.py is right
>> next to if you need to inspect it.
>>
>> Kind regards,
>>
>> Bernd.
>>
>
>
> How have you deployed this project? Can you show your deployment
> configuration?
> --
> DR.
>
> --
> 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/8142e4c2-8a1b-4e6a-8bea-7f39416b1e61%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/CACOk0TxrZWgNHyNENuA_V7Antg%2BbdTVCcv5mgywuu3KmHqGbxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-30 Thread mohammad k
from django.conf.urls import url
from . import views

app_name = 'polls'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
url(r'^(?P[0-9]+)/results/$', views.ResultView.as_view(),
name='results'),
url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
]

you have to create a url.py for each app in them folder

On Wed, Aug 30, 2017 at 4:27 PM, mohammad k  wrote:

> like that :
> app_name = 'polls' in polls folder and in url.py
>
> On Wed, Aug 30, 2017 at 4:26 PM, mohammad k  wrote:
>
>> you have Different app in your project yes ?
>> you have to use app_name in url.py in each app
>>
>> On Wed, Aug 30, 2017 at 4:11 PM, Bernd Wechner 
>> wrote:
>>
>>> This has bamboozled me some. And the best thing I've found on-line
>>> doesn't seem to apply:
>>>
>>> https://stackoverflow.com/questions/26944908/django-url-mapp
>>> ing-how-to-remove-app-name-from-url-paths
>>>
>>> Let me summarise.
>>>
>>> I have a site that I've been building and testing with djangos
>>> development server of course. And it implements URLS like:
>>>
>>> http://127.0.0.1:8000/list/Model
>>> http://127.0.0.1:8000/add/Model
>>> http://127.0.0.1:8000/edit/Model/nn
>>> http://127.0.0.1:8000/view/Model/nn
>>> http://127.0.0.1:8000/delete/Model/nn
>>>
>>> Works like a dream, so I'm deploying, locally first, under lighttpd and
>>> uwsgi. That is working fine too. Sort of,
>>>
>>> These are all reached with links in my templates like yo:
>>>
>>> {% url 'list' model %}
>>> {% url 'add' model %}
>>> {% url 'edit' model pk %}
>>> {% url 'view' model pk %}
>>> {% url 'delete' model pk %}
>>>
>>> because in urls.py they all have "name"s defined like that.
>>>
>>> All honky dory.
>>>
>>> Now after deploying everything works nicely, but those same links point
>>> to:
>>>
>>> http://mysite.tld/app/list/Model
>>> http://mysite.tld/app/add/Model
>>> http://mysite.tld/app/edit/Model/nn
>>> http://mysite.tld/app/view/Model/nn
>>> http://mysite.tld/app/delete/Model/nn
>>>
>>> That is the app name is inserted. Odd. And undesired if not a crisis.
>>>
>>> But here's what bamboozles me. I can replace "app" in the url with any
>>> string at all, "x" say and the site continues to work but those URLs now
>>> point to :
>>>
>>> http://mysite.tld/x/list/Model
>>> http://mysite.tld/x/add/Model
>>> http://mysite.tld/x/edit/Model/nn
>>> http://mysite.tld/x/view/Model/nn
>>> http://mysite.tld/x/delete/Model/nn
>>>
>>> For what it's worth I don't want to quote urls.py and every other bit of
>>> possible config here of course, I am mainly interested to know if someone
>>> has insights that aren't shared in that SO link above as none of what is
>>> shared there seems to apply.
>>>
>>> For anyone really keen on code explorations urls.py is here:
>>>
>>> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py
>>>
>>> and the whole site is there too.
>>>
>>> What I want to understand is why this "app" suddenly appears in my URLs
>>> and how I can control it (remove it ideally). But I have looked at urls.py
>>> long enough and scratched my head and not found it. settings.py is right
>>> next to if you need to inspect it.
>>>
>>> Kind regards,
>>>
>>> Bernd.
>>>
>>>
>>>
>>>
>>> --
>>> 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/ms
>>> gid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com
>>> <https://groups.google.com/d/msgid/django-users/c2b971d4-61be-e74f-e6bc-6f3ed8ce2a65%40gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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/CACOk0TxkY_peb2mbFBEmLTX-gNCscsG5JMrnd3%3DVkyKK1LVdhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubts about static files

2017-08-30 Thread mohammad k
move the static folder beside the settings.py

On Wed, Aug 30, 2017 at 6:32 PM, mohammad k  wrote:

> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'firstdjango', 'static'),
> )
> STATIC_ROOT = '/Users/mk/Desktop/api/New folder/' : When you run
> collectstatic files moves files from static files from static folder to
> desktop.
> add this settings to the settings.py
>
> On Wed, Aug 30, 2017 at 6:28 PM, sarfaraz ahmed 
> wrote:
>
>>  Hello Team,
>>
>> I have doubts about static files. I read articles on Django but it does
>> not clearly states that atleast I got confused.
>>
>> STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] this is my
>> STATICFILES_DIRS settings which points out to static folder under my
>> project. Also, I can add all the folder from individual app which hold
>> static files here so that it search for static files.
>> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),'static_root')
>> which points out to one level up folder than my project. This is how my
>> project folder structures look like
>>
>> static_root
>> MyProject
>> --static
>> CSS
>> JS
>> imgs
>> --MyProject
>> --MyApp
>>
>> When I run collectstatic files moves files from static files from static
>> folder to static root.
>>
>> Now, my question is when deploy it on apache which folder should I point
>> to in my conf files. static_root or static.
>>
>> Regards,
>> Sarfaraz Ahmed
>>
>>
>>
>>
>>
>> --
>> 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/ms
>> gid/django-users/6b7e06ea-a56b-4b4b-b0ad-79ee4dbc3884%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/6b7e06ea-a56b-4b4b-b0ad-79ee4dbc3884%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CACOk0TyzZ6RK9Ff2KofqS%2BdK%2B3iJU2R-GB8Wj4QcpMwsP0i3ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubts about static files

2017-08-30 Thread mohammad k
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'firstdjango', 'static'),
)
STATIC_ROOT = '/Users/mk/Desktop/api/New folder/' : When you run
collectstatic files moves files from static files from static folder to
desktop.
add this settings to the settings.py

On Wed, Aug 30, 2017 at 6:28 PM, sarfaraz ahmed 
wrote:

>  Hello Team,
>
> I have doubts about static files. I read articles on Django but it does
> not clearly states that atleast I got confused.
>
> STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] this is my
> STATICFILES_DIRS settings which points out to static folder under my
> project. Also, I can add all the folder from individual app which hold
> static files here so that it search for static files.
> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),'static_root') which
> points out to one level up folder than my project. This is how my project
> folder structures look like
>
> static_root
> MyProject
> --static
> CSS
> JS
> imgs
> --MyProject
> --MyApp
>
> When I run collectstatic files moves files from static files from static
> folder to static root.
>
> Now, my question is when deploy it on apache which folder should I point
> to in my conf files. static_root or static.
>
> Regards,
> Sarfaraz Ahmed
>
>
>
>
>
> --
> 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/6b7e06ea-a56b-4b4b-b0ad-79ee4dbc3884%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/CACOk0TyqO2exvH%3D4bs5wWEiwfogOszJdb0fq8Q3OiVhqLbK6Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-09-01 Thread mohammad k
when you use the url tage in templates
you have to used like that {% url 'polls:edit' parameters %}: polls is the
app or controller and the edit is view or method

On Thu, Aug 31, 2017 at 4:46 PM, Melvyn Sopacua 
wrote:

> You may have a reverse proxy on port 80 that incorrectly rewrites
> /(.*) to / both ways.
>
> On Thu, Aug 31, 2017 at 2:10 PM, Bernd Wechner 
> wrote:
> > Tom,
> >
> > So I did a quick test now before retiring after all. And I am pulling my
> > hair out now. If I restart lighttpd on port 8000 (the last step to
> apparent
> > convergence) it works. I access both development and webserve sites on:
> >
> > http://127.0.0.1:8000/
> >
> > with server local browsers (Chrome on the dev server and Lynx on the
> > webserver for lack of a desktop). And they both now have links to:
> >
> > http://127.0.0.1:8000/list/Player
> >
> > and the link serves properly on both sites!
> >
> > Aaargh. Simply moving the web server from port 80 to port 8000 and the
> > problem went away. I could tear my hair out here. Again, a small step
> closer
> > to pinning a cause, but not much close to understanding the reason. The
> site
> > wants to run on 80 not 8000.
> >
> > So I guess more empirical tests on the morrow or weekend will include
> moving
> > runserver onto port 80 (after checking my dev box doesn't have something
> > listing there already ;-) to see if it develops the problem) and a close
> > look at the code to see if I can find any port dependencies?
> >
> > I call Twilight Zone of this so far.
> >
> > Remember, this:
> >
> > http://127.0.0.1/Leaderboards/list/Player
> >
> > also works consistently on port 80, that is the menu presents that URL
> from
> >
> > Players
> >
> > and it serves that URL albeit it serves all URLS
> >
> > http://127.0.0.1/whatever/list/Player
> >
> > identically.
> >
> > And on port 8000 that menu presents the URL:
> >
> > http://127.0.0.1:8000/list/Player
> >
> > and serves it.
> >
> > The only difference is one config line in lighttpd.conf:
> >
> > server.port = 80
> >
> > vs
> >
> > server.port = 8000
> >
> > with a a lighttpd restart ("sudo /etc/init.d/lighttpd restart") between.
> > Some code paths differ based on port it seems,
> >
> > I'll go find a wall to bang my head on now ;-).
> >
> > Regards,
> >
> > Bernd.
> >
> >
> > 'Tom Evans' via Django users wrote:
> >
> > On Thu, Aug 31, 2017 at 2:09 AM, Bernd Wechner 
> > wrote:
> >> Daniel,
> >>
> >> Yes, I have deployed, that is the problem in a sense. URLs are clean in
> >> dev
> >> and suddenly contain an app_name when deployed.
> >>
> >> Not sure what you mean by configuration? The Django settings are here:
> >>
> >> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/settings.py
> >>
> >> The rest of the config is uwsgi under lighttpd, but none of that is
> likely
> >> to impact the appearance of an app_name in my URLs all of a sudden. I
> >> don't
> >> mind sharing the config files, but it's a distraction I fear.
> >
> > I think you will be surprised.
> >
> > I'm surprised your diagnosis doesn't point you at this straight away,
> > if the URLs are correct on one site but incorrect on another site, and
> > both sites run the exact same python/django code, then the error is
> > certainly in the bits that are different.
> >
> > Cheers
> >
> > Tom
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+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/862e89bd-
> 19ab-1a20-9fcc-8f5152eed92d%40gmail.com.
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> 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/CA%2Bgw1GUnbnTcqA4TjQTHyOEuy_bZKSDTSsLWfhs8vymPFYneBA%
> 40mail.gmail.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