Re: table bank_app_bank has no column named DOB

2023-08-19 Thread Joe Reitman
You can not use all caps as a field name. Some other restrictions are:

   - A field name cannot be a Python reserved word.
   - A field name cannot contain more than one underscore in a row.
   - A field name cannot start with an underscore.



On Friday, August 18, 2023 at 2:05:57 PM UTC-5 meenu loranz wrote:

> from django.contrib.auth.models import User
> from django.db import models
> from django.urls import reverse
> # Create your models here.
>
> class bank(models.Model):
> name = models.CharField(max_length=255)
> DOB = models.DateField()
> age = models.IntegerField()
> gender = models.CharField(max_length=10)
> phone_no = models.CharField(max_length=10)
> mail_id = models.EmailField(max_length=25)
> address = models.CharField(max_length=255)
> district = models.CharField(max_length=100)
> branch = models.CharField(max_length=100)
> account_type = models.CharField(max_length=100)
> # materials_provided = models.CharField(max_length=100)
>
>
> def __str__(self):
> return self.name
>
> This is my model.py page. And i can see this table and all fields in my 
> database. But while running show me the operational error that no column 
> named DOB. How can i fix this?
>
>

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


Re: President of India: Save Nallamala Forest from Uranium Mining @rashtrapatibhvn @TelanganaCMO

2019-09-15 Thread Joe Reitman
I flagged this as spam. This is a Django forum. 

On Friday, September 13, 2019 at 11:11:10 PM UTC-5, pardhu.s...@gmail.com 
wrote:
>
> Hey,
>
> I just signed the petition "President of India: Save Nallamala Forest from 
> Uranium Mining @rashtrapatibhvn @TelanganaCMO" and wanted to see if you 
> could help by adding your name.
>
> Our goal is to reach 75,000 signatures and we need more support. You can 
> read more and sign the petition here:
>
> http://chng.it/RwqnqjH5V6
>
> Thanks!
> Partha 

-- 
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/0200650b-5d01-4bf4-9fe7-5372110773dc%40googlegroups.com.


Re: How to change the label for username to 'username/email' in login page in Django

2019-08-30 Thread Joe Reitman
You can use a label or help text. 

https://docs.djangoproject.com/en/2.2/ref/forms/fields/#label
https://docs.djangoproject.com/en/2.2/ref/forms/fields/#help-text



On Friday, August 30, 2019 at 12:28:47 PM UTC-5, Sandip Nath wrote:
>
> I am building a car rental website with Django. Currently working on user 
> authentication.The user can either use his/her username/email and password 
> to login.It's working fine. My question is, how will I change the label for 
> username field to "username/email" so that the user can understand that 
> either username or email can be entered. I cannot  make changes in the 
> login.html template because I have used there {{ form.as_p }} tag and the 
> concerned portion in my forms.py file has:
>
> class LoginForm(forms.Form):
> username = forms.CharField()
> password = forms.CharField(widget=forms.PasswordInput)
>
> I am not able to understand where to make changes. Please help.
>

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


Re: I think I've found a bug in the Dev server

2019-08-02 Thread Joe Reitman
Anyway. If you think there is a bug, you should visit the Django github 
community and raise the issue there.

On Thursday, August 1, 2019 at 10:00:29 AM UTC-7, Isaac Way wrote:
>
> If I send a request to an invalid URL, the NEXT request sent to that URL 
> is processed incorrectly by Django. I've ruled out any client side 
> shenanigans
>
> I've detailed it in a stack overflow question: 
> https://stackoverflow.com/questions/57313270/django-dev-server-processing-the-same-ajax-request-inconsistently
>

-- 
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/496dd70c-1817-4cd5-b36e-431b23c3a424%40googlegroups.com.


Re: I think I've found a bug in the Dev server

2019-08-02 Thread Joe Reitman
Have you tested it with a production server? The dev server is for testing 
not suitable for production.

On Thursday, August 1, 2019 at 10:00:29 AM UTC-7, Isaac Way wrote:
>
> If I send a request to an invalid URL, the NEXT request sent to that URL 
> is processed incorrectly by Django. I've ruled out any client side 
> shenanigans
>
> I've detailed it in a stack overflow question: 
> https://stackoverflow.com/questions/57313270/django-dev-server-processing-the-same-ajax-request-inconsistently
>

-- 
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/3a81f2c7-c16c-4b21-924a-e9f700ef4a8f%40googlegroups.com.


Re: SQLite 3.8.3 or later is required (found 3.7.17).

2019-07-20 Thread Joe Reitman
I had the same problem. To fix it I used Python 3.6 and Django 2.1. 


On Friday, July 19, 2019 at 7:37:06 AM UTC-5, Anchal Agarwal wrote:
>
> Hello Django users,
> i am trying to deploy my django on AWS 
> I am following this 
> https://medium.com/@charlesthk/deploy-nginx-django-uwsgi-on-aws-ec2-amazon-linux-517a683163c6
> Everything was going right but when i run python manage.py migrate , it's 
> giving me this error
> django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is 
> required (found 3.7.17).
> how can i resolve this?
> Please help me 
>

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


Re: how to see the list of created tables in sqlite

2019-07-18 Thread Joe Reitman
A good way to view your tables is to use https://sqlitebrowser.org/

On Thursday, July 18, 2019 at 8:28:31 AM UTC-5, yasar arafath Kajamydeen 
wrote:
>
> Hi all,
>
> After executing the  command  -  python manage.py migrate
> the command is successful and then i would like to see the list of created 
> tables so  i enter command like  .schema  but it showing error.
>
> Please try to help me .
>
> Note - Am beginer to python 
>
>

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


Re: python manage.py runserver error

2019-07-13 Thread Joe Reitman
ModuleNotFoundError: No module named 'hello_world'

This is a big clue. 

On Saturday, July 13, 2019 at 6:35:31 AM UTC-5, Jack Bergemann wrote:
>
> (venv) C:\Users\Chas\rp-portfolio\personal_portfolio>python manage.py 
> runserver
> Watching for file changes with StatReloader
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File "C:\Python37\lib\threading.py", line 926, in _bootstrap_inner
> self.run()
>   File "C:\Python37\lib\threading.py", line 870, in run
> self._target(*self._args, **self._kwargs)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 54, in wrapper
> fn(*args, **kwargs)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 109, in inner_run
> autoreload.raise_last_exception()
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 77, in raise_last_exception
> raise _exception[1]
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
>  
> line 337, in execute
> autoreload.check_errors(django.setup)()
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 54, in wrapper
> fn(*args, **kwargs)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\__init__.py", 
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\apps\registry.py", 
> line 91, in populate
> app_config = AppConfig.create(entry)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\apps\config.py", 
> line 90, in create
> module = import_module(entry)
>   File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 965, in 
> _find_and_load_unlocked
> ModuleNotFoundError: No module named 'hello_world'
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
>  
> line 381, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
>  
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\base.py",
>  
> line 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 60, in execute
> super().execute(*args, **options)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\base.py",
>  
> line 364, in execute
> output = self.handle(*args, **options)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 95, in handle
> self.run(**options)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 102, in run
> autoreload.run_with_reloader(self.inner_run, **options)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 587, in run_with_reloader
> start_django(reloader, main_func, *args, **kwargs)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 572, in start_django
> reloader.run(django_main_thread)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 290, in run
> self.run_loop()
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 296, in run_loop
> next(ticker)
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 336, in tick
> for filepath, mtime in self.snapshot_files():
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 352, in snapshot_files
> for file in self.watched_files():
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 251, in watched_files
> yield from iter_all_python_module_files()
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 103, in iter_all_python_module_files
> return iter_modules_and_files(modules, frozenset(_error_files))
>   File 
> "C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py",
>  
> line 138, in iter_modules_and_files

Re: Followed 'Writing custom django-admin commands' - 'Apps aren't loaded yet.'!

2019-07-13 Thread Joe Reitman
Try following this tutorial:
https://simpleisbetterthancomplex.com/tutorial/2018/08/27/how-to-create-custom-django-management-commands.html

It looks like you don't have apps registered in INSTALLED APPS. Also, I 
always use the 'python manage.py ' not the 'django-admin 
'

On Thursday, July 11, 2019 at 3:15:39 PM UTC-5, paul_d...@hotmail.com wrote:
>
> I've got a basic Django site up and running and am now trying to write a 
> custom command by following the "Writing custom django-admin commands" 
> documentation.  However having followed it carefully I get this exception:
>
> (myfrontier) C:\Users\PDS\git\myfrontier>set 
> DJANGO_SETTINGS_MODULE=myfrontier.settings
>
> (myfrontier) C:\Users\PDS\git\myfrontier>django-admin podcasts
> Traceback (most recent call last):
>   File "C:\virtualenv\myfrontier\Scripts\django-admin-script.py", line 11, 
> in 
> load_entry_point('Django', 'console_scripts', 'django-admin')()
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\core\management\__init__.py",
>  
> line 381, in execute_from_command_line
> utility.execute()
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\core\management\__init__.py",
>  
> line 357, in execute
> django.setup()
>   File "C:\virtualenv\myfrontier\lib\site-packages\django\__init__.py", 
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
> 91, in populate
> app_config = AppConfig.create(entry)
>   File "C:\virtualenv\myfrontier\lib\site-packages\django\apps\config.py", 
> line 90, in create
> module = import_module(entry)
>   File "C:\virtualenv\myfrontier\lib\importlib\__init__.py", line 126, in 
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in 
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in 
> _call_with_frames_removed
>   File "c:\users\pds\git\myfrontier\portal\management\podcasts.py", line 
> 2, in 
> from portal.models import ShowEpisode
>   File "c:\users\pds\git\myfrontier\portal\models.py", line 4, in 
> class Dir(models.Model):
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\db\models\base.py", line 
> 103, in __new__
> app_config = apps.get_containing_app_config(module)
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
> 252, in get_containing_app_config
> self.check_apps_ready()
>   File 
> "C:\virtualenv\myfrontier\lib\site-packages\django\apps\registry.py", line 
> 135, in check_apps_ready
> raise AppRegistryNotReady("Apps aren't loaded yet.")
> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>
> The first two lines of my custom command are just like the example in the 
> doc...
> from django.core.management.base import BaseCommand, CommandError
> from portal.models import ShowEpisode
>
> So what am I doing wrong?  Is the documentation just wrong?  A quick 
> Google throws up lots of suggestions and a number of people hitting this so 
> can someone from Django dev. give some proper chapter and verse on how to 
> solve this please?
>
> thanks,
> Paul DS
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ae0fca5-1f57-457b-a90b-6ca4e2b7b668%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DeprecationWarning in Django 1.11.22 with Python 3.7

2019-07-08 Thread Joe Reitman
Looks like a bug in pyparsing.py

https://github.com/pyparsing/pyparsing/pull/16

On Monday, July 8, 2019 at 1:09:16 PM UTC-5, Uri Even-Chen wrote:
>
> Hi,
>
> I tested Django 1.11.22 (or any version from 1.11.17 to 1.11.22) with 
> Python 3.7, and found out that when running tests with deprecation warnings 
> enabled, I receive the following error:
>
> DeprecationWarning: Using or importing the ABCs from 'collections' instead 
> of from 'collections.abc' is deprecated, and in 3.8 it will stop working
>
> Is this known that Django 1.11 doesn't work with Python 3.7 
> with deprecation warnings enabled? Does this problem exist with other 
> versions of Django too?
>
> By the way, running tests without deprecation warnings enabled works (the 
> tests pass).
>
> אורי
> u...@speedy.net 
>

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


Re: Django Interview Questions

2019-07-08 Thread Joe Reitman
Error 522 Ray ID: 4f324c909f05d29a • 2019-07-08 13:11:05 UTCConnection 
timed out
On Monday, November 2, 2009 at 9:36:41 AM UTC-6, Dimitri Gnidash wrote:
>
> Hey guys, 
>
> For all those of you interviewing or being interviewed, I created a 
> quick list of sample interview questions. 
> While not comprehensive, it is a good start to review these before the 
> interview, if anything, to gain a perspective on how other people 
> might be using Django. 
>
>
> http://blog.lightsonsoftware.com/django-interview-questions-0 
>
>
> Dimitri Gnidash 
> www.lightsonsoftware.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b18a4b85-ee2d-4a19-821a-21adebef782c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to convert files from .bin to .png with Python or Django

2019-07-05 Thread Joe Reitman
Try using the Pillow library. 

On Wednesday, July 3, 2019 at 6:52:35 PM UTC-5, Fernando Garrido Villalobos 
wrote:
>
> How to create a function that have like argument the path of a .bin file 
> and returns a .png file ...
> I need your help, 
> thank you so much.
>

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


Re: Connecting to SQL Server

2019-07-05 Thread Joe Reitman
When does this error occur? During runserver or when executing a commit 
from your model?

On Thursday, July 4, 2019 at 11:48:40 AM UTC-5, John Burke wrote:
>
> For this particular instance, I don't need the port number.
>
> On Thu, Jul 4, 2019 at 11:47 AM Joe Reitman  > wrote:
>
>> Don't you need to assign a port number?
>>
>> On Wednesday, July 3, 2019 at 6:52:35 PM UTC-5, John Burke wrote:
>>>
>>> Trying to connect to SQL Server from Django
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'sql_server.pyodbc',
>>> 'NAME': 'dbname',
>>> 'HOST': 'hostname',
>>> 'PORT': '',
>>> 'USER': 'user',
>>> 'PASSWORD': 'password',
>>> 'OPTIONS': {
>>> 'driver': 'ODBC Driver 13 for SQL Server',
>>> },
>>> }
>>> }
>>>
>>>
>>> I get the following error:
>>> File "...\venv\lib\site-packages\sql_server\pyodbc\base.py", line 362, 
>>> in init_connection_state
>>> val = cursor.execute('SELECT SYSDATETIME()').fetchone()[0]
>>> ValueError: hour must be in 0..23
>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/60dae4de-82b0-472c-987d-9fab48c37f0f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/60dae4de-82b0-472c-987d-9fab48c37f0f%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Regards,
> John B
>

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


