Django Sitemap on heroku error h13

2020-09-12 Thread dum dum
I don't know why,
in local
localhost:8000/sitemap.xml will generate sitemap.xml.

But on heroku,
domain/sitemap.xml will error h13.

I followed this tutorial
https://jawaban.online/scope/outlink/6442/django-sitemap-tutorial-help-crawlers-understand-your-website-2018-youtube/
and
https://medium.com/analytics-vidhya/django-sitemap-8f4ca0538fa

Any suggestions?
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3DaNTq2bmWj4DyosiOA02qWbVjieazZKc0_PW5ajTx4_dg%40mail.gmail.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-12 Thread dum dum
Another problem now..

I don't know why,
in local
localhost:8000/sitemap.xml will generate sitemap.xml.

But on heroku,
domain/sitemap.xml will error h13.

Any suggestions?
Thanks.

On Wed, Sep 9, 2020 at 11:31 AM hans alexander  wrote:

> Thanks guys.. Already solved it.
> I guess the main reason of the problem is that I'm using Pycharm Community
> Edition.
> So the alert error not accurate.
>
> Anyway I tried to py manage.py with some alerts, and worked.
> for example:
> [image: image.png]
> I left it like that. And sitemap still works.
>
> But now the new problem is when I submitted my sitemap.xml to google
> search console, I got this error.
> [image: image.png]
> I don't know why.
>
> Even when I access the domain/sitemap.xml, the sitemap is showing.
>
> Any suggestions?
>
> Thanks
>
> On Wed, Sep 9, 2020 at 4:20 AM coolguy 
> wrote:
>
>> I did this long time ago and here is what i did...
>>
>> in settings.py
>> SITE_ID = 1
>> # Application definition
>> INSTALLED_APPS = [
>># ...
>>'django.contrib.sites',
>>'django.contrib.sitemaps',
>> ]
>>
>> run migration i.e.
>> >>> py manage.py migrateOR python manage.py migrate
>> after this step, sites application will be in sync with the database.
>>
>> create a file sitemaps.py in your blog application. Your sitemap.py seems
>> okay to me.
>>
>> update your main project urls.py file
>> 
>> from django.contrib.sitemaps.views import sitemap
>> from blog.sitemaps import BlogPostsSitemap
>>
>> sitemaps = {
>> 'posts' : BlogPostsSitemap,
>> }
>>
>> urlpatterns = [
>>   
>>   path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
>> name='django.contrib.sitemaps.views.sitemap'),
>> ]
>>
>> Now run the development server and open (assuming you are using default
>> configuration) http://127.0.0.1:8000/sitemap
>>
>> lets try...
>>
>> On Tuesday, September 8, 2020 at 2:53:12 PM UTC-4 hanz...@gmail.com
>> wrote:
>>
>>> I followed a tutorial for creating django sitemap, but still got
>>> problems along the way.
>>> I've seen some videos, but didn't work.
>>> Do you have any references for easy way creating django sitemap for blog
>>> posts?
>>> Sure it would help.
>>>
>>> Thanks
>>>
>>>
>>>
>>> On Wed, Sep 9, 2020 at 12:02 AM coolguy  wrote:
>>>
 Not sure why you are importing this into your main project urls.py but
 its very straight forward

 from blog.sitemaps import BlogPostsSitemap

 question... are you trying to map the application url here? then you
 should use path('/' , Include("blog.urls"))




 On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com
 wrote:

> Sorry, point no 1 needs to be revised..
> 1. In urls.py, I want to import BlogPostsSitemap
>
>
> --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com
 
 .

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%40googlegroups.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3Dak%2BvTWq0L%2B7jjKrcphEAAQRFX0ESaaO6FBjQR4PA%3Dnyw%40mail.gmail.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread coolguy
I wanted to see your model to understand but i realized after my last post 
that you are using "instance.user.id" while your employee instance does not 
have user field. (had to go somewhere urgently) >>> return 
"employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
extension)  

change it as follow and remove user from it.
return "employees/media/users/{0}/profile_picture.{1}".format(instance.id 
, extension)  

It should work...

On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
wrote:

> coolguy here is the complete Employee model:
>
> class Employee(models.Model): #TODO: Double-check this
> username = models.CharField(max_length=50, unique=True)
> email = models.EmailField()
> password = models.CharField(max_length=50)
> first_name = models.CharField(max_length=150)
> last_name = models.CharField(max_length=100)
> website = models.URLField(max_length=200, blank=True)
>
> profile_picture = models.ImageField(upload_to=get_upload_path, 
> blank=True, null=True)
> 
> def __str__(self):
> return str(self.first_name) + str(self.last_name)
>
> *Why do I need the foreign key to User in the first place?* I don't 
> recall seing the foreign key to User in any one of the tutorials.
> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao je:
>
>> Please share the complete employee model. It seems you are missing User 
>> foreign key in it.
>>
>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey guys,
>>>
>>> I have the following code in models.py file in one of my apps:
>>>
>>> def get_upload_path(instance, filename):
>>> extension = filename.split('.')[-1]
>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>> instance.user.id, extension)
>>>
>>> class Employee(models.Model):
>>> # some attributes here
>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>> blank=True, null=True)
>>>
>>> I am getting the following error when I try to add an Employee via the 
>>> admin interface:
>>>
>>> AttributeError at /admin/employees/employee/add/
>>>
>>> 'Employee' object has no attribute 'user'
>>>
>>> *I don't know where this error is stemming from.* I took the 
>>> get_upload_path function from the official Django FIleField 
>>> documentation 
>>> .
>>>
>>> Any ideas as to what is going on here?
>>>
>>> Best,
>>> Mislav
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f08f03a-9617-48b9-bfdb-d00e44652cf1n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
coolguy here is the complete Employee model:

class Employee(models.Model): #TODO: Double-check this
username = models.CharField(max_length=50, unique=True)
email = models.EmailField()
password = models.CharField(max_length=50)
first_name = models.CharField(max_length=150)
last_name = models.CharField(max_length=100)
website = models.URLField(max_length=200, blank=True)
profile_picture = models.ImageField(upload_to=get_upload_path, 
blank=True, null=True)

def __str__(self):
return str(self.first_name) + str(self.last_name)

*Why do I need the foreign key to User in the first place?* I don't recall 
seing the foreign key to User in any one of the tutorials.
Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao je:

> Please share the complete employee model. It seems you are missing User 
> foreign key in it.
>
> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey guys,
>>
>> I have the following code in models.py file in one of my apps:
>>
>> def get_upload_path(instance, filename):
>> extension = filename.split('.')[-1]
>> return "employees/media/users/{0}/profile_picture.{1}".format(
>> instance.user.id, extension)
>>
>> class Employee(models.Model):
>> # some attributes here
>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>> blank=True, null=True)
>>
>> I am getting the following error when I try to add an Employee via the 
>> admin interface:
>>
>> AttributeError at /admin/employees/employee/add/
>>
>> 'Employee' object has no attribute 'user'
>>
>> *I don't know where this error is stemming from.* I took the 
>> get_upload_path function from the official Django FIleField documentation 
>> .
>>
>> Any ideas as to what is going on here?
>>
>> Best,
>> Mislav
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c0e9382d-62d2-4c49-bb83-e3a985d26749n%40googlegroups.com.


