Re: Lazy evaluation of django custom context processor in base.html

2019-04-17 Thread BIJAL MANIAR

Hi,

Can anyone help on this. I want to pass value of "USERROLE" across all the 
django templates through "base.html". How to efficiently call custom 
context processor as it queries database for every page load.

Thanks,
Bijal 

On Monday, April 15, 2019 at 6:35:15 PM UTC+5:30, BIJAL MANIAR wrote:
>
>
> Hi,
>
> Have created a custom context processor to retrieve extra user attribute 
> from custom UserData model. Passing this variable in "base.html" template 
> calls the custom context processor function on every request to render html 
> page. Since it is a database query, how to efficiently call custom context 
> processor in "base.html".
>
> custom_context_processor.py
> def global_settings_userrole(request):
> USERROLE = None
> if request.user.is_authenticated():
> u = 
> UserData.objects.filter(username=request.user.username).values('role').first()
> USERROLE = u['role']
> return {
> 'USERROLE': USERROLE
> }
>
>
>
>
>
> Thanks,
> Bijal
>

-- 
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/c18cac8e-ad16-412e-a557-f1f97f06a12b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-17 Thread Vijay Khemlani
In your HTML, the form tag should have an enctype


...


On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
wrote:

> Sorry, the image file wasnt uploaded.
>
>
>
> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
> wrote:
>
>> Hi Everybody,
>>
>> I am trying to upload a file, but it says "No file chosen", even when I
>> have selected the file. However it is getting uploaded when I have logged
>> in as as admin and i am uploading it from there.
>>
>> Kindly help me, thanks in advance.
>>
>> views.py file:
>>
>> class VideoCreateView(CreateView):
>> form_class = VideoModelForm
>> fields = ['Video_Description','videofile']
>> template_name = 'deploy/create_view.html'
>>
>> success_url = "/video/create/"
>>
>> def form_valid(self, form):
>> form.instance.user = self.request.videofile
>> return super(VideoCreateView, self).form_valid(form)
>>
>>
>> models.py file:
>>
>> class Video(models.Model):
>> Video_Description= models.CharField(max_length=500)
>> videofile= models.FileField(upload_to='videos/', null=True,
>> verbose_name="")
>> timestamp   = models.DateTimeField(auto_now_add=True)
>>
>> class Meta:
>> ordering = ['-timestamp']
>>
>>
>> def __str__(self):
>> return self.Video_Description + ": " + str(self.id)
>>
>>
>> urls.py file:
>>
>>
>> url(r'^create/$', VideoCreateView.as_view(), name='create')
>>
>>
>> create_view.html :
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>> PFA the image file displaying the page after i selected the file and hit
>> the Upload Video button
>>
>> With Kind Regards
>>
>> Aakash Baranwal
>>
> --
> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%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 on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: compute model field by related field

2019-04-17 Thread Derek
1. Add a "winner" field to your Match
2. Implement a post_save  signal for the Match model that updates the "won" 
or "lost" fields for each Club in the match (simple if/then logic based on 
winner).

PS I think the default values for "won" and "lost" for a Club should be "0" 
and not "1".

On Tuesday, 16 April 2019 20:19:34 UTC+2, omar ahmed wrote:
>
> hello ... i have two models "Club" class and "Match" class and it has 
> foreign key to Club
> now i want to increment "won" field (or draw or lost) in "Club" class by 
> "score_local" and "score_visitor" in "Match" class ..
> how can i do this
> class Club(models.Model):
> name = models.CharField(max_length=100)
> won = models.IntegerField(default=1)
> draw = models.IntegerField(default=1)
> lost = models.IntegerField()
> goal_for = models.IntegerField()
> goal_against = models.IntegerField()
>
>
> class Match(models.Model):
> play_date = models.DateTimeField('play date')
> club_visitor = models.ForeignKey(Club, on_delete=models.CASCADE, 
> related_name='match_club_visitor')
> club_local = models.ForeignKey(Club, on_delete=models.CASCADE, 
> related_name='match_club_local')
> score_visitor = models.IntegerField()
> score_local = models.IntegerField()
>