Re: help

2019-07-04 Thread Joe Reitman
I would suggest not using locals(). You only have three variables to pass 
through to your template. 



On Wednesday, July 3, 2019 at 6:26:22 PM UTC-5, Tosin Ayoola wrote:
>
> Good day guyz
> sorry i'm working on a django e-commerce project which i am new to, and 
> i'm stuck, i wan have a page that will display the list of all for the list 
> of all products under a particular category, which i have checked out on 
> stackoverflow, i tried every suggestion and yet since not working below is 
> my code hoping anyone can lead mr in d right direction
>
> ##View
>
> def index(request):
> products = Product.objects.all()
> category = get_list_or_404(Category)
> cat = Category.objects.filter(pk = id)
> return render(request, 'shop/index.html', locals())
>
> ##product_list Page
> Categories
> {% if cat %}
>  
> {% for c in cat %}
> 
>  {{c.name}}
> 
> {% for product in cat.get_product %}
>  {(product.name}}
> {% endfor %}
> {% endfor %}
> 
> {% else %}
>  There's no item category yet
> {% endif %}
>  
>
>
>
>

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


Re: Deploying a static website

2019-07-04 Thread Joe Reitman
Just to clarify static vs dynamic

There are basically two main types of *website* - *static* and *dynamic*. A 
*static 
site* is one that is usually written in plain HTML and what is in the code 
of the page is what is displayed to the user. A *dynamic site* is one that 
is written using a server-side scripting language such as PHP, ASP, JSP, or 
Coldfusion.

Django is a dynamic site. 



On Wednesday, July 3, 2019 at 8:47:15 PM UTC-5, Django Dojo wrote:
>
> I’ve created a static website in Django and i would like to know the 
> cheapest an

 

> d best way to design ploy it.

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


Re: Connecting to SQL Server

2019-07-04 Thread Joe Reitman
Don't you need to assign a port number?

On Wednesday, July 3, 2019 at 6:52:35 PM UTC-5, John Burke wrote:
>
> Trying to connect to SQL Server from Django
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'sql_server.pyodbc',
> 'NAME': 'dbname',
> 'HOST': 'hostname',
> 'PORT': '',
> 'USER': 'user',
> 'PASSWORD': 'password',
> 'OPTIONS': {
> 'driver': 'ODBC Driver 13 for SQL Server',
> },
> }
> }
>
>
> I get the following error:
> File "...\venv\lib\site-packages\sql_server\pyodbc\base.py", line 362, in 
> init_connection_state
> val = cursor.execute('SELECT SYSDATETIME()').fetchone()[0]
> ValueError: hour must be in 0..23
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/60dae4de-82b0-472c-987d-9fab48c37f0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: login page not working

2019-07-03 Thread Joe Reitman
Try debugging your view with a print statement. Print the username and 
password to see if those values are getting passed in.

On Wednesday, July 3, 2019 at 6:02:52 AM UTC-5, KUMBHAGIRI SIVAKRISHNA 
wrote:
>
> I entered username and password ,and click submit ,then it directs same 
> login page with empty username and password columns,  logic is correct in 
> views.py
> Please help me ,give any suggestions to solve this issue
> views.py:
> ==
> from django.shortcuts import render ,redirect
> from django.contrib import messages
> from django.contrib.auth.models import User,auth
> from django.contrib.auth import authenticate, login,logout
> def Login(request):
> if request.method=='POST':
> username = request.POST['username']
> password = request.POST['password']
>
> user = auth.authenticate(username=username,password=password)
>
> if user is not None:
> auth.login(request, user)
> return redirect('/')
> else:
> messages.info(request,'invalid credentials')
> return redirect('Login')
> else:
> return render(request,'login.html') 
>
>
> login.html:
> 
> 
> 
> 
> 
> 
> 
> Login
> 
> 
> 
> {% csrf_token %}
> 
> 
> 
> 
> 
> 
> 
> {% for message in messages %}
> {{message}}
> {% endfor %}
> 
> 
>
> home.html:
> ===
>
> {% if request.user.is_authenticated %}
> Hello,{{user.first_name}}
> Logout
> {%else%}
> Register
> Login
> {%endif%}
>
>
>

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


Re: Polls app not showing?

2019-07-02 Thread Joe Reitman
That looks really weird.

Try running this command in a new folder exactly as shown.
django-admin startproject polls_project .

Remember to include a space and period after polls_ project. 

It should create a directory structure like this in your new folder.

.

├── manage.py

├── polls_project

│   ├── __init__.py

│   ├── settings.py

│   ├── urls.py

│   └── wsgi.py

Most developers use a virtual environment when creating new projects. A 
virtual env separates the dependencies between different projects. It is 
not necessary for you to do that on your first project so don't worry about 
it. You can always watch youtube tutorials on creating virtual envs later 
on. 

On Tuesday, July 2, 2019 at 9:25:35 PM UTC-5, Scott Winter wrote:
>
> Ok, attached a pic of the mysite folder and the other items inside. Polls 
> 2 and 3 are my attempt at making another polls app. Feels like I'm missing 
> something really simple here.
>
> On Sunday, June 30, 2019 at 11:06:54 PM UTC-4, Joe Reitman wrote:
>>
>> What does your project directory look like?
>>
>>
>>
>> On Sunday, June 30, 2019 at 8:29:02 PM UTC-5, Scott Winter wrote:
>>>
>>> Sorry, you'll have to be clearer than that. Not sure how to do that nor 
>>> how it relates to the issue
>>>
>>> On Friday, June 28, 2019 at 12:28:33 AM UTC-4, karthikvignesh28 wrote:
>>>>
>>>> Create virtual environment
>>>>
>>>> On Fri, Jun 28, 2019, 6:14 AM ScottW  wrote:
>>>>
>>>>> The server ran a few weeks ago before I ran into this issue. I used 
>>>>> the run server command just now and now its not working. Interesting
>>>>>
>>>>> On Thursday, June 27, 2019 at 3:09:29 PM UTC-4, karthikvignesh28 wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thursday, June 27, 2019 at 8:04:39 AM UTC+5:30, ScottW wrote:
>>>>>>>
>>>>>>> Hi, 
>>>>>>>
>>>>>>> I'm attempting to get started with Django and very first part of the 
>>>>>>> polls app. When I type "python manage.py startapp polls"  into the 
>>>>>>> Windows 
>>>>>>> Powershell I don't see a folder for it in my file explorer under 
>>>>>>> "mysite". 
>>>>>>> Even stranger is that when I type 'tree' for this folder it shows that 
>>>>>>> its 
>>>>>>> on the computer, but there's nothing in it besides 'migrations' and 
>>>>>>> '_pycache_ '. Please refer to the screenshot attached for a picture of 
>>>>>>> the 
>>>>>>> Powershell code. If someone could help steer me in the right direction 
>>>>>>> that 
>>>>>>> would be great! 
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Can you run the server Without Creating a new app? 
>>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to django...@googlegroups.com.
>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/django-users/003f95c0-4e7d-4806-af90-6a4e9f6da018%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/django-users/003f95c0-4e7d-4806-af90-6a4e9f6da018%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>

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


Re: order of loading css-files

2019-07-02 Thread Joe Reitman
You have a 404 error meaning the browser can not find the file on the 
server.
The 304 error code means the file is already loaded in the browser and is 
the same as the file on the server so it won't be modified.

On Tuesday, July 2, 2019 at 7:14:38 AM UTC-5, bengoshi wrote:
>
> Hi:
>
> I tried to load bootstrap and an own css-file. But in which order does 
> django load it?
>
> I have tried in my base.html:
>
> 
> {% load static %}
>
>
> 
> 
>
> {% block title %}gyousei{% endblock title %}
>
> 
> ...
>
> and the log is writing:
>
> [02/Jul/2019 11:54:38] "GET / HTTP/1.1" 200 6259
> [02/Jul/2019 11:54:38] "GET /static/css/base.css HTTP/1.1" 304 0
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/css/site.css HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/jquery.min.js HTTP/1.1" 404 
> 1702
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
>
> and if I write 
>
> 
> {% load static %}
> 
>
> 
> 
>
>
> {% block title %}gyousei{% endblock title %}
>
> 
> ...
> the log writes
>
> [02/Jul/2019 11:54:11] "GET /static/css/base.css HTTP/1.1" 304 0
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/js/jquery.min.js HTTP/1.1" 404 
> 1702
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/css/site.css HTTP/1.1" 404 1690
>
> If I understand it correct in both cases django loads my base.css first so 
> bootstrap overwrites it.
> How can I change this?
>
> Thanks for your response,
>
> bengoshi
>
> -- herz-jesu-jugend.de
>
>

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


Re: django form not saving items to database

2019-07-01 Thread Joe Reitman


Try this:


def sell(request):
 if request.method == 'POST':
  form = ProductsForm(request.POST)
  if form.is_valid():
  print('form is valid')
  form.save()
  return redirect('home')

 else:
 form = ProductsForm()
 return render(request, 'sell/products_form.html', {'form': form})