Re: help me it shows error.

2020-09-12 Thread coolguy
change post:pk to i.id

also fix line and delete id={{ i.id }}

On Saturday, September 12, 2020 at 2:54:16 PM UTC-4 yashlan...@gmail.com 
wrote:

> [image: 5.PNG]
> [image: 8.PNG]
> [image: 9.PNG]
> [image: 10.PNG]
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0770bafa-3f96-4b64-9f09-3f0418007c6en%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
coolguy:

I tried it without the quotes. Maybe that was the issue.

Dana subota, 12. rujna 2020. u 20:33:52 UTC+2 korisnik coolguy napisao je:

> Keep this handy as well... 
>
> https://docs.djangoproject.com/en/3.1/ref/migration-operations/#addfield
>
> On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
> wrote:
>
>> A question to coolguy:
>>
>> *What should I have done if I selected option 1?* I get the Python shell 
>> and if I input a default value - let's say "te...@test.com", what else 
>> do I need to do? I tried to just provide the default value, but it wouldn't 
>> accept it, complaining that it was invalid Python (as it is). *Do I need 
>> to select the existing rows from the database and set them all to have the 
>> value of the new field to the default value? If yes, how do I do this most 
>> efficiently (in code)?*
>>
>> Best,
>> Mislav
>>
>> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>>
>>> just FYI...
>>>
>>> You didn't have to delete the db.sqllite3 file rather would have 
>>> followed on-screen direction and provided a default value to persist in the 
>>> existing records in your database. Later you could have edited the info 
>>> through your program and make correction.
>>>
>>> This is pretty normal situation where we added new fields/properties in 
>>> our model while database has existing records. You wouldn't be able to 
>>> delete the database in case you are using relational database like postgres 
>>> or mysql.
>>>
>>> Thanks
>>>
>>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 
>>> mislav@gmail.com wrote:
>>>
 Hey Danish,

 I was able to resolve the error by deleting the *db.sqlite3* file from 
 my project root directory and all of the *migrations* folders from all 
 of my apps.

 Thank you for responding.

 Best,
 Mislav


 Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
 mailto...@gmail.com napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
> wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  
>> to some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee 
>> without a default; we can't do that (the database needs something to 
>> populate existing rows).Please select a fix: 1) Provide a one-off 
>> default 
>> now (will be set on all existing rows with a null value for this column) 
>> 2) 
>> Quit, and let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out 
>> the new EmailField in the models I added them and I dropped all of the 
>> database rows in my entire database (not just the rows related to the 
>> models where I added the new email field; I dropped every row from every 
>> table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I 
>> need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ef66474e-3867-43d4-abbe-9183cd08d2cen%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
Keep this handy as well... 

https://docs.djangoproject.com/en/3.1/ref/migration-operations/#addfield

On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
wrote:

> A question to coolguy:
>
> *What should I have done if I selected option 1?* I get the Python shell 
> and if I input a default value - let's say "te...@test.com", what else do 
> I need to do? I tried to just provide the default value, but it wouldn't 
> accept it, complaining that it was invalid Python (as it is). *Do I need 
> to select the existing rows from the database and set them all to have the 
> value of the new field to the default value? If yes, how do I do this most 
> efficiently (in code)?*
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>
>> just FYI...
>>
>> You didn't have to delete the db.sqllite3 file rather would have followed 
>> on-screen direction and provided a default value to persist in the existing 
>> records in your database. Later you could have edited the info through your 
>> program and make correction.
>>
>> This is pretty normal situation where we added new fields/properties in 
>> our model while database has existing records. You wouldn't be able to 
>> delete the database in case you are using relational database like postgres 
>> or mysql.
>>
>> Thanks
>>
>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey Danish,
>>>
>>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>>> my project root directory and all of the *migrations* folders from all 
>>> of my apps.
>>>
>>> Thank you for responding.
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>>> mailto...@gmail.com napisao je:
>>>
 you need to give default value in email. seems few records are already 
 exist.

 else delete sqllite file and try again.

 On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
 wrote:

> Hey guys,
>
> I added an EmailField 
>  
> to some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee 
> without a default; we can't do that (the database needs something to 
> populate existing rows).Please select a fix: 1) Provide a one-off default 
> now (will be set on all existing rows with a null value for this column) 
> 2) 
> Quit, and let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out 
> the new EmailField in the models I added them and I dropped all of the 
> database rows in my entire database (not just the rows related to the 
> models where I added the new email field; I dropped every row from every 
> table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few 
> times, but I'm not sure what I need to do. I tried to supply a value for 
> that field, but the prompt is a Python shell, so I'm not sure what I need 
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>  
> 
> .
>


 -- 
 Thanks & Regards 
   
 Regards, 
 Danish

>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb23d859-0d78-4115-a461-cf8bd547493dn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
Interesting... did you try the email with quotes or without it

On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
wrote:

> A question to coolguy:
>
> *What should I have done if I selected option 1?* I get the Python shell 
> and if I input a default value - let's say "te...@test.com", what else do 
> I need to do? I tried to just provide the default value, but it wouldn't 
> accept it, complaining that it was invalid Python (as it is). *Do I need 
> to select the existing rows from the database and set them all to have the 
> value of the new field to the default value? If yes, how do I do this most 
> efficiently (in code)?*
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>
>> just FYI...
>>
>> You didn't have to delete the db.sqllite3 file rather would have followed 
>> on-screen direction and provided a default value to persist in the existing 
>> records in your database. Later you could have edited the info through your 
>> program and make correction.
>>
>> This is pretty normal situation where we added new fields/properties in 
>> our model while database has existing records. You wouldn't be able to 
>> delete the database in case you are using relational database like postgres 
>> or mysql.
>>
>> Thanks
>>
>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey Danish,
>>>
>>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>>> my project root directory and all of the *migrations* folders from all 
>>> of my apps.
>>>
>>> Thank you for responding.
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>>> mailto...@gmail.com napisao je:
>>>
 you need to give default value in email. seems few records are already 
 exist.

 else delete sqllite file and try again.

 On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
 wrote:

> Hey guys,
>
> I added an EmailField 
>  
> to some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee 
> without a default; we can't do that (the database needs something to 
> populate existing rows).Please select a fix: 1) Provide a one-off default 
> now (will be set on all existing rows with a null value for this column) 
> 2) 
> Quit, and let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out 
> the new EmailField in the models I added them and I dropped all of the 
> database rows in my entire database (not just the rows related to the 
> models where I added the new email field; I dropped every row from every 
> table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few 
> times, but I'm not sure what I need to do. I tried to supply a value for 
> that field, but the prompt is a Python shell, so I'm not sure what I need 
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>  
> 
> .
>


 -- 
 Thanks & Regards 
   
 Regards, 
 Danish

>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f0c98b3-bea3-4e47-977c-61323df4cf23n%40googlegroups.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread coolguy
Please share the complete employee model. It seems you are missing User 
foreign key in it.

On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 mislav@gmail.com 
wrote:

> Hey guys,
>
> I have the following code in models.py file in one of my apps:
>
> def get_upload_path(instance, filename):
> extension = filename.split('.')[-1]
> return "employees/media/users/{0}/profile_picture.{1}".format(
> instance.user.id, extension)
>
> class Employee(models.Model):
> # some attributes here
> profile_picture = models.ImageField(upload_to=get_upload_path, 
> blank=True, null=True)
>
> I am getting the following error when I try to add an Employee via the 
> admin interface:
>
> AttributeError at /admin/employees/employee/add/
>
> 'Employee' object has no attribute 'user'
>
> *I don't know where this error is stemming from.* I took the 
> get_upload_path function from the official Django FIleField documentation 
> .
>
> Any ideas as to what is going on here?
>
> Best,
> Mislav
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7f3940db-9144-4b68-bd83-095322b51af2n%40googlegroups.com.


AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
Hey guys,

I have the following code in models.py file in one of my apps:

def get_upload_path(instance, filename):
extension = filename.split('.')[-1]
return "employees/media/users/{0}/profile_picture.{1}".format(
instance.user.id, extension)

class Employee(models.Model):
# some attributes here
profile_picture = models.ImageField(upload_to=get_upload_path,
blank=True, null=True)

I am getting the following error when I try to add an Employee via the
admin interface:

AttributeError at /admin/employees/employee/add/

'Employee' object has no attribute 'user'

*I don't know where this error is stemming from.* I took the
get_upload_path function from the official Django FIleField documentation
.

Any ideas as to what is going on here?

Best,
Mislav

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABTqP_FcyzEXhtyBM--khtnsdHhfszi9vtmt-bY3TUsU0KWmLg%40mail.gmail.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
A question to coolguy:

*What should I have done if I selected option 1?* I get the Python shell 
and if I input a default value - let's say "t...@test.com", what else do I 
need to do? I tried to just provide the default value, but it wouldn't 
accept it, complaining that it was invalid Python (as it is). *Do I need to 
select the existing rows from the database and set them all to have the 
value of the new field to the default value? If yes, how do I do this most 
efficiently (in code)?*

Best,
Mislav

Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:

> just FYI...
>
> You didn't have to delete the db.sqllite3 file rather would have followed 
> on-screen direction and provided a default value to persist in the existing 
> records in your database. Later you could have edited the info through your 
> program and make correction.
>
> This is pretty normal situation where we added new fields/properties in 
> our model while database has existing records. You wouldn't be able to 
> delete the database in case you are using relational database like postgres 
> or mysql.
>
> Thanks
>
> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey Danish,
>>
>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>> my project root directory and all of the *migrations* folders from all 
>> of my apps.
>>
>> Thank you for responding.
>>
>> Best,
>> Mislav
>>
>>
>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>> mailto...@gmail.com napisao je:
>>
>>> you need to give default value in email. seems few records are already 
>>> exist.
>>>
>>> else delete sqllite file and try again.
>>>
>>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
>>> wrote:
>>>
 Hey guys,

 I added an EmailField 
  
 to some of my already existing models. When I tried to run:

 *python manage.py makemigrations*

 I got the following prompt:





 *You are trying to add a non-nullable field 'email' to employee without 
 a default; we can't do that (the database needs something to populate 
 existing rows).Please select a fix: 1) Provide a one-off default now (will 
 be set on all existing rows with a null value for this column) 2) Quit, 
 and 
 let me add a default in models.pySelect an option: *

 I quit the prompt (option two). Then I went ahead and commented out the 
 new EmailField in the models I added them and I dropped all of the 
 database 
 rows in my entire database (not just the rows related to the models where 
 I 
 added the new email field; I dropped every row from every table).

 Then I uncommented the new EmailField and tried to run:

 *python manage.py makemigrations*

 again, *but I still get the prompt above*! I selected option 1 a few 
 times, but I'm not sure what I need to do. I tried to supply a value for 
 that field, but the prompt is a Python shell, so I'm not sure what I need 
 to do if I select option 1.

 *How do I fix this?*

 Best,
 Mislav


 -- 
 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 view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
  
 
 .