-- 
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/d3e8e12a-4b6f-435d-a681-a4a6727bbda0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Need assistance! I want to create a list box that displays records that can be selected (single or multiple) from a PGSQL table.

2019-04-17 Thread Darryl Dillman
I have tried various methods including MVC, but cannot seem to get it 
right. I thought the MVC method would work, but it seems the database 
connection part was missing from the example I followed and only shows the 
submit button. I am able to create drop down lists from a static choices 
list in forms.py and display on my form, but I really need the data coming 
from my PGSQL table.

-- 
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/5772c160-6ec9-409e-9f70-0f1eb00b2612%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


jango.core.exceptions. error

2019-04-17 Thread fofazu . fz
 i am transferring my Django project to another laptop but it appears this 
error whan i try run server ~~django.core.exceptions.ImproperlyConfigured: 
Requested setting DEBUG, but settings are not configured. You must either 
define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.~~

-- 
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/cf1e4ba1-c098-415d-a756-7d90a817ccd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: jango.core.exceptions. error

2019-04-17 Thread Vivek Jha
Can you send me the screenshots

On Wed, 17 Apr 2019, 19:20 ,  wrote:

> i am transferring my Django project to another laptop but it appears this
> error whan i try run server ~~django.core.exceptions.ImproperlyConfigured:
> Requested setting DEBUG, but settings are not configured. You must either
> define the environment variable DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.~~
>
> --
> 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/cf1e4ba1-c098-415d-a756-7d90a817ccd7%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/CAMriZeHZMryBTT4kuM1SKMn2UchLQk6rmu1ttsg4dwgmnDGeNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-17 Thread Ram sundar
Hi Vijay,

You are right, but he has mentioned that it gets uploaded when logged in as
admin. Will it be a different template for the same view? Just wondering...

@Aakaash: can you please check in both cases and confirm please

Regards,
Ramsundar


On Wed 17 Apr, 2019, 6:18 PM Vijay Khemlani,  wrote:

> In your HTML, the form tag should have an enctype
>
> 
> ...
> 
>
> On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
> wrote:
>
>> Sorry, the image file wasnt uploaded.
>>
>>
>>
>> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
>> wrote:
>>
>>> Hi Everybody,
>>>
>>> I am trying to upload a file, but it says "No file chosen", even when I
>>> have selected the file. However it is getting uploaded when I have logged
>>> in as as admin and i am uploading it from there.
>>>
>>> Kindly help me, thanks in advance.
>>>
>>> views.py file:
>>>
>>> class VideoCreateView(CreateView):
>>> form_class = VideoModelForm
>>> fields = ['Video_Description','videofile']
>>> template_name = 'deploy/create_view.html'
>>>
>>> success_url = "/video/create/"
>>>
>>> def form_valid(self, form):
>>> form.instance.user = self.request.videofile
>>> return super(VideoCreateView, self).form_valid(form)
>>>
>>>
>>> models.py file:
>>>
>>> class Video(models.Model):
>>> Video_Description= models.CharField(max_length=500)
>>> videofile= models.FileField(upload_to='videos/', null=True,
>>> verbose_name="")
>>> timestamp   = models.DateTimeField(auto_now_add=True)
>>>
>>> class Meta:
>>> ordering = ['-timestamp']
>>>
>>>
>>> def __str__(self):
>>> return self.Video_Description + ": " + str(self.id)
>>>
>>>
>>> urls.py file:
>>>
>>>
>>> url(r'^create/$', VideoCreateView.as_view(), name='create')
>>>
>>>
>>> create_view.html :
>>>
>>> 
>>> {% csrf_token %}
>>> {{ form.as_p }}
>>> 
>>> 
>>>
>>> PFA the image file displaying the page after i selected the file and hit
>>> the Upload Video button
>>>
>>> With Kind Regards
>>>
>>> Aakash Baranwal
>>>
>> --
>> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%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 on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%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 on the web visit 
https://groups.google.com/d/msgid/django-users/CAGJAuo8y1rQKUkVd0ZgxAEKq74Yz6Zi6_3ZU-0r7x4A7pas5WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need assistance! I want to create a list box that displays records that can be selected (single or multiple) from a PGSQL table.