On Monday, July 1, 2019 at 6:35:31 AM UTC-5, brian wrote:
>
> model
>
> class Products(models.Model):
>
> UNIT = (
> ('whole', 'whole unit'),
> ('item', 'per single item'),
> )
>
>
> # category = models.ForeignKey(Category, related_name='products', 
> on_delete=models.CASCADE)
> ProductName = models.CharField(max_length=255)
> user = models.ForeignKey(User, on_delete=models.CASCADE)
> ProductDescription = models.TextField(max_length=500, blank=True)
> price = models.FloatField()
> location = models.CharField(choices = COUNTIES, max_length=300)
> # category = models.CharField( choices = CATEGORIES, max_length=10, 
> default='other')
> category = models.ForeignKey(Category, related_name='products', 
> on_delete=models.CASCADE)
>
> unitofsale = models.CharField(max_length=10, choices=UNIT)
> image = models.FileField(upload_to='products_images/', blank=True)
> sublocation = models.CharField(max_length=100)
> created= models.DateTimeField(auto_now_add=True)
> # slug = models.SlugField(max_length=200,db_index=True)
>
> class Meta:
> ordering = ('-created',)
> # index_together = (('id', 'slug'),)
>
> view
>
> def sell(request):
>  if request.method == 'POST':
>   form = ProductsForm()
>   form = ProductsForm(request.POST, request.FILES, instance = 
> request.user)
>   if form.is_valid():
>   print('form is valid')
>   form = form.save(commit=True)
>   user = request.user
>   form.user = user
>   form.save()
>   return redirect('home')
>
>  else:
>  form = ProductsForm()
>  return render(request, 'sell/products_form.html', {'form': form})
>
> template
>
>  enctype="multipart/form-data">
> {% csrf_token %}
> 
> 
> 
> Product Name
> {{  form.ProductName}}
>
> 
>
>
> 
> 
> 
> Product Price
> {{ form.price }}
> 
> 
> 
> 
> 
> 
> County
> {{  form.location}}
>
> 
>
>
> 
> 
> 
> Sub-location
> {{ form.sublocation }}
> 
> 
> 
> 
> 
> 
> Category
> {{  form.category}}
>
> 
>
>
> 
> 
> 
> Unit of Sale
> {{ form.unitofsale }}
> 
> 
> 
> 
> 
> 
> Product Description
> {{  form.ProductDescription}}
>
> 
>
>
> 
> 
> 
> Upload Product Image
> {{ form.image }}
> 
> 
> 
> 
> 
> 
>  Sell 
>
> 
>
>
> 
> 
>
>
> 
>
> {##}
> 
>
>
>

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


Re: Polls app not showing?

2019-06-30 Thread Joe Reitman
What does your project directory look like?



On Sunday, June 30, 2019 at 8:29:02 PM UTC-5, Scott Winter wrote:
>
> Sorry, you'll have to be clearer than that. Not sure how to do that nor 
> how it relates to the issue
>
> On Friday, June 28, 2019 at 12:28:33 AM UTC-4, karthikvignesh28 wrote:
>>
>> Create virtual environment
>>
>> On Fri, Jun 28, 2019, 6:14 AM ScottW  wrote:
>>
>>> The server ran a few weeks ago before I ran into this issue. I used the 
>>> run server command just now and now its not working. Interesting
>>>
>>> On Thursday, June 27, 2019 at 3:09:29 PM UTC-4, karthikvignesh28 wrote:



 On Thursday, June 27, 2019 at 8:04:39 AM UTC+5:30, ScottW wrote:
>
> Hi, 
>
> I'm attempting to get started with Django and very first part of the 
> polls app. When I type "python manage.py startapp polls"  into the 
> Windows 
> Powershell I don't see a folder for it in my file explorer under 
> "mysite". 
> Even stranger is that when I type 'tree' for this folder it shows that 
> its 
> on the computer, but there's nothing in it besides 'migrations' and 
> '_pycache_ '. Please refer to the screenshot attached for a picture of 
> the 
> Powershell code. If someone could help steer me in the right direction 
> that 
> would be great! 
>



 Can you run the server Without Creating a new app? 

>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/003f95c0-4e7d-4806-af90-6a4e9f6da018%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

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


Re: Nested dictionaries

2019-06-30 Thread Joe Reitman
I use the JSON module to encode and decode JSON. 

On Sunday, June 30, 2019 at 9:26:04 AM UTC-5, David Elphee wrote:
>
> I guess I don’t even need Django or models to do what I described.  But 
> yes, for future functionality, I’d like to be able to store JSON to a 
> database. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01df4ac2-845e-4e21-8726-1a90f4704c2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: deploy django on AWS

2019-06-30 Thread Joe Reitman
https://www.zappa.io/

It's not easy to configure but it does work well when up and running.

On Sunday, June 30, 2019 at 11:37:20 AM UTC-5, Harshit wrote:
>
> Hello Django users,
> I want to host my django website on aws, This is first time that i am 
> hosting a website. Can u suggest any good resource from which i can learn?
>
> Thank you
>

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


Re: deploy django on AWS

2019-06-30 Thread Joe Reitman
https://www.zappa.io/

On Sunday, June 30, 2019 at 11:37:20 AM UTC-5, Harshit wrote:
>
> Hello Django users,
> I want to host my django website on aws, This is first time that i am 
> hosting a website. Can u suggest any good resource from which i can learn?
>
> Thank you
>

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


Re: Nested dictionaries

2019-06-30 Thread Joe Reitman
You want to save JSON data to a database?

On Saturday, June 29, 2019 at 8:47:38 PM UTC-5, David Elphee wrote:
>
> Hello,
> I am new at django and in over my head I think.  I am trying to create a 
> kind of shim that will accept JSON from a webhook POST, work with the data 
> using Python, and then POST some new JSON to another API.  I have 
> successfully worked through tutorials that have "flat" data, and I have 
> looked at the documentation on serializing nested data, but I don't see how 
> to write the models to work with the serializers.  Does anyone know of a 
> tutorial that demonstrates working with nested dictionaries?
> Thank you,
> Dave E.
>

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


Re: Help

2019-06-30 Thread Joe Reitman
Also, you will have to wrap your entire form in a  tag. 
Then you can use a submit button to submit the data to the server.

If you are displaying data from the database and allowing the user to make 
and save changes, you first have to render the data from the view.

What is the Javascript code?

On Sunday, June 30, 2019 at 7:54:43 AM UTC-5, pramod wrote:
>
> I wrote a js for that wer it display the results  of addition 
> automatically through id
> If I use like this {{form. Full}} How do I pass the Id to the js? 
>
> On Jun 30, 2019 6:19 PM, "Joe Reitman" > 
> wrote:
>
> Don't use an 'input' element to display your form field.
>
> Try something like this:
>
> {{ form.date }}
>
>
>
> On Sunday, June 30, 2019 at 7:35:42 AM UTC-5, pramod wrote:
>>
>> The give to get the input  from the user in table? 
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/2ba6a878-9dee-47ed-8f36-48d51d1bfca5%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/2ba6a878-9dee-47ed-8f36-48d51d1bfca5%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>

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


Re: Help

2019-06-30 Thread Joe Reitman
Don't use an 'input' element to display your form field.

Try something like this:

{{ form.date }}



On Sunday, June 30, 2019 at 7:35:42 AM UTC-5, pramod wrote:
>
> The give to get the input  from the user in table? 
>

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


Re: .model class not added in localhost:8000/admin

2019-06-29 Thread Joe Reitman
In your Destination class you have to return a string representation of the 
fields you to display in Admin.

https://docs.djangoproject.com/en/2.2/ref/models/instances/#other-model-instance-methods


On Saturday, June 29, 2019 at 7:36:17 AM UTC-5, KUMBHAGIRI SIVAKRISHNA 
wrote:
>
> 'Destination'  class from models.py cannot add to the 
> http://localhost:8000/admin/  
> please help me ,give if any suggestions
>

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


Re: what's a good approach for building a product model in a django multi-vendor eCommerce system?

2019-06-29 Thread Joe Reitman
You can use Choices 
- https://docs.djangoproject.com/en/2.2/ref/models/fields/#choices

On Saturday, June 29, 2019 at 3:17:04 AM UTC-5, Arya wrote:
>
> as you know eCommerce websites consist of various types of products and 
> attributes.
> there are digital products as well as physical products.
> there are many different attributes that are assigned to a specific type 
> of product.
>
> i need a good example to build such a system in django.
>
> what i know is that i need to create an app for products and create a 
> class for the product type and then later you lookup the data in the 
> database using this fields:
>
> class Product(models.Model):
> title = models.CharField(max_length=200)
> ...
> ...
> ...
> a
> but what if i want my users (vendors) to be able to define an attribute 
> for their product model that is not pre-defined by me?
> say a shoe might have a size field(attribute) but a memory may have a 
> capacity attribute. a developer can't predefine everything.
>
> woocommerce in WordPress has a system that enables admins to add global 
> attributes for product types that is usable and see-able by all vendors.
> vendors can also define local attributes only seen by themselves.
>
> how do you perform such a task in django? are there any good 
> articles/tutorials on this subject that covers everything?
>
> thank you
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/188364d5-9cf3-4cb8-9833-638c82ce273f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: need help - following django tutorial to create polls database - missing "on delete cascade" - using django 2.2.1 with mysql 8.0

2019-06-28 Thread Joe Reitman
The notes say:

   - The exact output will vary depending on the database you are using. 
   The example above is generated for* PostgreSQL.*

Are you using the default SQLite?

You could try running migrate and then checking the tables to see if the 
constraint was added using a DB admin viewer.

For SQLite I use - https://sqlitebrowser.org/
For Postgres  - https://www.pgadmin.org/



On Tuesday, May 28, 2019 at 7:44:44 PM UTC-5, K Tan wrote:
>
> Hi, everyone,
>
> This is my first time using Django and I think I'm missing something or 
> there is a bug. I am following the instructions on (
> https://docs.djangoproject.com/en/2.2/intro/tutorial02/) and I've just 
> added the following chunk of code to "polls/models.py". (I copied/pasted so 
> I know it's correct.)
>
> 
> from django.db import models
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> 
>
>
> Then I ran the following command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py makemigrations polls
> Migrations for 'polls':
>   polls/migrations/0001_initial.py
> - Create model Question
> - Create model Choice
> 
>
> Which is missing one line compared to the tutorial:
>
> - Add field question to choice
>
>
>
> Now when I run this command:
>
> 
> LITTLEBLACK:www samktan$ python3 manage.py sqlmigrate polls 0001
> BEGIN;
> --
> -- Create model Question
> --
> CREATE TABLE `polls_question` (`id` integer AUTO_INCREMENT NOT NULL 
> PRIMARY KEY, `question_text` varchar(200) NOT NULL, `pub_date` datetime(6) 
> NOT NULL);
> --
> -- Create model Choice
> --
> CREATE TABLE `polls_choice` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY 
> KEY, `choice_text` varchar(200) NOT NULL, `votes` integer NOT NULL, 
> `question_id` integer NOT NULL);
> ALTER TABLE `polls_choice` ADD CONSTRAINT 
> `polls_choice_question_id_c5b4b260_fk_polls_question_id` FOREIGN KEY 
> (`question_id`) REFERENCES `polls_question` (`id`);
> COMMIT;
> 
>
> It is missing the "on delete cascade" clause, which I suspect it caused by 
> the missing line above.
>
> I have confirmed in MySQL that the "on delete cascade" clause is 
> definitely missing.
>
> 
> mysql> show create table `polls_choice`;
>
> +--+-+
> | Table| Create Table 
> 
> 
> 
> 
> 
>|
>
> +--+-+
> | polls_choice | CREATE TABLE `polls_choice` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `choice_text` varchar(200) COLLATE utf8mb4_general_ci NOT NULL,
>   `votes` int(11) NOT NULL,
>   `question_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> (`question_id`),
>   CONSTRAINT `polls_choice_question_id_c5b4b260_fk_polls_question_id` 
> FOREIGN KEY (`question_id`) REFERENCES `polls_question` (`id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci |
>
> 

Re: Error when displaying videos on iOS and Safari, but fine in Chrome

2019-06-28 Thread Joe Reitman
What is the format of the video? iOS and Safari won't play back WebM. 

On Thursday, June 27, 2019 at 9:16:35 PM UTC-5, Walker Obrien wrote:
>
> I have a social media application in the early stages of deployment, and 
> when videos are uploaded they are getting displayed perfectly fine when 
> visiting the site on chrome but they are not being displayed correctly when 
> using iOS or Safari... Any suggestions?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/05885ac2-87ab-49a0-b005-81f9e337984a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polls app not showing?

2019-06-27 Thread Joe Reitman
Did you create a project first with the 'startproject' command?

On Wednesday, June 26, 2019 at 9:34:39 PM UTC-5, ScottW wrote:
>
> Hi, 
>
> I'm attempting to get started with Django and very first part of the polls 
> app. When I type "python manage.py startapp polls"  into the Windows 
> Powershell I don't see a folder for it in my file explorer under "mysite". 
> Even stranger is that when I type 'tree' for this folder it shows that its 
> on the computer, but there's nothing in it besides 'migrations' and 
> '_pycache_ '. Please refer to the screenshot attached for a picture of the 
> Powershell code. If someone could help steer me in the right direction that 
> would be great! 
>

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


Re: Website advice/ Django packages

2019-06-27 Thread Joe Reitman
probably not. I would assume the store price info, etc in a database

On Thursday, June 27, 2019 at 7:10:07 AM UTC-5, Django Dojo wrote:
>
> I’m looking to develop  similar to: 
> https://www.northwestregisteredagent.com but I’m confused on how the 
> prices change for each state. Is there a Django package for this?

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


Re: How to connect Django with Hbase

2019-06-27 Thread Joe Reitman
Django only supports a few relational databases out of the box. Oracle, 
mysql, postgres and sqlite.

There may be some 3rd party packages out there via google search. The other 
option is to write your own db backend.  

On Wednesday, June 26, 2019 at 9:59:46 AM UTC-5, Varun Kumar wrote:
>
> Hello folks , 
>
>Does anyone know how to connect django with hbase as db ?
> *Regards,*
>
> *Varun Kumar *
> *Mob: +91-8884601515*
> *email: varuns...@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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e81009a9-1133-49a0-9cef-c289b95067ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [novice question] Render a list of objects

2019-06-22 Thread Joe Reitman
The example code you provided will create a  on the first iteration of 
the loop and  tag every 4th iteration of the loop. This cycle will 
continue resulting in a table with 4 columns of data. Example:

results = [ 1, 2, 3, 4, 5, 6, 7, 8 ]



  
1
2
3
4
  
  
5
6
7
8
  



If you have 2 lists, render them from your view like return render(request, 
'polls/detail.html', {'list1': list1, 'list2': list2})
In your template create an 8 column table:


  {% for r in list1 %}
{% cycle '' '' '' '' '' '' '' ''%}
  {{r}}
{% cycle '' '' '' '' '' '' '' '' %}
  {% endfor %}

{% for r in list2 %}
{% cycle '' '' '' '' '' '' '' ''%}
  {{r}}
{% cycle '' '' '' '' '' '' '' '' %}
  {% endfor %}




Hope this helps

On Friday, June 21, 2019 at 5:58:21 PM UTC-5, Sudeep Gopal wrote:
>
> Hello, 
>
> I am new to django. 
>
> I am using django forms in my project and I am not using django models. 
>
> From the user,  my django form asks for 4 inputs :- signal_to_noise_1 , 
> signal_to_noise_2, bandwidth1 and bandwidth2. 
>
> Based on these values I use my  look up table and I create a results which 
> are 2 lists of records.
>  Each list has approximately 40 to 50 records. Each record has 8 fields. 
> (field1,...field8) ...
>
> *Each list *looks like this (if my description is not clear) field1 is 
> unique. 
>
> field1  field2  field3 
>
>
>
> field8
>
>
>
>
>
>
>
>
>
>
>
> Both the lists (with each list having about 50 records) are in my django 
> view. 
>
> From what I read online, I can use the render() method which has a 
> *dictionary 
> *called context. (
> https://docs.djangoproject.com/en/2.2/ref/templates/api/#rendering-a-context 
> 
> )
>
> I am not sure how to convert these list of record objects to this 
> dictionary format which has {"name":value} pair. 
>
> Even the django tables requires it in the dictionary format.
>
> The nearest thing which I found was 
> https://stackoverflow.com/questions/9388064/django-template-turn-array-into-html-table
>  
>
> But I did not understand what exactly the below syntax does and how I can 
> customize it to my usecase any input would be greatly appreciated ...
>
> 
>   {% for r in results %}
> {% cycle '' '' '' '' %}
>   {{r.content}}
> {% cycle '' '' '' '' %}
>   {% endfor %}
>
>
>
>
>
>

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


Re: my file uploads missing/deleted

2019-06-15 Thread Joe Reitman
Did you create a processed image field in your model?

On Friday, June 14, 2019 at 7:50:41 AM UTC-5, omar ahmed wrote:
>
> ok i did all steps but it still doesn't work .. this is my settings.py 
> file :
> PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
> STATIC_URL = '/static/'
> STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
> STATICFILES_STORAGE = 
> 'whitenoise.storage.CompressedManifestStaticFilesStorage'
>
> DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
> DROPBOX_OAUTH2_TOKEN = 
> 'hSRexFBHo-AAWVBZOhZJo6jrIP3NgMK0L_7aWHkb0mJs-z4IWO6b_EBk'
> DROPBOX_ROOT_PATH = '/arenaimages/'
>
> and this is admin.py :
> from django.contrib import admin
> from imagekit.admin import AdminThumbnail
> from .models import MapData
> # Register your models here.
>
> from .models import League, LeagueNews, Comment, Club, Match
> admin.site.register(League)
> admin.site.register(LeagueNews)
> admin.site.register(Comment)
>
> class ClubAdmin(admin.ModelAdmin):
> fields = ['league_names', 'name', 'year_of_establishment', 'logo', 'won', 
> 'draw', 'lost', 'total_points', 'goal_for', 'goal_against', 'goal_diff']
> logo = AdminThumbnail(image_field='image')
> readonly_fields = ('total_points', 'goal_diff',)
>
> admin.site.register(Club, ClubAdmin)
> admin.site.register(Match)
> thanks joe
>
> On Friday, June 14, 2019 at 12:31:31 PM UTC+2, Joe Reitman wrote:
>>
>> Yes. Generate an access token from your Dropbox App Console and put it in 
>> your settings.py. The token is used to authenticate your Django app with 
>> your Dropbox app.
>>
>> DROPBOX_ROOT_PATH is the folder in your Dropbox App where you want to 
>> store your photos. You need to define it with this variable in settings.py.
>>  Typically I call it 'images' like this:  
>> DROPBOX_ROOT_PATH = '/images/'
>>
>>
>> On Thursday, June 13, 2019 at 3:44:20 PM UTC-5, omar ahmed wrote:
>>>
>>> i did first and second steps
>>> but what about 
>>> DROPBOX_OAUTH2_TOKEN = your token from dropbox
>>> did you mean Generate access token ??
>>> DROPBOX_ROOT_PATH = your root path to store media
>>> did you mean link to Dropbox app folder ?
>>> thanks
>>> On Thursday, June 13, 2019 at 6:15:02 PM UTC+2, Joe Reitman wrote:
>>>>
>>>> Omar, 
>>>>
>>>> You should not be configuring views for Dropbox. DJANGO-STORAGES does 
>>>> all the back end coding for you.
>>>>
>>>> Follow these steps from DJANGO-STORAGES documentation after removing 
>>>> the code changes you made to views. I'm assuming your using pip.
>>>>
>>>> 1. pip install django-storages
>>>> 2. pip install dropbox
>>>> 3. In your settings.py set these variables
>>>> DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
>>>> DROPBOX_OAUTH2_TOKEN = your token from dropbox
>>>> DROPBOX_ROOT_PATH = your root path to store media
>>>> FROM THE DROPBOX DOCUMENTATION TUTORIAL YOU ONLY NEED TO REGISTER YOUR 
>>>> APP AND GENERATE YOUR OAUTH2 TOKEN. DISREGARD THE 'LINK YOUR ACCOUNT'. 
>>>> DJANGO STORAGES DOES THAT FOR YOU.
>>>>
>>>> 4. pip install django-imagekit and add it to your settings.py 
>>>> 'installed apps' -read the docs 
>>>> <https://django-imagekit.readthedocs.io/en/latest/> on this one
>>>>
>>>> Now you need to have an imagefield in your model and config your 
>>>> admin.py as I explained earlier. 
>>>> I highly recommend creating an app to do this functionality. Call it 
>>>> something like 'logo upload'. Django best practices says an app does one 
>>>> thing and does it well.
>>>>
>>>>
>>>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>>>
>>>>> hii ..
>>>>> i deployed my first django app on Heroku https://arena3.herokuapp.com/
>>>>> but my media files ( like club logo ) disappear or deleted ... 
>>>>> i found this article on Heroku 
>>>>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
>>>>>
>>>>> that means The Heroku filesystem is ephermal and i should use aws but 
>>>>> it's not free ?
>>>>> is there any solution ?
>>>>> how can i use Heroku postgres (addons) to upload my files permanently 
>>>>> .. thanks in advance
>>>>>
>>>>

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


Re: Create View not saving form data to database

2019-06-14 Thread Joe Reitman
Your passing strings as the first argument in your many-to-many fields. 
Shouldn't they be classes? Doc 


On Thursday, June 13, 2019 at 8:31:29 PM UTC-5, curtly critchlow wrote:
>
> CreateView class not saving data to database. When I hit submit, the html 
> the page only refreshes. l'm not getting any errors so I have no idea what 
> i'm doing wrong. Does CreateView automatically takes care of many to many 
> relationships? here is my code below, I've been trying to solve this 
> problem 2 days now.
>
>
>1. Models.py 
>2.  
>3. from django.db import models
>4. from django.utils import timezone
>5. from django.urls import reverse_lazy, reverse
>6. 
>7. # Create your models here.
>8. 
>9. class Requisition(models.Model):
>10.# constants
>11.FROZEN = 'Frozen'
>12.CHILLED = 'Chilled/Cold Pack'
>13.DRYICE = 'Dry Ice'
>14.ROOMTEMP = 'Room Temperature'
>15.TRANSPORT_CHOICE = 
>[(FROZEN,FROZEN),(CHILLED,CHILLED),(DRYICE,DRYICE),(ROOMTEMP,ROOMTEMP)]
>16.
>17.EMAIL = 'email'
>18.HARDCOPY = 'Hardcopy Pickup'
>19.BOTH = 'Email & Hardcopy Pickup'
>20.RECEIPT_CHOICE = [(EMAIL,EMAIL), (HARDCOPY,HARDCOPY), 
>(BOTH,BOTH)]
>21. 
>22. 
>23. ACUTE = 'Acute'
>24.CHRONIC = 'Chronic'
>25.SYMPTOMS_CHOICE = [(ACUTE,ACUTE,), (CHRONIC,CHRONIC)]
>26. 
>27. #columns
>28.accession_number = models.CharField(max_length=254, 
>unique=True, help_text='format: VSLXXX-XXX')
>29.customer = models.ForeignKey('general.Customer', 
>on_delete=models.CASCADE, related_name='requisition')
>30.
>31.# Veterinary Officer Info
>32.veterinary_officer = models.CharField(max_length=50, blank=True)
>33.address = models.CharField(max_length=50, blank=True)
>34.contact_number = models.CharField(max_length=13, blank=True, 
>help_text="number format example: +592 XXX ") 
>35. email_address = models.EmailField(max_length=50, blank=True)
>36. 
>37. # General sample info
>38.
>39.collected_by = models.CharField(max_length=50)
>40.time_of_collection = models.DateTimeField()
>41.
>42. 
>43. method_of_transport = models.CharField(max_length=50, 
>choices=TRANSPORT_CHOICE)
>44.result_transmission = models.CharField(max_length=50, 
>choices=RECEIPT_CHOICE)
>45. 
>46. #pathology
>47.reason_for_request = 
>models.ManyToManyField('ReasonForRequest',related_name='requisition', 
>blank=True)
>48.illness_date = models.DateField('Date of onset of illness', 
>blank=True, null=True)
>49.illness_duration = models.CharField('Duration of illness', 
>max_length=254, blank=True)
>50.symptoms = models.CharField(max_length=50, 
>choices=SYMPTOMS_CHOICE, blank=True)
>51.fever = models.BooleanField('Presence of Fever', blank=True, 
>null=True)
>52.body_temp = models.PositiveSmallIntegerField('Max body 
>Temperature (C)', blank=True, null=True)
>53.fever_duration = models.CharField('Duration of 
>Fever',max_length=50, blank=True)
>54.signs = models.ManyToManyField('Signs', 
>related_name='requisition', blank=True)
>55.vaccination_status = models.CharField(max_length=50, blank=True)
>56.vaccination_date = models.DateField('Date of Vaccination', 
>blank=True, null=True)
>57.treatments = models.TextField('Previous/Current Treatments', 
>blank=True)
>58.exposed = models.ManyToManyField('Exposed', 
>related_name='requisition', through='ExposureHistory', blank=True)
>59.
>60.comments = models.TextField(blank=True)
>61.recieved_by = models.ForeignKey('auth.User', 
>on_delete=models.CASCADE)
>62.submitted_by = models.CharField(max_length=254, help_text='if 
>multiple persons separate names using "&" exampe: John Doe   & 
>Jane Doe')
>63.date_of_submission = models.DateTimeField(auto_now_add=True)
>64. 
>65. def __str__(self):
>66.return self.accession_number 
>67.  
>68.def get_absolute_url(self):
>69.return reverse("laboratory:requisition_details", 
>kwargs={'pk':self.pk})
>70.
>71. forms.py
>72. 
>73. from django.forms import ModelForm
>74. from general.models import Customer
>75. from laboratory.models import Requisition
>76. from bootstrap_datepicker_plus import DatePickerInput, 
>DateTimePickerInput
>77. 
>78. class RequisitionForm(ModelForm):
>79.class Meta:
>80.model = Requisition
>81.fields = '__all__'
>82.widgets = {
>83.'illness_date': DatePickerInput,
>84.'vaccination_date': DatePickerInput,
>

Re: my file uploads missing/deleted

2019-06-14 Thread Joe Reitman
Yes. Generate an access token from your Dropbox App Console and put it in 
your settings.py. The token is used to authenticate your Django app with 
your Dropbox app.

DROPBOX_ROOT_PATH is the folder in your Dropbox App where you want to store 
your photos. You need to define it with this variable in settings.py.
 Typically I call it 'images' like this:  
DROPBOX_ROOT_PATH = '/images/'


On Thursday, June 13, 2019 at 3:44:20 PM UTC-5, omar ahmed wrote:
>
> i did first and second steps
> but what about 
> DROPBOX_OAUTH2_TOKEN = your token from dropbox
> did you mean Generate access token ??
> DROPBOX_ROOT_PATH = your root path to store media
> did you mean link to Dropbox app folder ?
> thanks
> On Thursday, June 13, 2019 at 6:15:02 PM UTC+2, Joe Reitman wrote:
>>
>> Omar, 
>>
>> You should not be configuring views for Dropbox. DJANGO-STORAGES does all 
>> the back end coding for you.
>>
>> Follow these steps from DJANGO-STORAGES documentation after removing the 
>> code changes you made to views. I'm assuming your using pip.
>>
>> 1. pip install django-storages
>> 2. pip install dropbox
>> 3. In your settings.py set these variables
>> DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
>> DROPBOX_OAUTH2_TOKEN = your token from dropbox
>> DROPBOX_ROOT_PATH = your root path to store media
>> FROM THE DROPBOX DOCUMENTATION TUTORIAL YOU ONLY NEED TO REGISTER YOUR 
>> APP AND GENERATE YOUR OAUTH2 TOKEN. DISREGARD THE 'LINK YOUR ACCOUNT'. 
>> DJANGO STORAGES DOES THAT FOR YOU.
>>
>> 4. pip install django-imagekit and add it to your settings.py 'installed 
>> apps' -read the docs <https://django-imagekit.readthedocs.io/en/latest/> 
>> on this one
>>
>> Now you need to have an imagefield in your model and config your admin.py 
>> as I explained earlier. 
>> I highly recommend creating an app to do this functionality. Call it 
>> something like 'logo upload'. Django best practices says an app does one 
>> thing and does it well.
>>
>>
>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>
>>> hii ..
>>> i deployed my first django app on Heroku https://arena3.herokuapp.com/
>>> but my media files ( like club logo ) disappear or deleted ... 
>>> i found this article on Heroku 
>>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
>>>
>>> that means The Heroku filesystem is ephermal and i should use aws but 
>>> it's not free ?
>>> is there any solution ?
>>> how can i use Heroku postgres (addons) to upload my files permanently .. 
>>> thanks in advance
>>>
>>

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


Re: my file uploads missing/deleted

2019-06-13 Thread Joe Reitman
Omar, 

You should not be configuring views for Dropbox. DJANGO-STORAGES does all 
the back end coding for you.

Follow these steps from DJANGO-STORAGES documentation after removing the 
code changes you made to views. I'm assuming your using pip.

1. pip install django-storages
2. pip install dropbox
3. In your settings.py set these variables
DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
DROPBOX_OAUTH2_TOKEN = your token from dropbox
DROPBOX_ROOT_PATH = your root path to store media
FROM THE DROPBOX DOCUMENTATION TUTORIAL YOU ONLY NEED TO REGISTER YOUR APP 
AND GENERATE YOUR OAUTH2 TOKEN. DISREGARD THE 'LINK YOUR ACCOUNT'. DJANGO 
STORAGES DOES THAT FOR YOU.

4. pip install django-imagekit and add it to your settings.py 'installed 
apps' -read the docs  on 
this one

Now you need to have an imagefield in your model and config your admin.py 
as I explained earlier. 
I highly recommend creating an app to do this functionality. Call it 
something like 'logo upload'. Django best practices says an app does one 
thing and does it well.


On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>
> hii ..
> i deployed my first django app on Heroku https://arena3.herokuapp.com/
> but my media files ( like club logo ) disappear or deleted ... 
> i found this article on Heroku 
> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
> that means The Heroku filesystem is ephermal and i should use aws but it's 
> not free ?
> is there any solution ?
> how can i use Heroku postgres (addons) to upload my files permanently .. 
> thanks in advance
>

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


Re: my file uploads missing/deleted

2019-06-12 Thread Joe Reitman
Omar,

To upload images from the Admin panel, you will have to configure your 
apps' admin.py file. I use the django-imagekit package to manipulate user 
uploaded images. This package also provides the ability to upload images 
via the Admin panel with a couple lines of code. Here is my Admin.py code. 

from django.contrib import admin
from imagekit.admin import AdminThumbnail
from .models import MapData


class PhotoAdmin(admin.ModelAdmin):

 list_display = ('__str__', 'admin_thumbnail')
 admin_thumbnail = AdminThumbnail(image_field='image')


admin.site.register(MapData, PhotoAdmin) 



It displays thumbnails of all the images stored in my database and presents 
them in a list view in the Admin panel alongside the other model data.

On Tuesday, June 11, 2019 at 4:16:43 PM UTC-5, omar ahmed wrote:
>
> yes James you are right i need to upload images using the Django 
> admin, ... how can i use Dropbox for this issue ? 
> i need a good tutorial
>
> On Tuesday, June 11, 2019 at 6:14:10 PM UTC+2, James Farris wrote:
>>
>> He is saying these aren’t static files. It sounds like he uploads them 
>> using the Django admin, which of course is like an end user on a client 
>> uploading files to the media directory. 
>>
>> Since that is the case it sounds like the Dropbox option is the best. 
>> Documentation was provided earlier. So being that it seems like he read 
>> through the documentation, my question is where is he stuck in the Dropbox 
>> implementation?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e689c03-572f-46e5-ae4d-247141653a55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: my file uploads missing/deleted

2019-06-11 Thread Joe Reitman
Omar,

You need to put the image in your 'static' files directory. 





On Monday, June 10, 2019 at 2:37:58 PM UTC-5, omar ahmed wrote:
>
> almost i did all of these instructions 
> collectstatic - DEBUG = True  - install and use whitenoise in my app 
> the problem is heroku is ephemeral ( that's mean image clubs appear and 
> after one hour it disappear )
> i want to use something like Dropbox (permenant) but i don't know how to  
> make it my media folder 
>
>
> On Monday, June 10, 2019 at 10:57:23 AM UTC+2, Joe Reitman wrote:
>>
>> A couple of things to check.
>> > width="100">
>> 1. Is the photo located in directory above?
>> 2. Did you run collectstatic?
>> 3. In your settings.py are STATIC_ROOT, STATIC_URLS and STATICFILES_DIRS 
>> configured
>> 4. In your template you have setup like this example:
>>
>> {% load static %}
>>
>>
>> Also, it looks like you have DEBUG set to True. When DEBUG is set to 
>> True, Django will use it's development static file server to serve static 
>> files. However, setting DEBUG true in production is not recommended. 
>>
>> Note that when you set DEBUG to False, the Django static file server is 
>> disabled. Hence the need to host static files on a CDN *or* using a 
>> static file server like Whitenoise. You can serve static files within your 
>> Django app using Whitenoise <http://whitenoise.evans.io/en/stable/> and 
>> is recommended by Heroku 
>> <https://devcenter.heroku.com/articles/django-assets#whitenoise>. The 
>> other option is to serve static files from external sources.
>>
>> If you only have one photo, you can do what I suggested using codepen.io 
>> or surge.sh or almost any other remote storage that allows you to 
>> 'hotlink' <https://simple.wikipedia.org/wiki/Hotlinking> image files.
>>
>>
>> On Sunday, June 9, 2019 at 9:17:42 PM UTC-5, omar ahmed wrote:
>>>
>>> this is explanation for my problem 
>>> my site is for football news My Media Files are uploaded to the app but 
>>> then disappear .... like clubs logo here 
>>> https://arena3.herokuapp.com/8/clubpage/
>>> when i created any club logo appear but after minutes disappear 
>>> i don't mean files uploaded by the users ( but by me in admin dashboard)
>>>
>>> On Sunday, June 9, 2019 at 11:16:19 PM UTC+2, Joe Reitman wrote:
>>>>
>>>> Omar,
>>>>
>>>> Looking at your original request I misunderstood what you wanted to do. 
>>>> I thought you wanted to configure media files which are uploaded by the 
>>>> user. 
>>>>
>>>> For static files you have many free options to store them and put the 
>>>> links in your img tags. If you have a codepen.io account, you can 
>>>> upload your images to codepen and use the links generated by codepen. 
>>>> Another option is to install surge.sh and upload images to a surge static 
>>>> site and then use the links to the images. If that makes sense.
>>>>
>>>> I have used both options to store my static files in various projects. 
>>>> These options are good for testing and development.
>>>>
>>>> On Sunday, June 9, 2019 at 9:07:01 AM UTC-5, omar ahmed wrote:
>>>>>
>>>>> i installed Dropbox for django environment 
>>>>> but how to link an account and adjust settings 
>>>>> tutorial is not clear
>>>>> thanks
>>>>>
>>>>> On Saturday, June 8, 2019 at 8:23:08 PM UTC+2, Joe Reitman wrote:
>>>>>>
>>>>>> Follow the django-storages documentation. 
>>>>>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>>>>>>
>>>>>> It's easy to setup.
>>>>>>
>>>>>> On Saturday, June 8, 2019 at 8:23:17 AM UTC-5, omar ahmed wrote:
>>>>>>>
>>>>>>> ok joe  how can i use Dropbox for this issue ..
>>>>>>>
>>>>>>> On Saturday, June 8, 2019 at 2:59:20 AM UTC+2, Joe Reitman wrote:
>>>>>>>>
>>>>>>>> Omar,
>>>>>>>>
>>>>>>>> I use Dropbox which is free up to 2GB. I installed django-storages 
>>>>>>>> library to make setting up Dropbox easy.  
>>>>>>>>
>>>>>>>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>>>>>>>
>>>>>>>&

Re: my file uploads missing/deleted

2019-06-10 Thread Joe Reitman
A couple of things to check.

1. Is the photo located in directory above?
2. Did you run collectstatic?
3. In your settings.py are STATIC_ROOT, STATIC_URLS and STATICFILES_DIRS 
configured
4. In your template you have setup like this example:

{% load static %}


Also, it looks like you have DEBUG set to True. When DEBUG is set to True, 
Django will use it's development static file server to serve static files. 
However, setting DEBUG true in production is not recommended. 

Note that when you set DEBUG to False, the Django static file server is 
disabled. Hence the need to host static files on a CDN *or* using a static 
file server like Whitenoise. You can serve static files within your Django 
app using Whitenoise <http://whitenoise.evans.io/en/stable/> and is 
recommended by Heroku 
<https://devcenter.heroku.com/articles/django-assets#whitenoise>. The other 
option is to serve static files from external sources.

If you only have one photo, you can do what I suggested using codepen.io or 
surge.sh or almost any other remote storage that allows you to 'hotlink' 
<https://simple.wikipedia.org/wiki/Hotlinking> image files.


On Sunday, June 9, 2019 at 9:17:42 PM UTC-5, omar ahmed wrote:
>
> this is explanation for my problem 
> my site is for football news My Media Files are uploaded to the app but 
> then disappear  like clubs logo here 
> https://arena3.herokuapp.com/8/clubpage/
> when i created any club logo appear but after minutes disappear 
> i don't mean files uploaded by the users ( but by me in admin dashboard)
>
> On Sunday, June 9, 2019 at 11:16:19 PM UTC+2, Joe Reitman wrote:
>>
>> Omar,
>>
>> Looking at your original request I misunderstood what you wanted to do. I 
>> thought you wanted to configure media files which are uploaded by the user. 
>>
>> For static files you have many free options to store them and put the 
>> links in your img tags. If you have a codepen.io account, you can upload 
>> your images to codepen and use the links generated by codepen. Another 
>> option is to install surge.sh and upload images to a surge static site and 
>> then use the links to the images. If that makes sense.
>>
>> I have used both options to store my static files in various projects. 
>> These options are good for testing and development.
>>
>> On Sunday, June 9, 2019 at 9:07:01 AM UTC-5, omar ahmed wrote:
>>>
>>> i installed Dropbox for django environment 
>>> but how to link an account and adjust settings 
>>> tutorial is not clear
>>> thanks
>>>
>>> On Saturday, June 8, 2019 at 8:23:08 PM UTC+2, Joe Reitman wrote:
>>>>
>>>> Follow the django-storages documentation. 
>>>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>>>>
>>>> It's easy to setup.
>>>>
>>>> On Saturday, June 8, 2019 at 8:23:17 AM UTC-5, omar ahmed wrote:
>>>>>
>>>>> ok joe  how can i use Dropbox for this issue ..
>>>>>
>>>>> On Saturday, June 8, 2019 at 2:59:20 AM UTC+2, Joe Reitman wrote:
>>>>>>
>>>>>> Omar,
>>>>>>
>>>>>> I use Dropbox which is free up to 2GB. I installed django-storages 
>>>>>> library to make setting up Dropbox easy.  
>>>>>>
>>>>>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>>>>>
>>>>>>> hii ..
>>>>>>> i deployed my first django app on Heroku 
>>>>>>> https://arena3.herokuapp.com/
>>>>>>> but my media files ( like club logo ) disappear or deleted ... 
>>>>>>> i found this article on Heroku 
>>>>>>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted
>>>>>>>   
>>>>>>>
>>>>>>> that means The Heroku filesystem is ephermal and i should use aws 
>>>>>>> but it's not free ?
>>>>>>> is there any solution ?
>>>>>>> how can i use Heroku postgres (addons) to upload my files 
>>>>>>> permanently .. thanks in advance
>>>>>>>
>>>>>>

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


Re: my file uploads missing/deleted

2019-06-09 Thread Joe Reitman
Omar,

Looking at your original request I misunderstood what you wanted to do. I 
thought you wanted to configure media files which are uploaded by the user. 

For static files you have many free options to store them and put the links 
in your img tags. If you have a codepen.io account, you can upload your 
images to codepen and use the links generated by codepen. Another option is 
to install surge.sh and upload images to a surge static site and then use 
the links to the images. If that makes sense.

I have used both options to store my static files in various projects. 
These options are good for testing and development.

On Sunday, June 9, 2019 at 9:07:01 AM UTC-5, omar ahmed wrote:
>
> i installed Dropbox for django environment 
> but how to link an account and adjust settings 
> tutorial is not clear
> thanks
>
> On Saturday, June 8, 2019 at 8:23:08 PM UTC+2, Joe Reitman wrote:
>>
>> Follow the django-storages documentation. 
>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>>
>> It's easy to setup.
>>
>> On Saturday, June 8, 2019 at 8:23:17 AM UTC-5, omar ahmed wrote:
>>>
>>> ok joe  how can i use Dropbox for this issue ..
>>>
>>> On Saturday, June 8, 2019 at 2:59:20 AM UTC+2, Joe Reitman wrote:
>>>>
>>>> Omar,
>>>>
>>>> I use Dropbox which is free up to 2GB. I installed django-storages 
>>>> library to make setting up Dropbox easy.  
>>>>
>>>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>>>
>>>>> hii ..
>>>>> i deployed my first django app on Heroku https://arena3.herokuapp.com/
>>>>> but my media files ( like club logo ) disappear or deleted ... 
>>>>> i found this article on Heroku 
>>>>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
>>>>>
>>>>> that means The Heroku filesystem is ephermal and i should use aws but 
>>>>> it's not free ?
>>>>> is there any solution ?
>>>>> how can i use Heroku postgres (addons) to upload my files permanently 
>>>>> .. thanks in advance
>>>>>
>>>>

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


Re: my file uploads missing/deleted

2019-06-08 Thread Joe Reitman
Follow the django-storages documentation. 
https://django-storages.readthedocs.io/en/latest/backends/dropbox.html

It's easy to setup.

On Saturday, June 8, 2019 at 8:23:17 AM UTC-5, omar ahmed wrote:
>
> ok joe  how can i use Dropbox for this issue ..
>
> On Saturday, June 8, 2019 at 2:59:20 AM UTC+2, Joe Reitman wrote:
>>
>> Omar,
>>
>> I use Dropbox which is free up to 2GB. I installed django-storages 
>> library to make setting up Dropbox easy.  
>>
>> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>>
>>> hii ..
>>> i deployed my first django app on Heroku https://arena3.herokuapp.com/
>>> but my media files ( like club logo ) disappear or deleted ... 
>>> i found this article on Heroku 
>>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
>>>
>>> that means The Heroku filesystem is ephermal and i should use aws but 
>>> it's not free ?
>>> is there any solution ?
>>> how can i use Heroku postgres (addons) to upload my files permanently .. 
>>> thanks in advance
>>>
>>

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


Re: my file uploads missing/deleted

2019-06-07 Thread Joe Reitman
Omar,

I use Dropbox which is free up to 2GB. I installed django-storages library 
to make setting up Dropbox easy.  

On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>
> hii ..
> i deployed my first django app on Heroku https://arena3.herokuapp.com/
> but my media files ( like club logo ) disappear or deleted ... 
> i found this article on Heroku 
> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
> that means The Heroku filesystem is ephermal and i should use aws but it's 
> not free ?
> is there any solution ?
> how can i use Heroku postgres (addons) to upload my files permanently .. 
> thanks in advance
>

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


Re: Form with CheckBoxSelectMultiple not validating

2019-06-07 Thread Joe Reitman
Can you show the code?

On Friday, June 7, 2019 at 1:57:23 PM UTC-5, Dube Software wrote:
>
> I have a form with a CheckBoxSelectMultiple widget. When I select choices 
> and submit the form, `is_valid()` returns False. What could be the cause?
>
> Kind regards,
> Lloyd
>
> *Sent with Shift 
> *
>

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


Re: DateInput not accepting format argument

2019-06-07 Thread Joe Reitman
Or a better option is to use a third party app such as 
https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/index.html

On Friday, June 7, 2019 at 1:05:04 PM UTC-5, Joe Reitman wrote:
>
> Try this:
>
> in settings.py
>
> USE_L10N = False
>
> USE_TZ = True
>
> DATE_INPUT_FORMATS = ['%B %d, %Y']
>
>
> In forms.py
>
> start_date = forms.DateField(
> widget=forms.DateInput(attrs={'placeholder': 'October 24, 2019'}),
> )
>
>
> On Friday, June 7, 2019 at 5:36:30 AM UTC-5, Dube Software wrote:
>>
>> Hi,
>>
>> I have a form with a start_date field of type DateField (widget is 
>> DateInput).
>>
>> When I specify a format argument, the input does not render as specified. 
>> The format is always -MM-DD. My code is as follows:
>>
>> ```
>> start_date = forms.DateField(
>> label='Start date',
>> widget=forms.widgets.DateInput(
>> format='%d %B, %Y',
>> attrs = {
>> 'type': 'date',
>> }
>> )
>> )
>> ```
>> What am I missing?
>>
>> Kind regards,
>> Lloyd
>>
>> *Sent with Shift 
>> <https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>*
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28af33d7-359a-499e-9576-2729fc742ce8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DateInput not accepting format argument

2019-06-07 Thread Joe Reitman
Try this:

in settings.py

USE_L10N = False

USE_TZ = True

DATE_INPUT_FORMATS = ['%B %d, %Y']


In forms.py

start_date = forms.DateField(
widget=forms.DateInput(attrs={'placeholder': 'October 24, 2019'}),
)


On Friday, June 7, 2019 at 5:36:30 AM UTC-5, Dube Software wrote:
>
> Hi,
>
> I have a form with a start_date field of type DateField (widget is 
> DateInput).
>
> When I specify a format argument, the input does not render as specified. 
> The format is always -MM-DD. My code is as follows:
>
> ```
> start_date = forms.DateField(
> label='Start date',
> widget=forms.widgets.DateInput(
> format='%d %B, %Y',
> attrs = {
> 'type': 'date',
> }
> )
> )
> ```
> What am I missing?
>
> Kind regards,
> Lloyd
>
> *Sent with Shift 
> *
>

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


Re: How to fix: Django forms: {{ form }} is not working in a dynamic html page

2019-06-06 Thread Joe Reitman
Update. 

You can do this by hard coding the HTML form in the template. If you want 
to gather the data a user enters, each form will have to be uniquely 
identifiable and your view will have to determine which form its getting 
post data from. You can put the card index number in the button value and 
code your view to handle it based on the button value. 


On Thursday, June 6, 2019 at 11:07:18 PM UTC-5, Joe Reitman wrote:
>
> Interesting problem. It won't display because the form is inside a 
> for-loop. Django Template language looks at variables inside a for-loop 
> differently. Basically it looks for a collection. Since {{ form }} is not a 
> collection, it just ignores it.
>
> I'm not sure how you can create multiple forms like that. But I would be 
> interested in knowing. 
>
>
> On Thursday, June 6, 2019 at 6:14:57 PM UTC-5, Majid Rafiee wrote:
>>
>> I've created a form in Django:
>>
>> #forms.py
>> from django import forms
>>
>>
>> class ContactForm(forms.Form):
>> name = forms.CharField()
>> number = forms.FloatField()
>> eail_user = forms.EmailField()
>>
>>
>> and imported in in views.py
>>
>> #views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom 
>> cards.forms import ContactForm
>>
>> def index(request):
>> cards = Cards.objects.all()
>> return render(request,'card.html', {'cards':cards})
>>
>> def contact(request):
>> form = ContactForm()
>> return render(request,'card.html', {'form': form})
>>
>> This is my base.html
>>
>> #base.html
>> {%  load staticfiles %}
>> 
>> 
>> 
>> > href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
>> rel="stylesheet" id="bootstrap-css">
>> > src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js">
>> > src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
>> > type="text/css">
>> 
>> 
>> Title
>> 
>> 
>> 
>> 
>> OUR TEAM
>> 
>> {% block content %}
>> {% endblock %}
>> 
>> 
>> 
>> 
>> 
>>
>>
>> And here is the card.html that is extended from base.html
>>
>> #card.html
>> {% extends 'base.html' %}
>>
>> {% block content %}
>> 
>> {% for card in cards %}
>> 
>> 
>> > ontouchstart="this.classList.toggle('hover');">
>> 
>> 
>> 
>> 
>> > 
>> src="https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png;
>> alt="card image">
>> {{ card.name }}
>> {{ card.description 
>> }}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> {{ card.name }}
>> 
>> 
>> {% csrf_token %}
>> {{ form }}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>   

Re: How to fix: Django forms: {{ form }} is not working in a dynamic html page

2019-06-06 Thread Joe Reitman
Interesting problem. It won't display because the form is inside a 
for-loop. Django Template language looks at variables inside a for-loop 
differently. Basically it looks for a collection. Since {{ form }} is not a 
collection, it just ignores it.

I'm not sure how you can create multiple forms like that. But I would be 
interested in knowing. 


On Thursday, June 6, 2019 at 6:14:57 PM UTC-5, Majid Rafiee wrote:
>
> I've created a form in Django:
>
> #forms.py
> from django import forms
>
>
> class ContactForm(forms.Form):
> name = forms.CharField()
> number = forms.FloatField()
> eail_user = forms.EmailField()
>
>
> and imported in in views.py
>
> #views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom 
> cards.forms import ContactForm
>
> def index(request):
> cards = Cards.objects.all()
> return render(request,'card.html', {'cards':cards})
>
> def contact(request):
> form = ContactForm()
> return render(request,'card.html', {'form': form})
>
> This is my base.html
>
> #base.html
> {%  load staticfiles %}
> 
> 
> 
>  href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
> rel="stylesheet" id="bootstrap-css">
>  src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js">
>  src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
>  type="text/css">
> 
> 
> Title
> 
> 
> 
> 
> OUR TEAM
> 
> {% block content %}
> {% endblock %}
> 
> 
> 
> 
> 
>
>
> And here is the card.html that is extended from base.html
>
> #card.html
> {% extends 'base.html' %}
>
> {% block content %}
> 
> {% for card in cards %}
> 
> 
>  ontouchstart="this.classList.toggle('hover');">
> 
> 
> 
> 
>  
> src="https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png;
> alt="card image">
> {{ card.name }}
> {{ card.description 
> }}
>  class="fa fa-plus">
> 
> 
> 
> 
> 
> 
> {{ card.name }}
> 
> 
> {% csrf_token %}
> {{ form }}
> 
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> {% endfor %}
>
> {% endblock %}
>
>
> As you may notice, I've called form by {{ form }} inside  tag in 
> card.html but the issue is that it just shows a Submit botton and ignores 
> {{ form }}. Any idea how to solve the issue?
> I also bring urls.py in cards app and main urls:
> #urls.py in cards
> from django.urls import path
> from . import views
>
>
> urlpatterns = [
>  path('', views.index),
>  path('form/', views.contact),
> ]
>
>
> #urls.py in main directory
>
> from django.contrib import admin
> from django.urls import path, include
>
>
> urlpatterns = [
>  path('admin/', admin.site.urls),
>  path('calculator_one_input/', include('calculator_one_input.urls')),
>  path('cards/', include('cards.urls')),
>  path('cards/form/', include('cards.urls')),
> ]
>
>
> I looked for a solution for three days and still I have no idea how to 
> solve this issue. I will be so appreciated if someone give me a clear clue 
> how to solve. Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To 

Re: Import circular

2019-06-06 Thread Joe Reitman
Can you post your views.py, urls.py and template?

On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>
> django.core.exceptions.ImproperlyConfigured: The included URLconf 
> 'simplemooc.urls' does not appear to have any patterns in it. If you see 
> valid patterns in the file then the issue is probably caused by a circular 
> import.
>
>

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


Re: While registering the user with django form, it gives "UNIQUE constraint failed: auth_user.username" error

2019-06-05 Thread Joe Reitman
The problem with Jaydeep's code is the 'username' field is not getting 
populated in the auth_user table. Django auth_user table by default must 
have unique usernames. Username is what Django authenticates to by default. 

Jaydeep was able to enter the initial user with email, firstname and 
lastname once because he left 'username' field blank. The second time 
failed because there is already a blank 'username' causing it to throw the 
Unique Constraint error. 

Also, as this code is written the 'userprofileinfo' table is not getting 
populated with any data.



On Tuesday, June 4, 2019 at 8:24:30 AM UTC-5, Flexian_me wrote:
>
> Consider we want another attribute in user model other than what is 
> already available, for example height or weight. Still this code is giving 
> error and focus should be to solve the issue that OP is facing. I am also 
> facing same issue and trying to figure it out.
> @Jaydeep Did you get to solve the issue somehow?
>
> Thanks!
>
> On Saturday, 18 May 2019 04:01:56 UTC+5:30, Joe Reitman wrote:
>>
>> I'm not sure what your objective is but you don't need to create another 
>> model to store user data. User data is stored in the auth.models. It has 
>> fields already available for what your trying to accomplish. 
>>
>> On Saturday, October 6, 2018 at 8:28:09 AM UTC-5, Jaydeep Borkar wrote:
>>>
>>> When I try to register a user using Django form, it gives me "UNIQUE 
>>> constraint failed: auth_user.username". When I tried registering the first 
>>> user, it worked, but I couldn't see that entry in my database. When I tried 
>>> registering the second user, it's giving me this error. Please, help me 
>>> through this. I have spent a considerable amount of time on this and I'm 
>>> stuck. 
>>>
>>> This is my code: 
>>>
>>> forms.py 
>>> from django import forms
>>> from django.contrib.auth.models import User
>>> from volunteer.models import UserProfileInfo
>>>
>>> class UserForm(forms.ModelForm):
>>>
>>> class Meta():
>>> model = User
>>> fields = ('email','first_name','last_name')
>>>
>>>
>>>
>>>
>>> views.py 
>>> from django.shortcuts import render
>>> from volunteer.forms import UserForm
>>>
>>>  
>>>
>>> def register(request):
>>>
>>> registered = False
>>>
>>> if request.method =="POST" :
>>> user_form = UserForm(data=request.POST)
>>>
>>> if user_form.is_valid():
>>>
>>> user = user_form.save()
>>> user.save()
>>>
>>> registered = True
>>>
>>> else:
>>> print(user_form.errors)
>>>
>>> else:
>>> user_form = UserForm()
>>>
>>> return render(request, 'volunteer/volunteer.html',
>>>  {'user_form':user_form,
>>>   'registered':registered})
>>>
>>>  
>>>   
>>>
>>>
>>> 
>>>
>>>
>>>
>>> models.py 
>>> from django.db import models
>>> from django.contrib.auth.models import User
>>>
>>> class UserProfileInfo(models.Model):
>>>
>>> user=models.OneToOneField(User)
>>>
>>> def __str__(self):
>>> return self.user.first_name
>>> return self.user.last_name
>>> return self.user.email
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> urls.py
>>> from django.conf.urls import url
>>>
>>> from . import views
>>>
>>> app_name = 'volunteer'
>>>
>>> urlpatterns = [
>>>
>>>  url(r'^', views.register, name='register'),
>>> ]
>>>
>>>
>>>
>>> admin.py
>>> from django.contrib import admin
>>> from volunteer.models import UserProfileInfo
>>>
>>> # Register your models here.
>>> admin.site.register(UserProfileInfo)
>>>
>>>
>>>
>>> volunteer.html file which has the user form
>>> 
>>> 
>>> 
>>> 
>>>  
>>>  
>>> 
>>>
>>>  
>>> https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css;>
>>> https://ajax.googleapis.com/ajax/libs/jquery/3.

Re: advantage of angular js with django??

2019-05-31 Thread Joe Reitman
AngularJS is a Single Page App (SPA) framework. You can use Django along 
with Django Rest API package as the backend to your Angular app. The 
biggest advantage is you can create, change or have multiple frontend 
systems on different platforms without having to make changes to your 
Django backend. For example you can create an AngularJS web app and a React 
Native app for iOS using the same Django backend.

On Friday, May 31, 2019 at 2:43:25 AM UTC-5, Pradeep Singh wrote:
>
> What are the advantages of using AngularJS with Django?
>

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


Re: problem with form

2019-05-29 Thread Joe Reitman
Can you post the error?

On Tuesday, May 28, 2019 at 6:22:30 PM UTC-5, Saeed Pooladzadeh wrote:
>
> Hi
>
> I'm trying to make a simple crud applicatio and learn from it. I wonder 
> why my form can't save the data. Here cames my view:
>
> from django.shortcuts import render
> from saeed.forms import SmodelForm  
> from saeed.models import Smodel
> from django.shortcuts import render, redirect  
>
>
>
> # Create your views here.
> def emp(request):  
> if request.method == "POST":  
> form = SmodelForm(request.POST)  
> if form.is_valid():  
> try:  
> form.save()  
> return redirect('/show')  
> except  AssertionError as error:
> 
> print(error)
> pass
>
>  
> 
>
> 
> else:  
> form = SmodelForm()  
> return render(request,'saeed/index.html',{'form':form})  
> #
> def show(request):  
> smodels = Smodel.objects.all()  
> return render(request,'saeed/show.html',{'smodels':smodels}) 
> #
>
> def edit(request, id):  
> smodels = Smodel.objects.get(id=id)  
> return render(request,'saeed/edit.html', {'smodels':smodels})  
> #---
>
> def update(request, id):  
> smodels = Smodel.objects.get(id=id)  
> form = SmodelForm(request.POST, instance = smodels)  
> if form.is_valid():  
> form.save()  
> return redirect("/show")  
> return render(request,'saeed/edit.html',{'smodels':smodels})  
>
> #-
> def destroy(request, id):  
> smodels = Smodel.objects.get(id=id)  
> smodels.delete()  
> return redirect("/show")  
>
>
> and here cames the complete app:
>
>
> https://ln.sync.com/dl/1bf7658d0/pw69mf37-yk85kjaa-qprd4xdx-m8em4rxk
>
> can you please inform me where is wrong?
>
> thanks
>
> thanks
>

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


Re: Template not showing my post details

2019-05-29 Thread Joe Reitman
What does your view look like?

On Wednesday, May 29, 2019 at 4:26:55 AM UTC-5, cixtus anyanwu wrote:
>
> Help me out here. Whats wrong with django?
>

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


Re: URL conf error

2019-05-29 Thread Joe Reitman
The problem is probably with your view or a naming issue. You also have 
problems pointed out by others with the syntax in your urls. Good luck.

On Wednesday, May 29, 2019 at 7:17:23 AM UTC-5, Madhur Kabra wrote:
>
> Thanks for your answer, I have imported the views correctly, and made the 
> changes what you suggested. But its' still not working
>
> On Wednesday, May 29, 2019 at 12:53:31 AM UTC+5:30, Victor H. Velasquez 
> Rizo wrote:
>>
>> Hi Madhur.
>>
>> On your urls.py,
>> *change: *url('^$', views.index, name=index),
>> *to:* url('^$', views.index, name="index"),
>>
>> I assume that you imported the *views.*
>>
>> On Tue, May 28, 2019 at 12:31 PM Madhur Kabra  
>> wrote:
>>
>>> I am getting the url conf error. I  have attached the relevant files. 
>>> Thanks for the assistance
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/37eedb50-637a-45bf-839a-cbe52a410f4e%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> -- 
>>
>>
>>
>> Atte...,.
>> Vìctor Hugo Velàsquez Rizo
>> Cali - Colombia
>>
>

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


Re: URL conf error

2019-05-28 Thread Joe Reitman
What do your views look like?

I see you have an app named 'music' in your project URL Config that 
includes 'music.urls'. Your music app URL Config has a single view that 
calls the index view. When you type 127.0.0.1/music/ in the browser address 
bar you should see your index page. Is the index view setup correctly?  

On Tuesday, May 28, 2019 at 12:31:35 PM UTC-5, Madhur Kabra wrote:
>
> I am getting the url conf error. I  have attached the relevant files. 
> Thanks for the assistance
>

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


Re: Display image in template

2019-05-28 Thread Joe Reitman
Have you looked in inspector on your browser to see if the URL is correctly 
rendered in IMG SRC?
Have you installed Pillow? ImageField requires python Pillow.

On Tuesday, May 28, 2019 at 1:38:49 PM UTC-5, Anchal Agarwal wrote:
>
> Thanks for the answer but  I have already set the MEDIA path 
> here is my urls.py
> from . import settings
> from django.contrib.staticfiles.urls import static
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> urlpatterns += staticfiles_urlpatterns()
> urlpatterns += static(settings.MEDIA_URL, document_root
> =settings.MEDIA_ROOT)
>
> models.py
> from django.db import models
>
> class Album(models.Model):
> artist = models.CharField(max_length=250)
> album_title = models.CharField(max_length=500)
> genre=models.CharField(max_length=100)
> album_logo = models.ImageField(upload_to="gallery")
>
> def __str__(self):
> return self.album_title 
>
>
>  settings.py
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
> MEDIA_ROOT=os.path.join(BASE_DIR,'media')
> MEDIA_URL= '/media/'
>
> On Tue, May 28, 2019 at 11:42 PM Anirudh Jain  > wrote:
>
>> You will have to setup MEDIA path f8rst. All your uploded files will be 
>> stored in that folder. STATIC path is used only for, well, static content 
>> like css and js.
>>
>> On Tue, 28 May 2019, 23:31 anchal agarwal, > > wrote:
>>
>>> I want to display image dynamically from the database in a django 
>>> template. I have used ImageField for this purpose. The code shows no error 
>>> but it is only displaying an icon of image.
>>> This is my template file,
>>> here album is the context and album_logo is the variable in which i have 
>>> stored my image. please tell me how can i fix this issue
>>> 
>>>
>>> {{ album.album_title}}
>>> {{ album.artist }}
>>>
>>> 
>>> {% for song in album.song_set.all %}
>>> {{song.song_title}}-{{song.file_type}}
>>> {% endfor %}
>>> 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: How to use permissions on a CreateView class?

2019-05-28 Thread Joe Reitman
Fellipe,

Here is an example of decorating class based views from the documentation 

:

from django.contrib.auth.decorators import login_requiredfrom 
django.utils.decorators import method_decoratorfrom django.views.generic import 
TemplateView
class ProtectedView(TemplateView):
template_name = 'secret.html'

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)


On Tuesday, May 28, 2019 at 6:54:38 AM UTC-5, Fellipe Henrique wrote:
>
> Hello,
>
> I have these class, based on CreateView class... and I only want allow 
> user with these permissions to add record...
>
> class ClienteCreateView(ERPbrViewMixin, CreateView):
> template_name = 'cadastro/cliente/form.html'
> permission_required = ('cliente.can_open', 'cliente.can_edit', 
> 'cliente.can_add')
> model = Cliente
> form_class = ClienteForm
>
> But, not working... user without these permission, when type the url show 
> the form...
>
> Any tips how to do that?
>
> Cheers!
>
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh 
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>

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


Re: What's wrong with this model

2019-05-28 Thread Joe Reitman
By default CharField is not Nullable meaning it can't be created with out 
some data in it. 

You have two options:
Make field nullable:  blank=True
Or add a default: default=default_text

On Monday, May 27, 2019 at 4:52:19 PM UTC-5, Saeed Pooladzadeh wrote:
>
> Hello
>
> I made this model and think everything is fine:
>
> class Smodel(models.Model):
>
> eid=models.AutoField(primary_key=True)
># eid=models.IntegerField(default=0)
> elogin = models.CharField(max_length=8) 
> epassword= models.CharField(max_length=8) 
>   
> elikeDay=models.IntegerField(default=0)
> efollowPerDay=models.IntegerField(default=0)
> 
>
>
> #esession = models.TextField()
> class Meta:  
> db_table = "saeed"  
>
>
>   'But when I try to 'make migration 
> I get this error:
>
> You are trying to add a non-nullable field 'elogin' to smodel 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.py
> Select an option: 
>
>
> *What is wrong with this model and how can I resolve it?*
>
> regards,
> Saeed 
>

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


Re: deploy to Heroku " collectstatic --noinput "

2019-05-27 Thread Joe Reitman
Is there a question here? I will point out what I see wrong in Settings.py.

Allowed_hosts is empty. Need the host domain.
Missing Port number for your database
Did you migrate your models?
Secret key should be stored in environment variable



On Sunday, May 26, 2019 at 4:34:54 PM UTC-5, omar ahmed wrote:
>
> git push heroku master
> Counting objects: 4, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (4/4), done.
> Writing objects: 100% (4/4), 414 bytes | 0 bytes/s, done.
> Total 4 (delta 3), reused 0 (delta 0)
> remote: Compressing source files... done.
> remote: Building source:
> remote: 
> remote: -> Python app detected
> remote: -> Installing requirements with pip
> remote: 
> remote: -> $ *python manage.py collectstatic --noinput*
> remote:122 static files copied to 
> '/tmp/build_ae5c33e3156cddd5969268ac72b87668/staticfiles', 392 
> post-processed.
> remote: 
> remote: -> Discovering process types
> remote:Procfile declares types -> web
> remote: 
> remote: -> Compressing...
> remote:Done: 55.3M
> remote: -> Launching...
> remote:Released v12
> remote:https://arena3.herokuapp.com/ deployed to Heroku
> remote: 
> remote: Verifying deploy... done.
> To https://git.heroku.com/arena3.git
>48d580d..0dcd3ad  master -> master
>
> settings.py
>
> """
> Django settings for arena project.
>
> Generated by 'django-admin startproject' using Django 2.2.1.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/2.2/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/2.2/ref/settings/
> """
>
> import os
> import django_heroku
> import dj_database_url
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '=l$6@=a%bu(--=pgd)-i!(%-ik&%7k11l_7*3j11eln'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'core.apps.CoreConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django_social_share',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'whitenoise.middleware.WhiteNoiseMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'arena.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR,'templates')],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> 'core.context_processors.add_to_base',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'arena.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> 'NAME': 'arenadb',
>  'USER': 'arenaomar',
>  'PASSWORD': '',
>  'HOST': 'localhost',
>  'PORT': '',
> }
> }
>
>
> # Password validation
> # 
> https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
> ,
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'
> ,
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/2.2/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/2.2/howto/static-files/
>
>
> PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
> STATIC_URL = '/static/'
> STATIC_ROOT = os.path.join(BASE_DIR, 'static')
> STATICFILES_STORAGE = 
> 'whitenoise.storage.CompressedManifestStaticFilesStorage'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> MEDIA_URL = '/media/'
> MEDIA_ROOT = 

Re: Unwelcome error!

2019-05-20 Thread Joe Reitman
You need to run makemigrations and migrate to create the tables django 
uses. 

On Monday, May 20, 2019 at 5:22:08 PM UTC-5, Stephen Owen wrote:
>
> Hi, all,
> I am creating a blog in Django, following lectures on You Tube.  
> Everything was working fine and then an error occurred that I could 
> fathom.  So I have now just started a new project.  One accessing 
> localhost, I got the expected page but when I tried localhost I got this 
> (attached.)
> Any diea what is happening?  The first project was fine up until I 
> probably coded something in teh wrong place.
>
>

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


Re: Customising django user model

2019-05-20 Thread Joe Reitman
You can customize the user table by extending AbstractUser and add the 
fields you want to add (gender, phone)

I have a custom user example adding age field:

from django.db import models
from django.contrib.auth.models import AbstractUser

class CustomUser(AbstractUser):
   age = models.PositiveIntegerField(null=True, blank=True) 


On Sunday, May 19, 2019 at 12:13:08 PM UTC-5, Sipum wrote:
>
> Hello Friends,
>
> I want to customise django default user table and which should consist of 
> name,phone, email and gender.
> And after that when every time a user logs in, he/she should able to log 
> in through an OTP to phone or email.
>
> can anyone guide me  What to do here.??
>
> Thanks.
> Sipum
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/24afe883-98b9-4bfc-a9fe-284c7a6cb771%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations File too Large preventing Migrate

2019-05-20 Thread Joe Reitman
Can you show us the model your trying to migrate?

On Sunday, May 19, 2019 at 9:11:47 PM UTC-5, Yoo wrote:
>
> In Django 2.2, I run makemigrations then migrate. I wait approx. 5-7 
> minutes and then I get "Fatal Python error: Cannot recover from stack 
> overflow." "Current thread 0x0002094 (most recent call first):" yada yada 
> "File "manage.py", line 17 in main "File manage.py line 21 in "
>
>
> End. I check the migrations file and the file is 4000 lines of code large. 
> What do I do in this case? Should I make my own migration files, and if so, 
> how?
>

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


Re: While registering the user with django form, it gives "UNIQUE constraint failed: auth_user.username" error

2019-05-17 Thread Joe Reitman
I'm not sure what your objective is but you don't need to create another 
model to store user data. User data is stored in the auth.models. It has 
fields already available for what your trying to accomplish. 

On Saturday, October 6, 2018 at 8:28:09 AM UTC-5, Jaydeep Borkar wrote:
>
> When I try to register a user using Django form, it gives me "UNIQUE 
> constraint failed: auth_user.username". When I tried registering the first 
> user, it worked, but I couldn't see that entry in my database. When I tried 
> registering the second user, it's giving me this error. Please, help me 
> through this. I have spent a considerable amount of time on this and I'm 
> stuck. 
>
> This is my code: 
>
> forms.py 
> from django import forms
> from django.contrib.auth.models import User
> from volunteer.models import UserProfileInfo
>
> class UserForm(forms.ModelForm):
>
> class Meta():
> model = User
> fields = ('email','first_name','last_name')
>
>
>
>
> views.py 
> from django.shortcuts import render
> from volunteer.forms import UserForm
>
>  
>
> def register(request):
>
> registered = False
>
> if request.method =="POST" :
> user_form = UserForm(data=request.POST)
>
> if user_form.is_valid():
>
> user = user_form.save()
> user.save()
>
> registered = True
>
> else:
> print(user_form.errors)
>
> else:
> user_form = UserForm()
>
> return render(request, 'volunteer/volunteer.html',
>  {'user_form':user_form,
>   'registered':registered})
>
>  
>   
>
>
> 
>
>
>
> models.py 
> from django.db import models
> from django.contrib.auth.models import User
>
> class UserProfileInfo(models.Model):
>
> user=models.OneToOneField(User)
>
> def __str__(self):
> return self.user.first_name
> return self.user.last_name
> return self.user.email
>
>
>
>
>
>
>
> urls.py
> from django.conf.urls import url
>
> from . import views
>
> app_name = 'volunteer'
>
> urlpatterns = [
>
>  url(r'^', views.register, name='register'),
> ]
>
>
>
> admin.py
> from django.contrib import admin
> from volunteer.models import UserProfileInfo
>
> # Register your models here.
> admin.site.register(UserProfileInfo)
>
>
>
> volunteer.html file which has the user form
> 
> 
> 
> 
>  
>  
> 
>
>  
> https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css;>
> https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
> ">
> https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js
> ">
>  https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js
> ">
>  
>   
>  
>   
>
>  
> {% if registered %}
>Thanks!
> {% else %}
>   Register
>
>
>  
> {% csrf_token %}
> {{ user_form.as_p }}
>  
>
>  {% endif %}
>
>   
>
>  
>  
>
> 
>  
>
>
>
> I feel there's some problem in views.py or models.py, or volunteer.html. 
> or maybe something else. Please, guide me through this. 
> Thanks in advance. 
>

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


Re: Django Model Forms.

2019-05-17 Thread Joe Reitman
In your template you can identify each field by its name and use a table to 
render them in columns. e.g.

table
  table row
table data {{ form.username }}
table data {{ form.password }}

On Friday, May 17, 2019 at 2:23:14 AM UTC-5, kimeualexis wrote:
>
> Hello, guys.
> Is there a way to lay out Django Model form fields across the Browser 
> rather than top-down?
>
> Kindly assist.
>

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


Re: i am new i want full details of Django

2019-05-16 Thread Joe Reitman
This book really helped me get started. 
"Django for Beginners: Build websites with Python and Django" by William S. 
Vincent.

https://www.amazon.com/Django-Beginners-Build-websites-Python-ebook/dp/B079ZZLRRL/ref=pd_sim_351_1/147-5244532-7545404?_encoding=UTF8_rd_i=B079ZZLRRL_rd_r=2fb5f10a-77f0-11e9-8772-d5659328fe72_rd_w=7pdZP_rd_wg=Uufxb_rd_p=90485860-83e9-4fd9-b838-b28a9b7fda30_rd_r=8RQECXHSQNS75GGFK4CR=1=8RQECXHSQNS75GGFK4CR

On Thursday, May 16, 2019 at 9:00:02 AM UTC-5, Sanjay K wrote:
>
> could u please provide the basic books
>

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


Re: Any open source project for beginner to start with ?

2019-05-16 Thread Joe Reitman
Looks good on mobile. Nice job.

On Thursday, May 16, 2019 at 9:00:18 AM UTC-5, himanshu chouhan wrote:
>
> I've already hosted it on heroku -
> http://bit.ly/2VHL3Iu
>
> On Thu, May 16, 2019 at 6:58 AM Joe Reitman  > wrote:
>
>> Do you have your website available to see on github?
>>
>> On Wednesday, May 15, 2019 at 3:44:30 PM UTC-5, himanshu chouhan wrote:
>>>
>>> Hi All,
>>>
>>> I know this ppl discuss really important issue here, I'm trying my luck 
>>> in django, if anyone could suggest me any open-source project to start with 
>>> or else if anyone is open to collaboration with their project, please do 
>>> tell
>>>
>>> I have built a fully functional django + bootstrap website and looking 
>>> for opportunity to learn further more. Any help would be much appreciated.
>>>
>>> Regards
>>> himanshu
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a3569f3c-28a4-4781-b11f-63d00be3bc61%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/a3569f3c-28a4-4781-b11f-63d00be3bc61%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: Any open source project for beginner to start with ?

2019-05-15 Thread Joe Reitman
Do you have your website available to see on github?

On Wednesday, May 15, 2019 at 3:44:30 PM UTC-5, himanshu chouhan wrote:
>
> Hi All,
>
> I know this ppl discuss really important issue here, I'm trying my luck in 
> django, if anyone could suggest me any open-source project to start with or 
> else if anyone is open to collaboration with their project, please do tell
>
> I have built a fully functional django + bootstrap website and looking for 
> opportunity to learn further more. Any help would be much appreciated.
>
> Regards
> himanshu
>

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


Re: How to reengage pycharm command line to run >'py manage.py migrate'?

2019-05-14 Thread Joe Reitman
Open up another terminal by clicking the '+' sign.

On Tuesday, May 14, 2019 at 12:31:32 PM UTC-5, jos.jwj wrote:
>
> Hello fellow community members,
>
> I am a fresher working on a project in pycharm on a Lenovo system. 
> Everything seems to be going as django wold indicate however after running 
> code.
> c:/users/Joseph/django example-project> py manage.py runserver
> ...starting development server
> my command line 'c:/users/Joseph/django example-project>' never comes back 
> up, so I can't run my migrations, or any other line of code. any advice on 
> to fix  this fix would be appreciated.  Thank you, 
> Joseph
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4aba67c6-26cf-4b65-8e8c-1db453fca624%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: formfield_overrides doesn't work

2019-05-12 Thread Joe Reitman
Tim,

I found this in the Django source code on Github searching for 
'formfield_overrides'. It is in a test module testing formfield_overrides 
functionality. I'm assuming you imported TextInput from forms? This should 
work to change your *admin* display. Are trying to change your Admin panel 
form or a form going out to the user?


class BandAdmin(admin.ModelAdmin):
 formfield_overrides = {
 CharField: {'widget': forms.TextInput(attrs={'size': '10'})}
 }


Regards,
Joe

On Saturday, May 11, 2019 at 2:10:06 PM UTC-5, tim042849 wrote:
>
>  2.1.5 with python 3.7.2 
>
> I have a models.py class as follows: 
> class Article(models.Model): 
> title = models.CharField(max_length=255,) 
>  
> And I want to override the rendered default size attribute to 100 in 
> the input/text form field. 
>
> the template rendering is done as follows 
>  
> {% csrf_token %} 
> {{ form.as_p}} 
> Save 
>  
>
> in the application admin.py I have the following: 
> class ArticleAdmin(admin.ModelAdmin): 
> formfield_overrides = { 
> models.CharField: {'widget': TextInput(attrs={'size': '100'}), }, 
> } 
> # registered as 
> admin.site.register(Article, ArticleAdmin) 
>
> Sadly it appears to have no effect. 
> Viewing the rendered source, I do not see a size attribute. 
> the field is rendered as: 
>  
>
> Have I ommited a step? 
> thanks 
> -- 
> Tim Johnson 
> http://www.tj49.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97e5ce92-a476-467f-a323-a724c16c8421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: formfield_overrides doesn't work

2019-05-12 Thread Joe Reitman
Tim,

Here is an example of a custom form field limiting the input to 100 
characters. The model is defined to accept 255 chars. BTW, the text widget 
'attrs' sets the HTML form element attributes.

class SearchForm(forms.Form):

 search_for = forms.CharField(
 label='',
 label_suffix='',
 max_length=100,
 required=True,
 widget=forms.TextInput(attrs={'placeholder': 'search', ' autofocus': ''}),
 help_text='',
 error_messages={'required': ''},
 )


On Saturday, May 11, 2019 at 2:10:06 PM UTC-5, tim042849 wrote:
>
> django 2.1.5 with python 3.7.2 
>
> I have a models.py class as follows: 
> class Article(models.Model): 
> title = models.CharField(max_length=255,) 
>  
> And I want to override the rendered default size attribute to 100 in 
> the input/text form field. 
>
> the template rendering is done as follows 
>  
> {% csrf_token %} 
> {{ form.as_p}} 
> Save 
>  
>
> in the application admin.py I have the following: 
> class ArticleAdmin(admin.ModelAdmin): 
> formfield_overrides = { 
> models.CharField: {'widget': TextInput(attrs={'size': '100'}), }, 
> } 
> # registered as 
> admin.site.register(Article, ArticleAdmin) 
>
> Sadly it appears to have no effect. 
> Viewing the rendered source, I do not see a size attribute. 
> the field is rendered as: 
>  
>
> Have I ommited a step? 
> thanks 
> -- 
> Tim Johnson 
> http://www.tj49.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9bd73f0f-a944-4a0e-9c2e-2ea2db7974c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static files won't match the path given

2019-05-12 Thread Joe Reitman
Configuring static files can be a headache. I personally use Whitenoise 
 to serve my static files. It is 
self contained and can be configured in Django settings after installation. 

A couple of advantages of Whitenoise:

1. During development you can override the Django's static file server by 
putting 'whitenoise.runserver_nostatic' in Installed Apps. This way you can 
have the same behaviour on your local machine as you'll have on your hosted 
server.
2. You don't have to mess with Apache or Nginx settings. 

On Saturday, May 11, 2019 at 12:23:11 AM UTC-5, Rookies DJ wrote:
>
> I apologise, I'm a hardware engineer, I'm not very familiar with coding; 
> I'm only on Django for the past 5 months. (under my boss order)
>
> I had managed to develop and establish a Django App, and manage to upload 
> it to remote server *NameCheap*. There on the server, the issue is unable 
> to locate the static files. Even when we directed the path to static files 
> folder.
>
> This static files, infrequently work and load the static, that's how we 
> concluded the static error was caused by the misdirection of the path.
>
> But reading over the Django documentary multiple time didn't help resolve 
>
> Please help our team had been trying resolve this issue for past 2months 
>

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


Re: How to use Django with python-requests to fetch data from google api?

2019-05-10 Thread Joe Reitman
Krystian,

I got this work by changing the template tag name variables and removing 
the if statement. Since 'authors' is a list, you could send the entire list 
to the template and do a for-loop to render all the authors.

def api(request):
 query = request.GET
 response = requests.get('https://www.googleapis.com/books/v1/volumes/' + 
query['book'])
 book = response.json()
 return render(request, 'books/api.html', {
 'title': book['volumeInfo']['title'],
 'authors': book['volumeInfo']['authors'][0]
 })



{% block content %}
Google books API

 
 search on google books api


 {{ title }} - {{ authors }} 

{% endblock %}


Output

[image: Screen Shot 2019-05-10 at 9.47.13 AM.png]

On Thursday, May 9, 2019 at 11:46:46 PM UTC-5, Krystian wrote:
>
> Hey Joe,
>
> There was a spelling mistake :D i've been sitting so long on this and 
> didn't saw it 
>
> W dniu czwartek, 9 maja 2019 22:35:12 UTC+2 użytkownik Krystian napisał:
>>
>> Hi there,
>>
>> I was trying today just for myself learning to get data from google books 
>> api https://www.googleapis.com/books/v1/volumes/ without needed auth key 
>> but the point is that I'm getting no results. I've tried with single book 
>> (like below), tried to get books that title contains "something" but django 
>> is giving me key errors when I'm trying to display it on view. Could you 
>> please tell me how to make this work with Django? I know it should be 
>> simple but still gettings those errors
>>
>> Exception Type: KeyError
>> Exception Value: 
>>
>> 'title'
>>
>>
>> import requests
>>
>> def api(request):
>> response = requests.get('
>> https://www.googleapis.com/books/v1/volumes/YyXoCAAJ')
>> book = response.json()
>> return render(request, 'books/api.html', {
>> 'title': book['title'],
>> 'authors': book['authors']
>> })
>>
>> and here is html
>>
>> {% block content %}
>>   Google books API
>>   
>> 
>> search on google books api
>>   
>>   {% if book %}
>>   
>> {{ book.title }} {{ book.authors }}
>>   
>>   {% endif %}
>> {% endblock %}
>>
>>

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


Re: How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Joe Reitman
Krystian,

To extract the Title and Author from your API call you need:

return render(request, 'books/api.html', {
'title': book['volumeInfo']['title'],
'authors': book['volumeInfo']['authors'][0]
}) 


'authors' is stored in an array(list) so if you want to pass all the 
authors as text you'll have to do some sort of list comprehension or just 
get one with an index.

Regards,
Joe




On Thursday, May 9, 2019 at 3:35:12 PM UTC-5, Krystian wrote:
>
> Hi there,
>
> I was trying today just for myself learning to get data from google books 
> api https://www.googleapis.com/books/v1/volumes/ without needed auth key 
> but the point is that I'm getting no results. I've tried with single book 
> (like below), tried to get books that title contains "something" but django 
> is giving me key errors when I'm trying to display it on view. Could you 
> please tell me how to make this work with Django? I know it should be 
> simple but still gettings those errors
>
> Exception Type: KeyError
> Exception Value: 
>
> 'title'
>
>
> import requests
>
> def api(request):
> response = requests.get('
> https://www.googleapis.com/books/v1/volumes/YyXoCAAJ')
> book = response.json()
> return render(request, 'books/api.html', {
> 'title': book['title'],
> 'authors': book['authors']
> })
>
> and here is html
>
> {% block content %}
>   Google books API
>   
> 
> search on google books api
>   
>   {% if book %}
>   
> {{ book.title }} {{ book.authors }}
>   
>   {% endif %}
> {% endblock %}
>
>

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


Re: Unit conversions between model field value and form field value

2019-05-07 Thread Joe Reitman
Hi Tim,

There is a 'Best Practices' guide for Django that recommends making models 
fat, 
https://django-best-practices.readthedocs.io/en/latest/applications.html#models.
 
With that it would be logical to do both conversions in the model.

Regards,
Joe

On Tuesday, May 7, 2019 at 5:24:09 PM UTC-5, Tim Bell wrote:
>
> Hi,
>
> I have a model with an integer field storing a duration in hours, while I 
> want to present that to users in a form in days. (The choice of these 
> different units is imposed by other factors not under my control.)
>
> So, when saving a form, I need to convert a value in days to hours by 
> multiplying by 24. I've done that with a clean_() method on 
> the form, as described at 
> https://docs.djangoproject.com/en/2.2/ref/forms/validation/. That works 
> fine for when saving a new model.
>
> When editing an existing model however, I need to take the value from the 
> model stored in hours, and convert that to days for display in the edit 
> form. I've considered various places where I could do that conversion, for 
> instance in the edit view, or the form __init__() method, or the model 
> field's value_from_object() method, but none of those choices seem like 
> the obvious choice, and I can't find a recommendation for how to do this 
> either.
>
> What would you suggest? And is the recommended approach actually 
> documented somewhere that I've missed?
>
> Thanks,
>
> Tim
>

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


Re: Serving Files with Django

2019-05-05 Thread Joe Reitman
Greetings,

Django can do all the file handling internally. You can create a model 
(database) with a FileField() as Kayode suggested. Using a CreateView class 
you can allow users to upload files from an input form. The model does not 
store the actual files. It stores a file path to where the file is located. 
You control where the file is stored in settings.py. Here is a link to a 
blog post that gives a high level overview of file handling - 
https://www.caktusgroup.com/blog/2017/08/28/advanced-django-file-handling/. 

I recently created an app that allows users to upload images along with geo 
coordinates. The app then displays the images on a map. Django handles all 
the upload/download. I did need the Dropbox app because I'm storing the 
images on Dropbox.

Hope this helps! 

On Wednesday, May 1, 2019 at 6:20:40 AM UTC-5, simon...@gmail.com wrote:
>
> Hello! Am currently working on a web app which allows user to upload files 
> of less that 1 gb size in any office formates like pdf, docx and some other 
> extentions for programs like .h, .py, .kt, .java. Is there any framework or 
> app that i can extend and make the file handling work? These files are to 
> be uploaded by users and download by other users
>

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