>>>
>>>
>>> -- 
>>> Thanks & Regards 
>>>   
>>> Regards, 
>>> Danish
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1920b7b0-a595-44e3-9c7f-2897fdb8a58bn%40googlegroups.com.


Re: Help with payment processing in django

2020-09-12 Thread coolguy
Buddy... did you design your project or you want us to design it for you... 
did you create models, views...

On Friday, September 11, 2020 at 6:52:31 AM UTC-4 shyam.ac...@gmail.com 
wrote:

>
> Hi guys, I am working on a project which offers contents  and every  
> content has a different price. i want the users to see only the overview of 
> the content, and if they want full access to the content they have to buy 
> it. If anyone here has done something like this before please let me 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e53f1a1d-fc56-49c7-a5a4-abe19f7d8fdcn%40googlegroups.com.


Re: I am getting this error while I mention all syntax properly.plz help me out.

2020-09-12 Thread coolguy
Please provide the template screen shot since error is generated from 
there... also send separate screen so its viewable.  

On Saturday, September 12, 2020 at 4:35:10 AM UTC-4 yashlan...@gmail.com 
wrote:

> [image: 5.PNG]
> [image: 6.PNG]
> [image: 7.PNG]
> [image: 8.PNG]
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6398f41f-8fd2-4212-9cca-830d3b2107ecn%40googlegroups.com.


Re: I am getting this error while I mention all syntax properly.plz help me out.

2020-09-12 Thread coolguy
Please provide the template screen shot since error is generated from 
there... also send separate screen so i viewable.

On Saturday, September 12, 2020 at 4:35:10 AM UTC-4 yashlan...@gmail.com 
wrote:

> [image: 5.PNG]
> [image: 6.PNG]
> [image: 7.PNG]
> [image: 8.PNG]
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/49719626-a3dd-4683-b984-5acd20b899c8n%40googlegroups.com.


Re: Environment Variables for Django Secret Key etc On Windows 10 and Heroku

2020-09-12 Thread dum dum
Yes, I've seen so many tutorials. I did the same thing, and didn't work.
I believe there is something wrong with my Django Project. I don't know
what it is.
Still tinkering.


On Sat, Sep 12, 2020 at 9:38 PM Mbah Victor 
wrote:

> Have you try googling your problem
>
> Victor
>
> On Sat, Sep 12, 2020, 9:34 AM dum dum  wrote:
>
>> I tried to put my Django Secret Key in Environment Variables.
>>
>> SECRET_KEY = os.environ.get('SECRET_KEY')
>>
>> I did save the SECRET_KEY on env var windows 10 like this
>> [image: image.png]
>>
>>
>> When I tried to py manage.py runserver, I got this error
>>
>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not 
>> be empty.
>>
>> I followed this
>>
>> https://stackoverflow.com/questions/19681102/my-django-secret-key-is-in-an-environment-variable-but-i-cant-do-syncdb
>>
>> But no idea with the solution..
>>
>> At this point, strange thing even occurred, I tried to py manage.py
>> without any SECRET_KEY on my Env Var on windows 10, and just leaving
>>   SECRET_KEY = os.environ.get('SECRET_KEY')
>> in my settings.py.
>>
>> I got no error.
>>
>> Strange.. But when I deployed it on heroku, it says the same error like
>> this
>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
>> not be empty.
>>
>> Is anyone here experienced the same stuck like me? Please kindly advise.
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANV3w%3DYdb3SuiC7KYrkN4bfieQx-fQxhm%2BPeMLpxJDWubVbwyA%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANTsAyc%3D%3DBLN7a0_c8rYd%3DsLHyWq78CHxAQr6Sa_PMcqtP7Cwg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3DYKsvpwWKd9co2TYWgv3jYcQmhSV3A_L9%3DZVFiT65L6Zw%40mail.gmail.com.