2019-04-17 Thread Joel Mathew
Great to know

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


Re: File not getting uploaded

2019-04-17 Thread Vijay Khemlani
When he said "uploading it from there" I was not sure whether "there" meant
Django's admin page or the same view that's failing now

As far as I know the form has to have a multipart enctype to upload files

On Wed, Apr 17, 2019 at 9:53 AM Ram sundar  wrote:

> Hi Vijay,
>
> You are right, but he has mentioned that it gets uploaded when logged in
> as admin. Will it be a different template for the same view? Just
> wondering...
>
> @Aakaash: can you please check in both cases and confirm please
>
> Regards,
> Ramsundar
>
>
> On Wed 17 Apr, 2019, 6:18 PM Vijay Khemlani,  wrote:
>
>> In your HTML, the form tag should have an enctype
>>
>> 
>> ...
>> 
>>
>> On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
>> wrote:
>>
>>> Sorry, the image file wasnt uploaded.
>>>
>>>
>>>
>>> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
>>> wrote:
>>>
 Hi Everybody,

 I am trying to upload a file, but it says "No file chosen", even when I
 have selected the file. However it is getting uploaded when I have logged
 in as as admin and i am uploading it from there.

 Kindly help me, thanks in advance.

 views.py file:

 class VideoCreateView(CreateView):
 form_class = VideoModelForm
 fields = ['Video_Description','videofile']
 template_name = 'deploy/create_view.html'

 success_url = "/video/create/"

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


 models.py file:

 class Video(models.Model):
 Video_Description= models.CharField(max_length=500)
 videofile= models.FileField(upload_to='videos/', null=True,
 verbose_name="")
 timestamp   = models.DateTimeField(auto_now_add=True)

 class Meta:
 ordering = ['-timestamp']


 def __str__(self):
 return self.Video_Description + ": " + str(self.id)


 urls.py file:


 url(r'^create/$', VideoCreateView.as_view(), name='create')


 create_view.html :

 
 {% csrf_token %}
 {{ form.as_p }}
 
 

 PFA the image file displaying the page after i selected the file and
 hit the Upload Video button

 With Kind Regards

 Aakash Baranwal

>>> --
>>> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%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 on the web visit
>> https://groups.google.com/d/msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%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 on the web visit
> https://groups.google.com/d/msgid/django-users/CAGJAuo8y1rQKUkVd0ZgxAEKq74Yz6Zi6_3ZU-0r7x4A7pas5WQ%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

Re: Need assistance! I want to create a list box that displays records that can be selected (single or multiple) from a PGSQL table.

2019-04-17 Thread Darryl Dillman
???

On Wednesday, April 17, 2019 at 10:02:53 AM UTC-4, Joel Mathew wrote:
>
> Great to know
>

-- 
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/ba42e6e5-4d0a-4cbe-a2e4-2a8d07c3a9a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL.
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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%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 on the web visit 
https://groups.google.com/d/msgid/django-users/cbdab94a9c2b481bbddb1b242009de80%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-17 Thread Aakash Baranwal
Hi,

Actually, his solution was correct because when I provided the encryption
it worked, however I am not sure about the reason why it did worked at all.

Thanks a lot.

With Kind Regards
Aakash Baranwal

On 17 Apr 2019 7:23 p.m., "Ram sundar"  wrote:

> Hi Vijay,
>
> You are right, but he has mentioned that it gets uploaded when logged in
> as admin. Will it be a different template for the same view? Just
> wondering...
>
> @Aakaash: can you please check in both cases and confirm please
>
> Regards,
> Ramsundar
>
>
> On Wed 17 Apr, 2019, 6:18 PM Vijay Khemlani,  wrote:
>
>> In your HTML, the form tag should have an enctype
>>
>> 
>> ...
>> 
>>
>> On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
>> wrote:
>>
>>> Sorry, the image file wasnt uploaded.
>>>
>>>
>>>
>>> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
>>> wrote:
>>>
 Hi Everybody,

 I am trying to upload a file, but it says "No file chosen", even when I
 have selected the file. However it is getting uploaded when I have logged
 in as as admin and i am uploading it from there.

 Kindly help me, thanks in advance.

 views.py file:

 class VideoCreateView(CreateView):
 form_class = VideoModelForm
 fields = ['Video_Description','videofile']
 template_name = 'deploy/create_view.html'

 success_url = "/video/create/"

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


 models.py file:

 class Video(models.Model):
 Video_Description= models.CharField(max_length=500)
 videofile= models.FileField(upload_to='videos/', null=True,
 verbose_name="")
 timestamp   = models.DateTimeField(auto_now_add=True)

 class Meta:
 ordering = ['-timestamp']


 def __str__(self):
 return self.Video_Description + ": " + str(self.id)


 urls.py file:


 url(r'^create/$', VideoCreateView.as_view(), name='create')


 create_view.html :

 
 {% csrf_token %}
 {{ form.as_p }}
 
 

 PFA the image file displaying the page after i selected the file and
 hit the Upload Video button

 With Kind Regards

 Aakash Baranwal

>>> --
>>> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%
>>> 2BzA1DM4DBHshTP5dMNat2g%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 on the web visit https://groups.google.com/d/
>> msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%
>> 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 on the web visit https://groups.google.com/d/
> msgid/django-users/CAGJAuo8y1rQKUkVd0ZgxAEKq74Yz6
> Zi6_3ZU-0r7x4A7pas5WQ%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.

Re: File not getting uploaded

2019-04-17 Thread Aakash Baranwal
Thanks a lot. Your solution worked perfectly for me.

With Kind Regards
Aakash Baranwal

On 17 Apr 2019 7:36 p.m., "Vijay Khemlani"  wrote:

When he said "uploading it from there" I was not sure whether "there" meant
Django's admin page or the same view that's failing now

As far as I know the form has to have a multipart enctype to upload files

On Wed, Apr 17, 2019 at 9:53 AM Ram sundar  wrote:

> Hi Vijay,
>
> You are right, but he has mentioned that it gets uploaded when logged in
> as admin. Will it be a different template for the same view? Just
> wondering...
>
> @Aakaash: can you please check in both cases and confirm please
>
> Regards,
> Ramsundar
>
>
> On Wed 17 Apr, 2019, 6:18 PM Vijay Khemlani,  wrote:
>
>> In your HTML, the form tag should have an enctype
>>
>> 
>> ...
>> 
>>
>> On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
>> wrote:
>>
>>> Sorry, the image file wasnt uploaded.
>>>
>>>
>>>
>>> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
>>> wrote:
>>>
 Hi Everybody,

 I am trying to upload a file, but it says "No file chosen", even when I
 have selected the file. However it is getting uploaded when I have logged
 in as as admin and i am uploading it from there.

 Kindly help me, thanks in advance.

 views.py file:

 class VideoCreateView(CreateView):
 form_class = VideoModelForm
 fields = ['Video_Description','videofile']
 template_name = 'deploy/create_view.html'

 success_url = "/video/create/"

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


 models.py file:

 class Video(models.Model):
 Video_Description= models.CharField(max_length=500)
 videofile= models.FileField(upload_to='videos/', null=True,
 verbose_name="")
 timestamp   = models.DateTimeField(auto_now_add=True)

 class Meta:
 ordering = ['-timestamp']


 def __str__(self):
 return self.Video_Description + ": " + str(self.id)


 urls.py file:


 url(r'^create/$', VideoCreateView.as_view(), name='create')


 create_view.html :

 
 {% csrf_token %}
 {{ form.as_p }}
 
 

 PFA the image file displaying the page after i selected the file and
 hit the Upload Video button

 With Kind Regards

 Aakash Baranwal

>>> --
>>> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%
>>> 2BzA1DM4DBHshTP5dMNat2g%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 on the web visit https://groups.google.com/d/
>> msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%
>> 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 on the web visit https://groups.google.com/d/
> msgid/django-users/CAGJAuo8y1rQKUkVd0ZgxAEKq74Yz6
> Zi6_3ZU-0r7x4A7pas5WQ%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-us

RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Okay, the model I’m using specifies an __eq__ function without a corresponding 
__hash__ function. I’ve opened a pull request with the owner of that project.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matthew Pava
Sent: Wednesday, April 17, 2019 11:18 AM
To: django-users@googlegroups.com
Subject: RE: Unhashable TypeError when deleted from model, Django 2.2

Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL.
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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%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+u

Re: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Sithembewena L. Dube
Interesting. Good catch.

Kind regards,
Sithu


*Sent with Shift
*

On Wed, Apr 17, 2019 at 9:48 PM Matthew Pava  wrote:

> Okay, the model I’m using specifies an __eq__ function without a
> corresponding __hash__ function. I’ve opened a pull request with the owner
> of that project.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Matthew Pava
> *Sent:* Wednesday, April 17, 2019 11:18 AM
> *To:* django-users@googlegroups.com
> *Subject:* RE: Unhashable TypeError when deleted from model, Django 2.2
>
>
>
> Hi Sithu,
>
> I would still need to a way determine when a record expires. A Boolean
> wouldn’t help in that regard.
>
> But I think this error has something to do with Django’s delete method.
> The filtering aspect works just fine.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Sithembewena L. Dube
> *Sent:* Tuesday, April 16, 2019 2:49 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Unhashable TypeError when deleted from model, Django 2.2
>
>
>
> Why not use a boolean field on the model to denote expires? Then if that
> field is True, delete the object? I think that would be cheaper and
> cleaner, especially with lookups.
>
>
>
> Kind regards,
> Sithu
>
>
>
> *Sent with Shift
> *
>
>
>
> On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava  wrote:
>
> I have a model that has a nullable field called expires. If expires is
> null, then the record never expires.
>
> I’m performing a delete on the model for any record that has an expires
> date that has passed, and I keep getting a TypeError that Model is
> unhashable. Am I doing something wrong?
>
>
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>
>
> Here’s the traceback:
>
>
>
> Traceback (most recent call last):
>
>   File "\django\core\handlers\exception.py", line 34, in inner
>
> response = get_response(request)
>
>   File "\django\core\handlers\base.py", line 115, in _get_response
>
> response = self.process_exception_by_middleware(e, request)
>
>   File "\django\core\handlers\base.py", line 113, in _get_response
>
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File "\django\views\decorators\csrf.py", line 54, in wrapped_view
>
> return view_func(*args, **kwargs)
>
>   File "\django\views\generic\base.py", line 71, in view
>
> return self.dispatch(request, *args, **kwargs)
>
>   File "\rest_framework\views.py", line 495, in dispatch
>
> response = self.handle_exception(exc)
>
>   File "\rest_framework\views.py", line 455, in handle_exception
>
> self.raise_uncaught_exception(exc)
>
>   File "\rest_framework\views.py", line 492, in dispatch
>
> response = handler(request, *args, **kwargs)
>
>   File "\rest_framework\decorators.py", line 55, in handler
>
> return func(*args, **kwargs)
>
>   File "C:\project\general\views.py", line 88, in all_messages_for_user
>
> Model.objects.filter(expires__lt=timezone.now()).delete()
>
>   File "\django\db\models\query.py", line 710, in delete
>
> collector.collect(del_query)
>
>   File "\django\db\models\deletion.py", line 192, in collect
>
> reverse_dependency=reverse_dependency)
>
>   File "\django\db\models\deletion.py", line 94, in add
>
> if obj not in instances:
>
> TypeError: unhashable type: 'Model'
>
> --
> 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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL
> 
> .
> 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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com
> 

Re: fesherstructural error

2019-04-17 Thread Joseph Jones
Hello fellow Django community members, thank you  for the advice I’m
applying it to the best of my ability  I still believe I am not being as
discriptive as  far as the problem I am having but I’m gleaning from what
I’ve read on the forum that with Django one often works out a solution
while discribing the error so any further advice  on error recongnition
would be apreciated thank you,
Joseph