Re: I am getting this error while I click on comment button which i mention in line 51 in html file.

2020-09-12 Thread coolguy
Can't see the line number in your provided screens.
However, i can see you have additional id id={{ i.id }}added to your button 
line. (remove it)
You have already provided the id in href="{% url 'userpage:post_detail' 
i.id %}" attribute.

On Saturday, September 12, 2020 at 4:34:10 AM UTC-4 yashlan...@gmail.com 
wrote:

> [image: 1..PNG]
> [image: 2.PNG]
> [image: 3.PNG]
> [image: 4.PNG]
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14828234-3ffe-4045-9e96-e4b15be0d6d6n%40googlegroups.com.


Re: Installation errors

2020-09-12 Thread Mohammad Ahshan Danish
*trying using virtual env*
*>pipenv install*
*>pipenv shell*
*>pipenv install django*

On Sat, Sep 12, 2020 at 8:07 PM Odeyale Kehinde  wrote:

> I want to install Django on my system but getting these errors.
>
> C:\Users\odeya>pip install Django==3.1.1
> Collecting Django==3.1.1
>   Downloading
> https://files.pythonhosted.org/packages/01/a5/fb3dad18422fcd4241d18460a1fe17542bfdeadcf74e3861d1a2dfc9e459/Django-3.1.1-py3-none-any.whl
> (7.8MB)
>  |██▌ | 1.6MB 37kB/s eta 0:02:49ERROR:
> Exception:
> Traceback (most recent call last):
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line
> 397, in _error_catcher
> yield
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line
> 479, in read
> data = self._fp.read(amt)
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py",
> line 62, in read
> data = self.__fp.read(amt)
>   File "c:\program files\python38\lib\http\client.py", line 454, in read
> n = self.readinto(b)
>   File "c:\program files\python38\lib\http\client.py", line 498, in
> readinto
> n = self.fp.readinto(b)
>   File "c:\program files\python38\lib\socket.py", line 669, in readinto
> return self._sock.recv_into(b)
>   File "c:\program files\python38\lib\ssl.py", line 1241, in recv_into
> return self.read(nbytes, buffer)
>   File "c:\program files\python38\lib\ssl.py", line 1099, in read
> return self._sslobj.read(len, buffer)
> socket.timeout: The read operation timed out
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\cli\base_command.py", line
> 188, in main
> status = self.run(options, args)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\commands\install.py", line
> 345, in run
> resolver.resolve(requirement_set)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line
> 196, in resolve
> self._resolve_one(requirement_set, req)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line
> 359, in _resolve_one
> abstract_dist = self._get_abstract_dist_for(req_to_install)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line
> 305, in _get_abstract_dist_for
> abstract_dist = self.preparer.prepare_linked_requirement(
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\operations\prepare.py", line
> 195, in prepare_linked_requirement
> unpack_url(
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 1058, in
> unpack_url
> unpack_http_url(
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 920, in
> unpack_http_url
> from_path, content_type = _download_http_url(link,
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 1152, in
> _download_http_url
> _download_url(resp, link, content_file, hashes, progress_bar)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 861, in
> _download_url
> hashes.check_against_chunks(downloaded_chunks)
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\utils\hashes.py", line 75,
> in check_against_chunks
> for chunk in chunks:
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 829, in
> written_chunks
> for chunk in chunks:
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\utils\ui.py", line 156, in
> iter
> for x in it:
>   File "c:\program
> files\python38\lib\site-packages\pip\_internal\download.py", line 794, in
> resp_read
> for chunk in resp.raw.stream(
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line
> 531, in stream
> data = self.read(amt=amt, decode_content=decode_content)
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line
> 496, in read
> raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
>   File "c:\program files\python38\lib\contextlib.py", line 131, in __exit__
> self.gen.throw(type, value, traceback)
>   File "c:\program
> files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line
> 402, in _error_catcher
> raise ReadTimeoutError(self._pool, None, 'Read timed out.')
> pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='
> files.pythonhosted.org', port=443): Read timed out.
>
> C:\Users\odeya>
>
> --
> 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 view this discussion on the web

Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mohammad Ahshan Danish
yes it works after deletion because old records get deleted.

but better approach is to do changes in migration.py files

On Sat, Sep 12, 2020 at 8:14 PM Mislav Jurić 
wrote:

> Hey Danish,
>
> I was able to resolve the error by deleting the *db.sqlite3* file from my
> project root directory and all of the *migration* folders from all of my
> apps.
>
> Thank you for responding.
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com
> napisao je:
>
>> you need to give default value in email. seems few records are already
>> exist.
>>
>> else delete sqllite file and try again.
>>
>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić 
>> wrote:
>>
>>> Hey guys,
>>>
>>> I added an EmailField
>>> 
>>> to some of my already existing models. When I tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> I got the following prompt:
>>>
>>>
>>>
>>>
>>>
>>> *You are trying to add a non-nullable field 'email' to employee without
>>> a default; we can't do that (the database needs something to populate
>>> existing rows).Please select a fix: 1) Provide a one-off default now (will
>>> be set on all existing rows with a null value for this column) 2) Quit, and
>>> let me add a default in models.pySelect an option: *
>>>
>>> I quit the prompt (option two). Then I went ahead and commented out the
>>> new EmailField in the models I added them and I dropped all of the database
>>> rows in my entire database (not just the rows related to the models where I
>>> added the new email field; I dropped every row from every table).
>>>
>>> Then I uncommented the new EmailField and tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> again, *but I still get the prompt above*! I selected option 1 a few
>>> times, but I'm not sure what I need to do. I tried to supply a value for
>>> that field, but the prompt is a Python shell, so I'm not sure what I need
>>> to do if I select option 1.
>>>
>>> *How do I fix this?*
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Thanks & Regards
>>
>> Regards,
>> Danish
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ac5c4f4d-8b2f-469d-9e7a-260a415d4644n%40googlegroups.com
> 
> .
>


-- 
Thanks & Regards

Regards,
Danish

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPQdaF094eV_UnOOLg0N%3DktYb%3DpaBQa5nSRVbAyrxu4gNmMCAA%40mail.gmail.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
just FYI...

You didn't have to delete the db.sqllite3 file rather would have followed 
on-screen direction and provided a default value to persist in the existing 
records in your database. Later you could have edited the info through your 
program and make correction.

This is pretty normal situation where we added new fields/properties in our 
model while database has existing records. You wouldn't be able to delete 
the database in case you are using relational database like postgres or 
mysql.

Thanks

On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
wrote:

> Hey Danish,
>
> I was able to resolve the error by deleting the *db.sqlite3* file from my 
> project root directory and all of the *migrations* folders from all of my 
> apps.
>
> Thank you for responding.
>
> Best,
> Mislav
>
>
> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
> napisao je:
>
>> you need to give default value in email. seems few records are already 
>> exist.
>>
>> else delete sqllite file and try again.
>>
>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
>> wrote:
>>
>>> Hey guys,
>>>
>>> I added an EmailField 
>>>  
>>> to some of my already existing models. When I tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> I got the following prompt:
>>>
>>>
>>>
>>>
>>>
>>> *You are trying to add a non-nullable field 'email' to employee without 
>>> a default; we can't do that (the database needs something to populate 
>>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>>> be set on all existing rows with a null value for this column) 2) Quit, and 
>>> let me add a default in models.pySelect an option: *
>>>
>>> I quit the prompt (option two). Then I went ahead and commented out the 
>>> new EmailField in the models I added them and I dropped all of the database 
>>> rows in my entire database (not just the rows related to the models where I 
>>> added the new email field; I dropped every row from every table).
>>>
>>> Then I uncommented the new EmailField and tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> again, *but I still get the prompt above*! I selected option 1 a few 
>>> times, but I'm not sure what I need to do. I tried to supply a value for 
>>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>>> to do if I select option 1.
>>>
>>> *How do I fix this?*
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> -- 
>> Thanks & Regards 
>>   
>> Regards, 
>> Danish
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b280d8c4-6a4e-44bd-99d0-58d69e3b25dcn%40googlegroups.com.


Re: Installation errors

2020-09-12 Thread Kasper Laudrup

Hi Odeyale,

On 12/09/2020 16.33, Odeyale Kehinde wrote:

I want to install Django on my system but getting these errors.

socket.timeout: The read operation timed out


I assume you must have an extremely slow internet connection. Try 
increasing the timeout to the pip command as documented here:


https://pip.pypa.io/en/stable/user_guide/

E.g:

# pip install --default-timeout=120 Django-3.1.1

Kind regards,

Kasper Laudrup

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/665ad2ba-34ee-6c05-78ba-589417017530%40stacktrace.dk.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey Danish,

I was able to resolve the error by deleting the *db.sqlite3* file from my 
project root directory and all of the *migrations* folders from all of my 
apps.

Thank you for responding.

Best,
Mislav


Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  to 
>> some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee without a 
>> default; we can't do that (the database needs something to populate 
>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>> be set on all existing rows with a null value for this column) 2) Quit, and 
>> let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out the 
>> new EmailField in the models I added them and I dropped all of the database 
>> rows in my entire database (not just the rows related to the models where I 
>> added the new email field; I dropped every row from every table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e91810c3-1faa-443c-91e1-e8b4c6553b7dn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey Danish,

I was able to resolve the error by deleting the *db.sqlite3* file from my 
project root directory and all of the *migration* folders from all of my 
apps.

Thank you for responding.

Best,
Mislav

Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  to 
>> some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee without a 
>> default; we can't do that (the database needs something to populate 
>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>> be set on all existing rows with a null value for this column) 2) Quit, and 
>> let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out the 
>> new EmailField in the models I added them and I dropped all of the database 
>> rows in my entire database (not just the rows related to the models where I 
>> added the new email field; I dropped every row from every table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac5c4f4d-8b2f-469d-9e7a-260a415d4644n%40googlegroups.com.


Re: Environment Variables for Django Secret Key etc On Windows 10 and Heroku

2020-09-12 Thread Mbah Victor
Have you try googling your problem

Victor

On Sat, Sep 12, 2020, 9:34 AM dum dum  wrote:

> I tried to put my Django Secret Key in Environment Variables.
>
> SECRET_KEY = os.environ.get('SECRET_KEY')
>
> I did save the SECRET_KEY on env var windows 10 like this
> [image: image.png]
>
>
> When I tried to py manage.py runserver, I got this error
>
> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not 
> be empty.
>
> I followed this
>
> https://stackoverflow.com/questions/19681102/my-django-secret-key-is-in-an-environment-variable-but-i-cant-do-syncdb
>
> But no idea with the solution..
>
> At this point, strange thing even occurred, I tried to py manage.py
> without any SECRET_KEY on my Env Var on windows 10, and just leaving
>   SECRET_KEY = os.environ.get('SECRET_KEY')
> in my settings.py.
>
> I got no error.
>
> Strange.. But when I deployed it on heroku, it says the same error like
> this
> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
> not be empty.
>
> Is anyone here experienced the same stuck like me? Please kindly advise.
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANV3w%3DYdb3SuiC7KYrkN4bfieQx-fQxhm%2BPeMLpxJDWubVbwyA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANTsAyc%3D%3DBLN7a0_c8rYd%3DsLHyWq78CHxAQr6Sa_PMcqtP7Cwg%40mail.gmail.com.


Installation errors

2020-09-12 Thread Odeyale Kehinde
I want to install Django on my system but getting these errors.

C:\Users\odeya>pip install Django==3.1.1
Collecting Django==3.1.1
  Downloading 
https://files.pythonhosted.org/packages/01/a5/fb3dad18422fcd4241d18460a1fe17542bfdeadcf74e3861d1a2dfc9e459/Django-3.1.1-py3-none-any.whl
 
(7.8MB)
 |██▌ | 1.6MB 37kB/s eta 0:02:49ERROR: 
Exception:
Traceback (most recent call last):
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 
397, in _error_catcher
yield
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 
479, in read
data = self._fp.read(amt)
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", 
line 62, in read
data = self.__fp.read(amt)
  File "c:\program files\python38\lib\http\client.py", line 454, in read
n = self.readinto(b)
  File "c:\program files\python38\lib\http\client.py", line 498, in readinto
n = self.fp.readinto(b)
  File "c:\program files\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
  File "c:\program files\python38\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
  File "c:\program files\python38\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 
188, in main
status = self.run(options, args)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\commands\install.py", line 
345, in run
resolver.resolve(requirement_set)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line 
196, in resolve
self._resolve_one(requirement_set, req)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line 
359, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\legacy_resolve.py", line 
305, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\operations\prepare.py", line 
195, in prepare_linked_requirement
unpack_url(
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 1058, in 
unpack_url
unpack_http_url(
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 920, in 
unpack_http_url
from_path, content_type = _download_http_url(link,
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 1152, in 
_download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 861, in 
_download_url
hashes.check_against_chunks(downloaded_chunks)
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\utils\hashes.py", line 75, 
in check_against_chunks
for chunk in chunks:
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 829, in 
written_chunks
for chunk in chunks:
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\utils\ui.py", line 156, in 
iter
for x in it:
  File "c:\program 
files\python38\lib\site-packages\pip\_internal\download.py", line 794, in 
resp_read
for chunk in resp.raw.stream(
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 
531, in stream
data = self.read(amt=amt, decode_content=decode_content)
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 
496, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "c:\program files\python38\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
  File "c:\program 
files\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 
402, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: 
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed 
out.

C:\Users\odeya>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9718df4b-9264-4c7e-af96-f4df56ecd05bn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mohammad Ahshan Danish
you need to give default value in email. seems few records are already
exist.

else delete sqllite file and try again.

On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić 
wrote:

> Hey guys,
>
> I added an EmailField
>  to
> some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee without a
> default; we can't do that (the database needs something to populate
> existing rows).Please select a fix: 1) Provide a one-off default now (will
> be set on all existing rows with a null value for this column) 2) Quit, and
> let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out the
> new EmailField in the models I added them and I dropped all of the database
> rows in my entire database (not just the rows related to the models where I
> added the new email field; I dropped every row from every table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few
> times, but I'm not sure what I need to do. I tried to supply a value for
> that field, but the prompt is a Python shell, so I'm not sure what I need
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
> 
> .
>


-- 
Thanks & Regards

Regards,
Danish

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPQdaF14z3tAGNDKsk5HYNDG4v%3DpZv6fHbSpC5AtyDdhwzR9zQ%40mail.gmail.com.


I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey guys,

I added an EmailField
 to
some of my already existing models. When I tried to run:

*python manage.py makemigrations*

I got the following prompt:





*You are trying to add a non-nullable field 'email' to employee without a
default; we can't do that (the database needs something to populate
existing rows).Please select a fix: 1) Provide a one-off default now (will
be set on all existing rows with a null value for this column) 2) Quit, and
let me add a default in models.pySelect an option: *