On Fri, Apr 12, 2019 at 1:21 PM Joseph Jones  wrote:

> Hello,
> First thank you very much for the advice and I apologize for the response
> delay. just to make sure I understand the advice correctly I would install
> Django on
> Hypotheticalprojetfolder/bin/env? Please let me know. Thank you,
> Joseph
>
> On Tue, Apr 9, 2019 at 3:30 PM Julio Cojom 
> wrote:
>
>> If you're using virtualenv, then u need to activate before running
>> manage.py, to activate, use workon .
>>
>> Maybe you only installed Django in your virtualenv and not in your system.
>>
>> Regards!
>>
>> El mar., 9 abr. 2019 a las 13:20, sachin thakur (<
>> sachin.thakur9...@gmail.com>) escribió:
>>
>>> Create your virtual machine  in any or directory
>>>
>>>
>>>  Then install the django in that virtual machine n create your project
>>>
>>> Regards
>>> Sachin Thakur
>>>
>>> On Wed 10 Apr, 2019, 12:47 AM Joseph Jones,  wrote:
>>>
 Hello fellow Django community members,
 I seem to be having quite a bit of trouble fixing my error in calling
 the manage.py directory in my project. I've received of a hint in that my
 code launcher  indicates that "Django is not importable into this
 environment" so it would appear as well as the error in the structure I
 have made an additional error to give an picture of the structure of my
 project. it is
 C:/users/Joseph
 C:/users/Joseph/Anaconda3
 C:/users/Joseph/Anaconda3 /lib
 C:/users/Joseph/Anaconda3 /lib/site-packages
 Any advice on the step I seem to be missing would be  appreciated.
 Thank you, Joseph

 --
 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/CAJGsC5Oy9HdXqHSe4qj2mShPjktyV2GsM2rY9qsQ4NZeKw_g8g%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 on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2BLmcYtMi3wsgGVtDpDmV19bAUJHDS3TNfX5Z5gyQgELAsy8xw%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 on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHRQUH%3D1XLhLx%3DShNtYRkW16E8hEKEN7DJhPtTW1cxMWp-HRKw%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 on the web visit 
https://groups.google.com/d/msgid/django-users/CAJGsC5PpBg%2B_ex8Dpg4_Mhz0Dh2Zt0Vh5tdi%3DH2dNnD7ALcnSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Settings file for multiple environments?

2019-04-17 Thread ANi

Hi,
I divided my settings into different files, but I think it's not working on 
Heroku, here are my code:

# This is abcd/setting/hk.py
from .base import *
import dj_database_url


DATABASES = {
 'default': dj_database_url.config()
}


ALLOWED_HOSTS.append('abcdmyapp.herokuapps.com')
WSGI_APPLICATION = 'abcd.wsgi.hk.application'
MIDDLEWARE.append('whitenoise.middleware.WhiteNoiseMiddleware')

DEBUG = False


I doubt these two configurations because I still can run my app in debug 
mode but got a error about not allowing the host and there is no folder 
created for static files.


More info:

# This is base.py
# no DATABASES, DEBUG and WSGI_APPLICATION

ALLOWED_HOSTS = ['127.0.0.1']
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',

]


# This is Procfile

web: gunicorn abcd.wsgi.hk 
release: python manage.py migrate
web: python manage.py runserver 0.0.0.0:$PORT

# This is abcd/wsgi/hk.py
 
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abcd.settings.hk")
application = get_wsgi_application()



-- 
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/8a6fe85d-2349-4b58-86df-6e2a4df00500%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need assistance! I want to create a list box that displays records that can be selected (single or multiple) from a PGSQL table.

2019-04-17 Thread ANi
Can you provide the code you've done so far?

Darryl Dillman於 2019年4月17日星期三 UTC+8下午9時51分16秒寫道:
>
> I have tried various methods including MVC, but cannot seem to get it 
> right. I thought the MVC method would work, but it seems the database 
> connection part was missing from the example I followed and only shows the 
> submit button. I am able to create drop down lists from a static choices 
> list in forms.py and display on my form, but I really need the data coming 
> from my PGSQL table.
>