I quit the prompt (option two). Then I went ahead and commented out the new
EmailField in the models I added them and I dropped all of the database
rows in my entire database (not just the rows related to the models where I
added the new email field; I dropped every row from every table).

Then I uncommented the new EmailField and tried to run:

*python manage.py makemigrations*

again, *but I still get the prompt above*! I selected option 1 a few times,
but I'm not sure what I need to do. I tried to supply a value for that
field, but the prompt is a Python shell, so I'm not sure what I need to do
if I select option 1.

*How do I fix this?*

Best,
Mislav

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com.


Re: 404 error

2020-09-12 Thread Spyke Lionel
yes I did. it should work properly.
I just wanna display a list of items after the link has been clicked.
But it happens that I get http://127.0.0.1:8000/music//
The last forward slash shouldn't have added.
This work when the integer is inserted manually on the address.
http://127.0.0.1:8000/music/2/
But I want it to happen this way when a link is clicked

On Sat, Sep 12, 2020, 9:55 AM Kunal Solanke 
wrote:

> Did you try what I told?
>
> On Sat, Sep 12, 2020, 14:05 Spyke Lionel  wrote:
>
>> I don't understand how the url became
>> http://127.0.0.1:8000/music//
>> Instead of http://127.0.0.1:8000/music//
>>
>>
>> On Sat, Sep 12, 2020, 8:29 AM 'Amitesh Sahay' via Django users <
>> django-users@googlegroups.com> wrote:
>>
>>> You are trying "http://127.0.0.1:8000/music//";
>>> 
>>>
>>> try something like
>>>
>>> http://127.0.0.1:8000//
>>>
>>> Regards,
>>> Amitesh
>>>
>>>
>>> On Saturday, 12 September, 2020, 12:55:57 pm IST, Kunal Solanke <
>>> kunalsolanke1...@gmail.com> wrote:
>>>
>>>
>>> I think he have created the music url,
>>> But the {{album_id}} is not properly passed as context from view.
>>>
>>>
>>> On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users <
>>> django-users@googlegroups.com> wrote:
>>>
>>> At the first glance, I think you havn't created URL pattern for "music".
>>> May bejust saying.
>>>
>>> Regards,
>>> Amitesh
>>>
>>>
>>> On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel <
>>> ndilion...@gmail.com> wrote:
>>>
>>>
>>> I have this urlpatterns..
>>>
>>> urlpatterns = [
>>> path('', views.index, name='index'),
>>> path('/', views.detail, name='detail'),
>>> ]
>>>
>>> my index.html looks like this
>>>
>>> Albums to display
>>> 
>>> {% for album in all_albums %}
>>>  {{ album.album_title
>>> }}
>>> {% endfor %}
>>> 
>>> #my index.html simply displays my albums. and the above works just fine
>>>
>>> my detail.html looks like this
>>>
>>> {{ album }}
>>> #and it works just fine too
>>>
>>> my views.py looks like this
>>>
>>> def index(request):
>>> all_albums = Album.objects.all()
>>> return render(request, 'music/index.html', {'all_albums':
>>> all_albums})
>>>
>>> def detail(request, album_id):
>>> try:
>>> album = Album.objects.get(pk=album_id)
>>> except Album.DoesNotExist:
>>> raise Http404("Album does not exist")
>>> return render(request, 'music/detail.html', {'album': album})
>>>
>>> #when ever I click on an album link to get the album details, I get the
>>> 404 below:
>>>
>>> Page not found (404)
>>> Request Method: GET
>>> Request URL: http://127.0.0.1:8000/music//
>>>
>>> Using the URLconf defined in website.urls, Django tried these URL
>>> patterns, in this order:
>>> 1. admin/
>>> 2. music/ [name='index']
>>> 3. music/ / [name='detail']
>>> The current path, music//, didn't match any of these.
>>>
>>> in my detail funtion in views.py, at first I used on request as an
>>> argument and it worked just fine to give me the album details (which
>>> returned only the album id number), but when i added album_id, so as to get
>>> the album details, I got an error. saying music// not found. Now I don't
>>> understand how the last forward slash(/) was added.
>>> can I get the explaination to 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com
>>> 
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com
>>> 
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOecAnyAVZf16m20HGu0KQp8_yrS9kzB8pfkMMyf55Y3tJY0xQ%40mail.gmail.com
>>> 
>>> .
>>>
>>> --
>>> You received this message 

Re: 404 error

2020-09-12 Thread Kunal Solanke
Did you try what I told?

On Sat, Sep 12, 2020, 14:05 Spyke Lionel  wrote:

> I don't understand how the url became
> http://127.0.0.1:8000/music//
> Instead of http://127.0.0.1:8000/music//
>
>
> On Sat, Sep 12, 2020, 8:29 AM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> You are trying "http://127.0.0.1:8000/music//";
>> 
>>
>> try something like
>>
>> http://127.0.0.1:8000//
>>
>> Regards,
>> Amitesh
>>
>>
>> On Saturday, 12 September, 2020, 12:55:57 pm IST, Kunal Solanke <
>> kunalsolanke1...@gmail.com> wrote:
>>
>>
>> I think he have created the music url,
>> But the {{album_id}} is not properly passed as context from view.
>>
>>
>> On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users <
>> django-users@googlegroups.com> wrote:
>>
>> At the first glance, I think you havn't created URL pattern for "music".
>> May bejust saying.
>>
>> Regards,
>> Amitesh
>>
>>
>> On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel <
>> ndilion...@gmail.com> wrote:
>>
>>
>> I have this urlpatterns..
>>
>> urlpatterns = [
>> path('', views.index, name='index'),
>> path('/', views.detail, name='detail'),
>> ]
>>
>> my index.html looks like this
>>
>> Albums to display
>> 
>> {% for album in all_albums %}
>>  {{ album.album_title }}
>> {% endfor %}
>> 
>> #my index.html simply displays my albums. and the above works just fine
>>
>> my detail.html looks like this
>>
>> {{ album }}
>> #and it works just fine too
>>
>> my views.py looks like this
>>
>> def index(request):
>> all_albums = Album.objects.all()
>> return render(request, 'music/index.html', {'all_albums': all_albums})
>>
>> def detail(request, album_id):
>> try:
>> album = Album.objects.get(pk=album_id)
>> except Album.DoesNotExist:
>> raise Http404("Album does not exist")
>> return render(request, 'music/detail.html', {'album': album})
>>
>> #when ever I click on an album link to get the album details, I get the
>> 404 below:
>>
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/music//
>>
>> Using the URLconf defined in website.urls, Django tried these URL
>> patterns, in this order:
>> 1. admin/
>> 2. music/ [name='index']
>> 3. music/ / [name='detail']
>> The current path, music//, didn't match any of these.
>>
>> in my detail funtion in views.py, at first I used on request as an
>> argument and it worked just fine to give me the album details (which
>> returned only the album id number), but when i added album_id, so as to get
>> the album details, I got an error. saying music// not found. Now I don't
>> understand how the last forward slash(/) was added.
>> can I get the explaination to 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAOecAnyAVZf16m20HGu0KQp8_yrS9kzB8pfkMMyf55Y3tJY0xQ%40mail.gmail.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/1325467128.1082007.1599895682642%40mail.yahoo.com
>> 
>> .
>>
> --
> You received this message because you are subscribed t

Re: 404 error

2020-09-12 Thread Spyke Lionel
I don't understand how the url became
http://127.0.0.1:8000/music//
Instead of http://127.0.0.1:8000/music//


On Sat, Sep 12, 2020, 8:29 AM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> You are trying "http://127.0.0.1:8000/music//";
> 
>
> try something like
>
> http://127.0.0.1:8000//
>
> Regards,
> Amitesh
>
>
> On Saturday, 12 September, 2020, 12:55:57 pm IST, Kunal Solanke <
> kunalsolanke1...@gmail.com> wrote:
>
>
> I think he have created the music url,
> But the {{album_id}} is not properly passed as context from view.
>
>
> On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
> At the first glance, I think you havn't created URL pattern for "music".
> May bejust saying.
>
> Regards,
> Amitesh
>
>
> On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel <
> ndilion...@gmail.com> wrote:
>
>
> I have this urlpatterns..
>
> urlpatterns = [
> path('', views.index, name='index'),
> path('/', views.detail, name='detail'),
> ]
>
> my index.html looks like this
>
> Albums to display
> 
> {% for album in all_albums %}
>  {{ album.album_title }}
> {% endfor %}
> 
> #my index.html simply displays my albums. and the above works just fine
>
> my detail.html looks like this
>
> {{ album }}
> #and it works just fine too
>
> my views.py looks like this
>
> def index(request):
> all_albums = Album.objects.all()
> return render(request, 'music/index.html', {'all_albums': all_albums})
>
> def detail(request, album_id):
> try:
> album = Album.objects.get(pk=album_id)
> except Album.DoesNotExist:
> raise Http404("Album does not exist")
> return render(request, 'music/detail.html', {'album': album})
>
> #when ever I click on an album link to get the album details, I get the
> 404 below:
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/music//
>
> Using the URLconf defined in website.urls, Django tried these URL
> patterns, in this order:
> 1. admin/
> 2. music/ [name='index']
> 3. music/ / [name='detail']
> The current path, music//, didn't match any of these.
>
> in my detail funtion in views.py, at first I used on request as an
> argument and it worked just fine to give me the album details (which
> returned only the album id number), but when i added album_id, so as to get
> the album details, I got an error. saying music// not found. Now I don't
> understand how the last forward slash(/) was added.
> can I get the explaination to 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOecAnyAVZf16m20HGu0KQp8_yrS9kzB8pfkMMyf55Y3tJY0xQ%40mail.gmail.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1325467128.1082007.1599895682642%40mail.yahoo.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://

Environment Variables for Django Secret Key etc On Windows 10 and Heroku

2020-09-12 Thread dum dum
I tried to put my Django Secret Key in Environment Variables.

SECRET_KEY = os.environ.get('SECRET_KEY')

I did save the SECRET_KEY on env var windows 10 like this
[image: image.png]


When I tried to py manage.py runserver, I got this error

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting
must not be empty.

I followed this
https://stackoverflow.com/questions/19681102/my-django-secret-key-is-in-an-environment-variable-but-i-cant-do-syncdb

But no idea with the solution..

At this point, strange thing even occurred, I tried to py manage.py without
any SECRET_KEY on my Env Var on windows 10, and just leaving
  SECRET_KEY = os.environ.get('SECRET_KEY')
in my settings.py.

I got no error.

Strange.. But when I deployed it on heroku, it says the same error like
this
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not
be empty.

Is anyone here experienced the same stuck like me? Please kindly advise.
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3DYdb3SuiC7KYrkN4bfieQx-fQxhm%2BPeMLpxJDWubVbwyA%40mail.gmail.com.


Re: 404 error

2020-09-12 Thread 'Amitesh Sahay' via Django users
You are trying "http://127.0.0.1:8000/music//";
try something like
http://127.0.0.1:8000//



Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:55:57 pm IST, Kunal Solanke 
 wrote:  
 
 I think he have created the music url,But the {{album_id}} is not properly 
passed as context from view.

On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users 
 wrote:

At the first glance, I think you havn't created URL pattern for "music". May 
bejust saying.


Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel 
 wrote:  
 
 I have this urlpatterns..
urlpatterns = [    path('', views.index, name='index'),    
path('/', views.detail, name='detail'),]
my index.html looks like this
Albums to display    {% for album in all_albums %}     {{ album.album_title }}    {% endfor 
%}#my index.html simply displays my albums. and the above works just fine
my detail.html looks like this
{{ album }}#and it works just fine too
my views.py looks like this
def index(request):    all_albums = Album.objects.all()    return 
render(request, 'music/index.html', {'all_albums': all_albums})
def detail(request, album_id):    try:        album = 
Album.objects.get(pk=album_id)    except Album.DoesNotExist:        raise 
Http404("Album does not exist")    return render(request, 'music/detail.html', 
{'album': album})
#when ever I click on an album link to get the album details, I get the 404 
below:
Page not found (404)Request Method: GETRequest URL: 
http://127.0.0.1:8000/music//
Using the URLconf defined in website.urls, Django tried these URL patterns, in 
this order:1. admin/2. music/ [name='index']3. music/ / 
[name='detail']The current path, music//, didn't match any of these.
in my detail funtion in views.py, at first I used on request as an argument and 
it worked just fine to give me the album details (which returned only the album 
id number), but when i added album_id, so as to get the album details, I got an 
error. saying music// not found. Now I don't understand how the last forward 
slash(/) was added.can I get the explaination to 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com.
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com.



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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1325467128.1082007.1599895682642%40mail.yahoo.com.


Re: 404 error