-- 
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/f7d18a05-a7b0-487e-8ced-72b803cea28a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Settings file for multiple environments?

2019-04-17 Thread Ayser shuhaib
Are you sure about the directory?
I mean is it “ abcd.setting.hk” or “abcd.settings.hk” ?

On Thu, 18 Apr 2019 at 06:00, ANi  wrote:

>
> Hi,
> I divided my settings into different files, but I think it's not working
> on Heroku, here are my code:
>
> # This is abcd/setting/hk.py
> from .base import *
> import dj_database_url
>
>
> DATABASES = {
>  'default': dj_database_url.config()
> }
>
>
> ALLOWED_HOSTS.append('abcdmyapp.herokuapps.com')
> WSGI_APPLICATION = 'abcd.wsgi.hk.application'
> MIDDLEWARE.append('whitenoise.middleware.WhiteNoiseMiddleware')
>
> DEBUG = False
>
>
> I doubt these two configurations because I still can run my app in debug
> mode but got a error about not allowing the host and there is no folder
> created for static files.
>
>
> More info:
>
> # This is base.py
> # no DATABASES, DEBUG and WSGI_APPLICATION
>
> ALLOWED_HOSTS = ['127.0.0.1']
> MIDDLEWARE = [
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 
> ]
>
>
> # This is Procfile
>
> web: gunicorn abcd.wsgi.hk
> release: python manage.py migrate
> web: python manage.py runserver 0.0.0.0:$PORT
>
> # This is abcd/wsgi/hk.py
>
> import os
> from django.core.wsgi import get_wsgi_application
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abcd.settings.hk")
> application = get_wsgi_application()
>
>
>
>
> --
> 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/8a6fe85d-2349-4b58-86df-6e2a4df00500%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/CAE0AZGLtyhXJ5X3HL00H5sbB66h5rGftnu%2BVYWZdEmkOvzV4Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Settings file for multiple environments?

2019-04-17 Thread ANi
yes, it is "abcd.*settings*.hk". And I think it will show error if it's 
wrong (?

Ayser shuhaib於 2019年4月18日星期四 UTC+8下午1時10分04秒寫道:
>
> Are you sure about the directory?
> I mean is it “ abcd.setting.hk” or “abcd.settings.hk” ?
>
> On Thu, 18 Apr 2019 at 06:00, ANi > wrote:
>
>>
>> Hi,
>> I divided my settings into different files, but I think it's not working 
>> on Heroku, here are my code:
>>
>> # This is abcd/setting/hk.py
>> from .base import *
>> import dj_database_url
>>
>>
>> DATABASES = {
>>  'default': dj_database_url.config()
>> }
>>
>>
>> ALLOWED_HOSTS.append('abcdmyapp.herokuapps.com')
>> WSGI_APPLICATION = 'abcd.wsgi.hk.application'
>> MIDDLEWARE.append('whitenoise.middleware.WhiteNoiseMiddleware')
>>
>> DEBUG = False
>>
>>
>> I doubt these two configurations because I still can run my app in debug 
>> mode but got a error about not allowing the host and there is no folder 
>> created for static files.
>>
>>
>> More info:
>>
>> # This is base.py
>> # no DATABASES, DEBUG and WSGI_APPLICATION
>>
>> ALLOWED_HOSTS = ['127.0.0.1']
>> MIDDLEWARE = [
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 
>> ]
>>
>>
>> # This is Procfile
>>
>> web: gunicorn abcd.wsgi.hk 
>> release: python manage.py migrate
>> web: python manage.py runserver 0.0.0.0:$PORT
>>
>> # This is abcd/wsgi/hk.py
>>  
>> import os
>> from django.core.wsgi import get_wsgi_application
>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abcd.settings.hk")
>> application = get_wsgi_application()
>>
>>
>>
>>
>> -- 
>> 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...@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/8a6fe85d-2349-4b58-86df-6e2a4df00500%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/919a2737-c2fa-48e7-84ed-5e89a4ac0522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.