2020-09-12 Thread Kunal Solanke
In your template it should be {{album.id}}
or {{album.album_id}} depending how your models are.I am talling about href
in anchor tag.

On Sat, Sep 12, 2020, 12:54 Kunal Solanke 
wrote:

> I think he have created the music url,
> But the {{album_id}} is not properly passed as context from view.
>
>
> On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> At the first glance, I think you havn't created URL pattern for "music".
>> May bejust saying.
>>
>> Regards,
>> Amitesh
>>
>>
>> On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel <
>> ndilion...@gmail.com> wrote:
>>
>>
>> I have this urlpatterns..
>>
>> urlpatterns = [
>> path('', views.index, name='index'),
>> path('/', views.detail, name='detail'),
>> ]
>>
>> my index.html looks like this
>>
>> Albums to display
>> 
>> {% for album in all_albums %}
>>  {{ album.album_title }}
>> {% endfor %}
>> 
>> #my index.html simply displays my albums. and the above works just fine
>>
>> my detail.html looks like this
>>
>> {{ album }}
>> #and it works just fine too
>>
>> my views.py looks like this
>>
>> def index(request):
>> all_albums = Album.objects.all()
>> return render(request, 'music/index.html', {'all_albums': all_albums})
>>
>> def detail(request, album_id):
>> try:
>> album = Album.objects.get(pk=album_id)
>> except Album.DoesNotExist:
>> raise Http404("Album does not exist")
>> return render(request, 'music/detail.html', {'album': album})
>>
>> #when ever I click on an album link to get the album details, I get the
>> 404 below:
>>
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/music//
>>
>> Using the URLconf defined in website.urls, Django tried these URL
>> patterns, in this order:
>> 1. admin/
>> 2. music/ [name='index']
>> 3. music/ / [name='detail']
>> The current path, music//, didn't match any of these.
>>
>> in my detail funtion in views.py, at first I used on request as an
>> argument and it worked just fine to give me the album details (which
>> returned only the album id number), but when i added album_id, so as to get
>> the album details, I got an error. saying music// not found. Now I don't
>> understand how the last forward slash(/) was added.
>> can I get the explaination to 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com
>> 
>> .
>>
>

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


Re: 404 error

2020-09-12 Thread Kunal Solanke
I think he have created the music url,
But the {{album_id}} is not properly passed as context from view.


On Sat, Sep 12, 2020, 12:52 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> At the first glance, I think you havn't created URL pattern for "music".
> May bejust saying.
>
> Regards,
> Amitesh
>
>
> On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel <
> ndilion...@gmail.com> wrote:
>
>
> I have this urlpatterns..
>
> urlpatterns = [
> path('', views.index, name='index'),
> path('/', views.detail, name='detail'),
> ]
>
> my index.html looks like this
>
> Albums to display
> 
> {% for album in all_albums %}
>  {{ album.album_title }}
> {% endfor %}
> 
> #my index.html simply displays my albums. and the above works just fine
>
> my detail.html looks like this
>
> {{ album }}
> #and it works just fine too
>
> my views.py looks like this
>
> def index(request):
> all_albums = Album.objects.all()
> return render(request, 'music/index.html', {'all_albums': all_albums})
>
> def detail(request, album_id):
> try:
> album = Album.objects.get(pk=album_id)
> except Album.DoesNotExist:
> raise Http404("Album does not exist")
> return render(request, 'music/detail.html', {'album': album})
>
> #when ever I click on an album link to get the album details, I get the
> 404 below:
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/music//
>
> Using the URLconf defined in website.urls, Django tried these URL
> patterns, in this order:
> 1. admin/
> 2. music/ [name='index']
> 3. music/ / [name='detail']
> The current path, music//, didn't match any of these.
>
> in my detail funtion in views.py, at first I used on request as an
> argument and it worked just fine to give me the album details (which
> returned only the album id number), but when i added album_id, so as to get
> the album details, I got an error. saying music// not found. Now I don't
> understand how the last forward slash(/) was added.
> can I get the explaination to 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com
> 
> .
>

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


Re: 404 error

2020-09-12 Thread 'Amitesh Sahay' via Django users
At the first glance, I think you havn't created URL pattern for "music". May 
bejust saying.


Regards,
Amitesh  

On Saturday, 12 September, 2020, 12:47:56 pm IST, Spyke Lionel 
 wrote:  
 
 I have this urlpatterns..
urlpatterns = [    path('', views.index, name='index'),    
path('/', views.detail, name='detail'),]
my index.html looks like this
Albums to display    {% for album in all_albums %}     {{ album.album_title }}    {% endfor 
%}#my index.html simply displays my albums. and the above works just fine
my detail.html looks like this
{{ album }}#and it works just fine too
my views.py looks like this
def index(request):    all_albums = Album.objects.all()    return 
render(request, 'music/index.html', {'all_albums': all_albums})
def detail(request, album_id):    try:        album = 
Album.objects.get(pk=album_id)    except Album.DoesNotExist:        raise 
Http404("Album does not exist")    return render(request, 'music/detail.html', 
{'album': album})
#when ever I click on an album link to get the album details, I get the 404 
below:
Page not found (404)Request Method: GETRequest URL: 
http://127.0.0.1:8000/music//
Using the URLconf defined in website.urls, Django tried these URL patterns, in 
this order:1. admin/2. music/ [name='index']3. music/ / 
[name='detail']The current path, music//, didn't match any of these.
in my detail funtion in views.py, at first I used on request as an argument and 
it worked just fine to give me the album details (which returned only the album 
id number), but when i added album_id, so as to get the album details, I got an 
error. saying music// not found. Now I don't understand how the last forward 
slash(/) was added.can I get the explaination to 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com.
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/230500518.1084108.1599895276220%40mail.yahoo.com.


404 error

2020-09-12 Thread Spyke Lionel
I have this urlpatterns..

urlpatterns = [
path('', views.index, name='index'),
path('/', views.detail, name='detail'),
]

my index.html looks like this

Albums to display

{% for album in all_albums %}
 {{ album.album_title }}
{% endfor %}

#my index.html simply displays my albums. and the above works just fine

my detail.html looks like this

{{ album }}
#and it works just fine too

my views.py looks like this

def index(request):
all_albums = Album.objects.all()
return render(request, 'music/index.html', {'all_albums': all_albums})

def detail(request, album_id):
try:
album = Album.objects.get(pk=album_id)
except Album.DoesNotExist:
raise Http404("Album does not exist")
return render(request, 'music/detail.html', {'album': album})

#when ever I click on an album link to get the album details, I get the 404 
below:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/music//

Using the URLconf defined in website.urls, Django tried these URL patterns, 
in this order:
1. admin/
2. music/ [name='index']
3. music/ / [name='detail']
The current path, music//, didn't match any of these.

in my detail funtion in views.py, at first I used on request as an argument 
and it worked just fine to give me the album details (which returned only 
the album id number), but when i added album_id, so as to get the album 
details, I got an error. saying music// not found. Now I don't understand 
how the last forward slash(/) was added.
can I get the explaination to 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/36d25ae2-7e58-43dc-ad0f-83da9e55e526n%40googlegroups.com.