Re: Database migration issue

2020-04-12 Thread wanbao jin
Ok, I figure it out, When application configuration class is used in
INSTALLED_APPS, the name field of AppConfig subclass should be the path of
that application.

AppConfig.name¶
>
> Full
> Python path to the application, e.g. 'django.contrib.admin'.
> This attribute defines which application the configuration applies to. It
> must be set in all AppConfig
> 
>  subclasses.
> It must be unique across a Django project.


 

On Mon, Apr 13, 2020 at 10:52 AM wanbao jin  wrote:

> When I just change the api.blogs.apps.BlogsConfig to api.blogs , it
>> worked fine. I am curious why api.blogs.apps.BlogsConfig doesn't work
>>  
>>
>

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


Re: Database migration issue

2020-04-12 Thread wanbao jin
>
> When I just change the api.blogs.apps.BlogsConfig to api.blogs , it
> worked fine. I am curious why api.blogs.apps.BlogsConfig doesn't work
>  
>

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


Re: i want to change database sqllite to mysql but show error

2020-04-12 Thread Ernest Thuku
May we see some of your files..precisely settings.py...and have you
properly configured your MySQL app...either workbench or xampp?
On Apr 12, 2020 20:53, "Andrew Fetting"  wrote:

> Have you tried
> pip3 install mysqlclient
>
> On Sun, Apr 12, 2020, 7:36 AM Arun Sharma 
> wrote:
>
>> python manage.py runserver
>>
>>
>>
>> Watching for file changes with StatReloader
>> Exception in thread django-main-thread:
>> Traceback (most recent call last):
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\backends\mysql\base.py", line 16, in
>> 
>> import MySQLdb as Database
>> ModuleNotFoundError: No module named 'MySQLdb'
>>
>> The above exception was the direct cause of the following exception:
>>
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
>> line 926, in _bootstrap_inner
>> self.run()
>>   File 
>> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
>> line 870, in run
>> self._target(*self._args, **self._kwargs)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\utils\autoreload.py", line 53, in wrappe
>> r
>> fn(*args, **kwargs)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\core\management\commands\runserver.py",
>> line 109, in inner_run
>> autoreload.raise_last_exception()
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\utils\autoreload.py", line 76, in raise_
>> last_exception
>> raise _exception[1]
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\core\management\__init__.py", line 357,
>> in execute
>> autoreload.check_errors(django.setup)()
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\utils\autoreload.py", line 53, in wrappe
>> r
>> fn(*args, **kwargs)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\__init__.py", line 24, in setup
>> apps.populate(settings.INSTALLED_APPS)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\apps\registry.py", line 114, in populate
>>
>> app_config.import_models()
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\apps\config.py", line 211, in import_mod
>> els
>> self.models_module = import_module(models_module_name)
>>   File "C:\Users\Arunkumar\AppData\Local\Programs\Python\
>> Python37-32\lib\importlib\__init__.py", line 127, in import_m
>> odule
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 1006, in _gcd_import
>>   File "", line 983, in _find_and_load
>>   File "", line 967, in
>> _find_and_load_unlocked
>>   File "", line 677, in _load_unlocked
>>   File "", line 728, in exec_module
>>   File "", line 219, in
>> _call_with_frames_removed
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\project\models.py", line
>> 4, in 
>> class Project(models.Model):
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\models\base.py", line 121, in __new__
>>
>> new_class.add_to_class('_meta', Options(meta, app_label))
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\models\base.py", line 325, in add_to_
>> class
>> value.contribute_to_class(cls, name)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\models\options.py", line 208, in cont
>> ribute_to_class
>> self.db_table = truncate_name(self.db_table, connection.ops.max_name_
>> length())
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\__init__.py", line 28, in __getattr__
>>
>> return getattr(connections[DEFAULT_DB_ALIAS], item)
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\utils.py", line 207, in __getitem__
>> backend = load_backend(db['ENGINE'])
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\utils.py", line 111, in load_backend
>> return import_module('%s.base' % backend_name)
>>   File "C:\Users\Arunkumar\AppData\Local\Programs\Python\
>> Python37-32\lib\importlib\__init__.py", line 127, in import_m
>> odule
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 1006, in _gcd_import
>>   File "", line 983, in _find_and_load
>>   File "", line 967, in
>> _find_and_load_unlocked
>>   File "", line 677, in _load_unlocked
>>   File "", line 728, in exec_module
>>   File "", line 219, in
>> _call_with_frames_removed
>>   File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\
>> site-packages\django\db\backends\mysql\base.py", line 21, in
>> 
>> ) from err
>> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
>> module.
>> Did you install mysqlclient?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> pip install 

Re: Django user model. 1 admin account, 1 customer account with the same email and different password

2020-04-12 Thread Ernest Thuku
Option 2 seems good...I could think of it before proceeding to any other
option
On Apr 13, 2020 04:02, "Kenny Soh"  wrote:

> Im trying to handle a use case where i have 2 roles. (admin , customer)
>
> There will be an admin portal and a customer portal (2 different login
> pages ).
>
>- An admin can invite a customer
>- An admin can be a customer as well , can invite himself into the
>customer portal
>- An admin account must not share the same password as the customer
>account.
>- Email is used as the unique field for both admin and customer
>account.
>
> For example :
>
> Admin account - custo...@email.com /password1
> Customer account - custo...@email.com /password2
>
> Solution 1: - Permission. Having 1 account with admin permission and
> customer permission. (This cant work to fit the business use case)
>
> Based on this article: https://simpleisbetterthancomplex.com/
> tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html
>
> Solution 2: - Creating 2 django projects. One for each user model since
> both accounts cant share password. The reason for separating into 2
> projects is because resources such as session,login, logout will not be
> shared. So each portal(admin,customer) has their own resource.
>
>-
>
>A create Customer API to allow admin to create a customer account in
>customer django project.
>-
>
>A shared db to share related data
>
> This is the only way i can think of to handle the use case. Please let me
> know if anyone has a better idea to handle 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/181ec499-e36c-4009-9587-06386219ab8d%40googlegroups.com
> 
> .
>

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


Re: TypeError: resolve() got an unexpected keyword argument 'strict' in Django

2020-04-12 Thread Ernest Thuku
Can you please provide more details...your views.. models etc
On Apr 13, 2020 01:58, "Abhishek Pandey"  wrote:

> Hello Everyone!
>
> I am a new Django learner. I followed some tutorials to install django but
> when i try to runserver an error message comes up. Whenever I hit this
> command: python manage.py runserver
> the following error comes up.
>
> Watching for file changes with StatReloader
> Performing system checks...
>
> 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 "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/__init__.py", line 401, in
> execute_from_command_line
> utility.execute()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/__init__.py", line 395, in
> execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/base.py", line 328, in
> run_from_argv
> self.execute(*args, **cmd_options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 60, in execute
> super().execute(*args, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/base.py", line 369, in
> execute
> output = self.handle(*args, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 95, in handle
> self.run(**options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/core/management/commands/runserver.py",
> line 102, in run
> autoreload.run_with_reloader(self.inner_run, **options)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 599, in
> run_with_reloader
> start_django(reloader, main_func, *args, **kwargs)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 584, in
> start_django
> reloader.run(django_main_thread)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 299, in run
> self.run_loop()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 305, in run_loop
> next(ticker)
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 345, in tick
> for filepath, mtime in self.snapshot_files():
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 361, in
> snapshot_files
> for file in self.watched_files():
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 260, in
> watched_files
> yield from iter_all_python_module_files()
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 105, in
> iter_all_python_module_files
> return iter_modules_and_files(modules, frozenset(_error_files))
>   File "/Users/Abhi/PycharmProjects/SearchProject/venv/lib/
> python3.6/site-packages/django/utils/autoreload.py", line 141, in
> iter_modules_and_files
> resolved_path = path.resolve(strict=True).absolute()
> TypeError: resolve() got an unexpected keyword argument 'strict'
>
>
>
> Can anyone help me out with this, please?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/df96311a-d9ef-4dec-aca3-1b003f279c76%40googlegroups.com
> 
> .
>

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


Database migration issue

2020-04-12 Thread Jin
Hi, everyone. 

I'm completely new to DRF and I structured my first project as the 
following.  When I run *python manage.py makemigrations * script, it gives 
errors. I guess it's related to my folder structure but don't know exactly 
what's wrong with it.

[image: Capture.PNG]


Any help would be appreciated.

Thanks
  

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


Django user model. 1 admin account, 1 customer account with the same email and different password

2020-04-12 Thread Kenny Soh


Im trying to handle a use case where i have 2 roles. (admin , customer)

There will be an admin portal and a customer portal (2 different login 
pages ).

   - An admin can invite a customer
   - An admin can be a customer as well , can invite himself into the 
   customer portal
   - An admin account must not share the same password as the customer 
   account.
   - Email is used as the unique field for both admin and customer account.

For example :

Admin account - custo...@email.com /password1 
Customer account - custo...@email.com /password2

Solution 1: - Permission. Having 1 account with admin permission and 
customer permission. (This cant work to fit the business use case)

Based on this article: 
https://simpleisbetterthancomplex.com/tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html

Solution 2: - Creating 2 django projects. One for each user model since 
both accounts cant share password. The reason for separating into 2 
projects is because resources such as session,login, logout will not be 
shared. So each portal(admin,customer) has their own resource.

   - 
   
   A create Customer API to allow admin to create a customer account in 
   customer django project.
   - 
   
   A shared db to share related data
   
This is the only way i can think of to handle the use case. Please let me 
know if anyone has a better idea to handle 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/181ec499-e36c-4009-9587-06386219ab8d%40googlegroups.com.


TypeError: resolve() got an unexpected keyword argument 'strict' in Django

2020-04-12 Thread Abhishek Pandey
Hello Everyone!

I am a new Django learner. I followed some tutorials to install django but 
when i try to runserver an error message comes up. Whenever I hit this 
command: python manage.py runserver
the following error comes up.

Watching for file changes with StatReloader
Performing system checks...

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 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 401, in execute_from_command_line
utility.execute()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 328, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 60, in execute
super().execute(*args, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 369, in execute
output = self.handle(*args, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 95, in handle
self.run(**options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
 
line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 584, in start_django
reloader.run(django_main_thread)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 299, in run
self.run_loop()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 305, in run_loop
next(ticker)
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 345, in tick
for filepath, mtime in self.snapshot_files():
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 361, in snapshot_files
for file in self.watched_files():
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 260, in watched_files
yield from iter_all_python_module_files()
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
  File 
"/Users/Abhi/PycharmProjects/SearchProject/venv/lib/python3.6/site-packages/django/utils/autoreload.py",
 
line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
TypeError: resolve() got an unexpected keyword argument 'strict'



Can anyone help me out with this, please?

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


Re: Django - PrePopulate the Foreign Key on the web page, and use that id to save the model.

2020-04-12 Thread _M_A_Y_A_N_K_
Cool, thanks Antje.

Seems it is working now, the only thing is in Drop-down i will have the
Project Name for which the URL is rest of the PRojects are removed from
drop down.
Now will work to have pre-selected. As of now it will default display as
-- with only one required project name.

Thanks & Regards,
-
Mayank Tripathi
Mo. +1 615 962 2128
"Do what you can, with what you have, where you are -by Theodore Roosevelt"
https://datascience.foundation/datascienceawards



On Sun, Apr 12, 2020 at 3:07 AM Antje Kazimiers  wrote:

> Hi, I think in your view modulesView() you need to pass the project id to
> ModuleForm:
>
> ..
> else :
> form = ModuleForm(projectid)
> ..
>
> and then you need to overwrite the constructor of ModuleForm by adding an
> __init__ function:
>
>   def __init__(self, projectid=None, *args, **kwargs):
> super(ModuleForm, self).__init__(*args, **kwargs)
> if projectid is not None:
> self.fields['project'] = forms.ModelChoiceField(
> ...
> queryset=Project.objects.filter(id=projectid)
> )
>
> something like that. --Antje
>
> On Sunday, April 12, 2020 at 8:14:51 AM UTC+2, Mayank Tripathi wrote:
>>
>> Hi All,
>>
>> I am facing an issue, to pre-populate the Foreign Key on the web page.
>> Actually i have two models Projects and Modules.
>> To create a Module, one has to select the Project and go to Module page
>> for create it, but there the Project is not populated.
>>
>> Below are the details... Please guide me.
>>
>> *models.py*
>> class Project(models.Model):
>> name = models.CharField(max_length = 200, null = True)
>> startdate = models.DateTimeField()
>>
>> def __str__(self):
>> return self.name
>>
>> class Modules(models.Model):
>> project = models.ForeignKey(Project, null = True, on_delete =
>> models.SET_NULL)
>> modulename = models.CharField(max_length = 200, null = True)
>> modulestartdate = models.DateTimeField()
>>
>> def __str__(self):
>> return self.modulename
>>
>> *forms.py*
>> class ProjectForm(forms.ModelForm):
>> class Meta:
>> model = Project
>> fields = '__all__'
>>
>>
>> class ModuleForm(forms.ModelForm):
>> class Meta:
>> model = Modules
>> fields = '__all__'
>>
>> *views.py*
>> def projectView (request):
>> if request.method == 'POST':
>> form = ProjectForm(request.POST)
>> if form.is_valid():
>> form.save(commit=True)
>>
>> return render(request, 'budget/projectForm.html', {'form': form})
>>
>> else :
>> form = ProjectForm()
>> return render(request, 'budget/projectForm.html', {'form': form})
>>
>>
>> def modulesView (request, projectid):
>> project = Project.objects.get(pk=projectid)
>>
>> if request.method == 'POST':
>> form = ModuleForm(request.POST)
>> if form.is_valid():
>> form.save(commit=True)
>>
>> return render(request, 'example/modulesForm.html', {'form': form})
>>
>> else :
>> form = ModuleForm(instance=project)
>> return render(request, 'example/modulesForm.html', {'form': form})
>>
>> *urls.py*
>> path('testproject/', views.projectView, name='projectView'),
>> path('testprojectmodule//', views.modulesView,
>> name='modulesView'),
>>
>> in html forms for both Project and Modules... just using {{ form.as_table
>> }}.
>>
>> Now after createing the Project, i used the url as
>> http://127.0.0.1:8000/testprojectmodule/1/
>> then my Project should get pre-populated... as reached using the project
>> id which is 1 in this case, but i am getting full drop-down. Refer attached
>> image.
>> Either the Project should be pre-selected.. or can make it non-editable
>> either will work for me.
>>
>> 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/26744cb1-03e3-4189-a438-0b462013bb66%40googlegroups.com
> 
> .
>

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


Re: i want to change database sqllite to mysql but show error

2020-04-12 Thread Andrew Fetting
Have you tried
pip3 install mysqlclient

On Sun, Apr 12, 2020, 7:36 AM Arun Sharma  wrote:

> python manage.py runserver
>
>
>
> Watching for file changes with StatReloader
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py",
> line 16, in
> 
> import MySQLdb as Database
> ModuleNotFoundError: No module named 'MySQLdb'
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File
> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 926, in _bootstrap_inner
> self.run()
>   File
> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 870, in run
> self._target(*self._args, **self._kwargs)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
> line 53, in wrappe
> r
> fn(*args, **kwargs)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\commands\runserver.py",
> line 109, in inner_run
> autoreload.raise_last_exception()
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
> line 76, in raise_
> last_exception
> raise _exception[1]
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\__init__.py",
> line 357,
> in execute
> autoreload.check_errors(django.setup)()
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
> line 53, in wrappe
> r
> fn(*args, **kwargs)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\__init__.py",
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\registry.py",
> line 114, in populate
>
> app_config.import_models()
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\config.py",
> line 211, in import_mod
> els
> self.models_module = import_module(models_module_name)
>   File
> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py",
> line 127, in import_m
> odule
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "C:\Users\Arunkumar\PycharmProjects\app2\project\models.py", line
> 4, in 
> class Project(models.Model):
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py",
> line 121, in __new__
>
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py",
> line 325, in add_to_
> class
> value.contribute_to_class(cls, name)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\options.py",
> line 208, in cont
> ribute_to_class
> self.db_table = truncate_name(self.db_table,
> connection.ops.max_name_length())
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\__init__.py",
> line 28, in __getattr__
>
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py",
> line 207, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py",
> line 111, in load_backend
> return import_module('%s.base' % backend_name)
>   File
> "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py",
> line 127, in import_m
> odule
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py",
> line 21, in
> 
> ) from err
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
> Did you install mysqlclient?
>
>
>
>
>
>
>
>
>
>
> pip install mysqlclient
> Collecting mysqlclient
>   Using cached
> https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e
> 03a/mysqlclient-1.4.6.tar.gz
> Installing collected packages: mysqlclient
>   Running setup.py install for mysqlclient ... error
> Complete 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
And If this doesn't work, I think it is the best course of action to go to
settings.py,
and set the DEBUG=True.
Then the 502 error may disappear and you'll see the Django error log

V V ned., 12. apr. 2020 ob 18:06 je oseba Rok Klancar 
napisala:

> Do it;
> It can't hurt
>
> V V ned., 12. apr. 2020 ob 18:04 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> Nope
>>
>> sudo ufw allow 'Nginx Full'
>>
>> [sudo] password for wms:
>>
>> Skipping adding existing rule
>>
>> Skipping adding existing rule (v6)
>>
>> sudo ufw enable
>>
>> Command may disrupt existing ssh connections. Proceed with operation
>> (y|n)? y
>>
>> Firewall is active and enabled on system startup
>>
>>
>> Do i need to sudo reboot also.
>>
>> On Sun, Apr 12, 2020 at 9:25 PM Rok Klancar  wrote:
>>
>>> Allright, It seems that the problem lies in the firewall (ufw stands for
>>> Uncomplicated FireWall)
>>>
>>> Try this:
>>> sudo ufw allow 'Nginx Full'
>>> and don't forget to do this after:
>>> sudo ufw enable
>>>
>>> Tell me how that worked out
>>>
>>> V V ned., 12. apr. 2020 ob 17:47 je oseba Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> napisala:
>>>
 sudo ufw status

 [sudo] password for wms:

 Status: inactive


 No funky settings as currently i want only to run the app on web, Not
 even installed ssl.

 On Sun, Apr 12, 2020 at 9:13 PM Rok Klancar  wrote:

> And did you set up any funky settings in settings.py, like for example
> some of these:
> [image: image.png]
> Cuz I once tried to make a "very secure" application, and I set all of
> those settings,
> but when I moved them into production, none of them worked, because I
> didn't really
> understand them.
>
> V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar <
> rklan...@gmail.com> napisala:
>
>> Everything seems to be in order
>>
>> Maybe it's the firewall's fault.
>> What do you get when you type
>> 'sudo ufw status' ?
>>
>> V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> napisala:
>>
>>> /etc/nginx/sites-available/iitians
>>>
>>> server {
>>>listen 80;
>>>server_name 192.95.37.123;
>>>location = /images/favicon.ico {access_log off;log_not_found 
>>> off;}
>>>
>>>location /static/ {
>>>  root /home/wms/iitians;
>>>}
>>>location /media/ {
>>>  root /home/wms/iitians;
>>>}
>>>
>>>location / {
>>>  include proxy_params;
>>>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>>>}
>>>  }
>>>
>>> /etc/systemd/system/gunicorn.service
>>>
>>> [Unit]
>>> Description=gunicorn service
>>> After=network.target
>>>
>>> [Service]
>>> User=wms
>>> Group=www-data
>>> WorkingDirectory=/home/wms/iitians/
>>> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - 
>>> --workers 3 --bind unix:/home/wms/iitians/iitans.sock 
>>> iitians.wsgi:application
>>>
>>> [Install]
>>> WantedBy=multi-user.target
>>>
>>>
>>> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar 
>>> wrote:
>>>
 Provide the contents of your file in nginx/sites-available and your
 gunicorn.service file

 V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
 jagtar.lakhe...@gmail.com> napisala:

> Hi Ajayi,
>
> sudo systemctl reload daemon-reload
>
> Failed to reload daemon-reload.service: Unit daemon-reload.service
> not found.
>
>
> perhaps u mean to say: sudo systemctl daemon-reload
>
>
> Ran these
> sudo systemctl daemon-reload
> sudo systemctl enable gunicorn
> sudo systemctl restart gunicorn
> sudo systemctl restart nginx
>
> wait for about 2-5minutes then run
> sudo systemctl status gunicorn
>
>
> Result:
>
>
> sudo systemctl status gunicorn
>
> [sudo] password for wms:
>
> *●* gunicorn.service - gunicorn service
>
>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
> vendor preset
>
>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST;
> 6min ago
>
>  Main PID: 8587 (gunicorn)
>
> Tasks: 4 (limit: 1689)
>
>CGroup: /system.slice/gunicorn.service
>
>├─8587 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8590 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8592 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
Do it;
It can't hurt

V V ned., 12. apr. 2020 ob 18:04 je oseba Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> napisala:

> Nope
>
> sudo ufw allow 'Nginx Full'
>
> [sudo] password for wms:
>
> Skipping adding existing rule
>
> Skipping adding existing rule (v6)
>
> sudo ufw enable
>
> Command may disrupt existing ssh connections. Proceed with operation
> (y|n)? y
>
> Firewall is active and enabled on system startup
>
>
> Do i need to sudo reboot also.
>
> On Sun, Apr 12, 2020 at 9:25 PM Rok Klancar  wrote:
>
>> Allright, It seems that the problem lies in the firewall (ufw stands for
>> Uncomplicated FireWall)
>>
>> Try this:
>> sudo ufw allow 'Nginx Full'
>> and don't forget to do this after:
>> sudo ufw enable
>>
>> Tell me how that worked out
>>
>> V V ned., 12. apr. 2020 ob 17:47 je oseba Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> napisala:
>>
>>> sudo ufw status
>>>
>>> [sudo] password for wms:
>>>
>>> Status: inactive
>>>
>>>
>>> No funky settings as currently i want only to run the app on web, Not
>>> even installed ssl.
>>>
>>> On Sun, Apr 12, 2020 at 9:13 PM Rok Klancar  wrote:
>>>
 And did you set up any funky settings in settings.py, like for example
 some of these:
 [image: image.png]
 Cuz I once tried to make a "very secure" application, and I set all of
 those settings,
 but when I moved them into production, none of them worked, because I
 didn't really
 understand them.

 V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar <
 rklan...@gmail.com> napisala:

> Everything seems to be in order
>
> Maybe it's the firewall's fault.
> What do you get when you type
> 'sudo ufw status' ?
>
> V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> /etc/nginx/sites-available/iitians
>>
>> server {
>>listen 80;
>>server_name 192.95.37.123;
>>location = /images/favicon.ico {access_log off;log_not_found off;}
>>
>>location /static/ {
>>  root /home/wms/iitians;
>>}
>>location /media/ {
>>  root /home/wms/iitians;
>>}
>>
>>location / {
>>  include proxy_params;
>>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>>}
>>  }
>>
>> /etc/systemd/system/gunicorn.service
>>
>> [Unit]
>> Description=gunicorn service
>> After=network.target
>>
>> [Service]
>> User=wms
>> Group=www-data
>> WorkingDirectory=/home/wms/iitians/
>> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 
>> 3 --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application
>>
>> [Install]
>> WantedBy=multi-user.target
>>
>>
>> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar 
>> wrote:
>>
>>> Provide the contents of your file in nginx/sites-available and your
>>> gunicorn.service file
>>>
>>> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> napisala:
>>>
 Hi Ajayi,

 sudo systemctl reload daemon-reload

 Failed to reload daemon-reload.service: Unit daemon-reload.service
 not found.


 perhaps u mean to say: sudo systemctl daemon-reload


 Ran these
 sudo systemctl daemon-reload
 sudo systemctl enable gunicorn
 sudo systemctl restart gunicorn
 sudo systemctl restart nginx

 wait for about 2-5minutes then run
 sudo systemctl status gunicorn


 Result:


 sudo systemctl status gunicorn

 [sudo] password for wms:

 *●* gunicorn.service - gunicorn service

Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
 vendor preset

Active: *active (running)* since Sun 2020-04-12 19:17:35 IST;
 6min ago

  Main PID: 8587 (gunicorn)

 Tasks: 4 (limit: 1689)

CGroup: /system.slice/gunicorn.service

├─8587 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

├─8590 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

├─8592 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

└─8594 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun


 Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
 [8587] [INFO] S

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Jagtar Singh Lakhyan
Nope

sudo ufw allow 'Nginx Full'

[sudo] password for wms:

Skipping adding existing rule

Skipping adding existing rule (v6)

sudo ufw enable

Command may disrupt existing ssh connections. Proceed with operation (y|n)?
y

Firewall is active and enabled on system startup


Do i need to sudo reboot also.

On Sun, Apr 12, 2020 at 9:25 PM Rok Klancar  wrote:

> Allright, It seems that the problem lies in the firewall (ufw stands for
> Uncomplicated FireWall)
>
> Try this:
> sudo ufw allow 'Nginx Full'
> and don't forget to do this after:
> sudo ufw enable
>
> Tell me how that worked out
>
> V V ned., 12. apr. 2020 ob 17:47 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> sudo ufw status
>>
>> [sudo] password for wms:
>>
>> Status: inactive
>>
>>
>> No funky settings as currently i want only to run the app on web, Not
>> even installed ssl.
>>
>> On Sun, Apr 12, 2020 at 9:13 PM Rok Klancar  wrote:
>>
>>> And did you set up any funky settings in settings.py, like for example
>>> some of these:
>>> [image: image.png]
>>> Cuz I once tried to make a "very secure" application, and I set all of
>>> those settings,
>>> but when I moved them into production, none of them worked, because I
>>> didn't really
>>> understand them.
>>>
>>> V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar <
>>> rklan...@gmail.com> napisala:
>>>
 Everything seems to be in order

 Maybe it's the firewall's fault.
 What do you get when you type
 'sudo ufw status' ?

 V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
 jagtar.lakhe...@gmail.com> napisala:

> /etc/nginx/sites-available/iitians
>
> server {
>listen 80;
>server_name 192.95.37.123;
>location = /images/favicon.ico {access_log off;log_not_found off;}
>
>location /static/ {
>  root /home/wms/iitians;
>}
>location /media/ {
>  root /home/wms/iitians;
>}
>
>location / {
>  include proxy_params;
>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>}
>  }
>
> /etc/systemd/system/gunicorn.service
>
> [Unit]
> Description=gunicorn service
> After=network.target
>
> [Service]
> User=wms
> Group=www-data
> WorkingDirectory=/home/wms/iitians/
> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 
> 3 --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application
>
> [Install]
> WantedBy=multi-user.target
>
>
> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar 
> wrote:
>
>> Provide the contents of your file in nginx/sites-available and your
>> gunicorn.service file
>>
>> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> napisala:
>>
>>> Hi Ajayi,
>>>
>>> sudo systemctl reload daemon-reload
>>>
>>> Failed to reload daemon-reload.service: Unit daemon-reload.service
>>> not found.
>>>
>>>
>>> perhaps u mean to say: sudo systemctl daemon-reload
>>>
>>>
>>> Ran these
>>> sudo systemctl daemon-reload
>>> sudo systemctl enable gunicorn
>>> sudo systemctl restart gunicorn
>>> sudo systemctl restart nginx
>>>
>>> wait for about 2-5minutes then run
>>> sudo systemctl status gunicorn
>>>
>>>
>>> Result:
>>>
>>>
>>> sudo systemctl status gunicorn
>>>
>>> [sudo] password for wms:
>>>
>>> *●* gunicorn.service - gunicorn service
>>>
>>>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
>>> vendor preset
>>>
>>>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST;
>>> 6min ago
>>>
>>>  Main PID: 8587 (gunicorn)
>>>
>>> Tasks: 4 (limit: 1689)
>>>
>>>CGroup: /system.slice/gunicorn.service
>>>
>>>├─8587 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>├─8590 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>├─8592 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>└─8594 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>
>>> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>>> [8587] [INFO] S
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>>> [8587] [INFO] L
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>>> [8587] [INFO] U
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>>> [8590] [INFO] B
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>>> 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
Allright, It seems that the problem lies in the firewall (ufw stands for
Uncomplicated FireWall)

Try this:
sudo ufw allow 'Nginx Full'
and don't forget to do this after:
sudo ufw enable

Tell me how that worked out

V V ned., 12. apr. 2020 ob 17:47 je oseba Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> napisala:

> sudo ufw status
>
> [sudo] password for wms:
>
> Status: inactive
>
>
> No funky settings as currently i want only to run the app on web, Not even
> installed ssl.
>
> On Sun, Apr 12, 2020 at 9:13 PM Rok Klancar  wrote:
>
>> And did you set up any funky settings in settings.py, like for example
>> some of these:
>> [image: image.png]
>> Cuz I once tried to make a "very secure" application, and I set all of
>> those settings,
>> but when I moved them into production, none of them worked, because I
>> didn't really
>> understand them.
>>
>> V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar 
>> napisala:
>>
>>> Everything seems to be in order
>>>
>>> Maybe it's the firewall's fault.
>>> What do you get when you type
>>> 'sudo ufw status' ?
>>>
>>> V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> napisala:
>>>
 /etc/nginx/sites-available/iitians

 server {
listen 80;
server_name 192.95.37.123;
location = /images/favicon.ico {access_log off;log_not_found off;}

location /static/ {
  root /home/wms/iitians;
}
location /media/ {
  root /home/wms/iitians;
}

location / {
  include proxy_params;
  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
}
  }

 /etc/systemd/system/gunicorn.service

 [Unit]
 Description=gunicorn service
 After=network.target

 [Service]
 User=wms
 Group=www-data
 WorkingDirectory=/home/wms/iitians/
 ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 3 
 --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application

 [Install]
 WantedBy=multi-user.target


 On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar  wrote:

> Provide the contents of your file in nginx/sites-available and your
> gunicorn.service file
>
> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> Hi Ajayi,
>>
>> sudo systemctl reload daemon-reload
>>
>> Failed to reload daemon-reload.service: Unit daemon-reload.service
>> not found.
>>
>>
>> perhaps u mean to say: sudo systemctl daemon-reload
>>
>>
>> Ran these
>> sudo systemctl daemon-reload
>> sudo systemctl enable gunicorn
>> sudo systemctl restart gunicorn
>> sudo systemctl restart nginx
>>
>> wait for about 2-5minutes then run
>> sudo systemctl status gunicorn
>>
>>
>> Result:
>>
>>
>> sudo systemctl status gunicorn
>>
>> [sudo] password for wms:
>>
>> *●* gunicorn.service - gunicorn service
>>
>>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
>> vendor preset
>>
>>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST;
>> 6min ago
>>
>>  Main PID: 8587 (gunicorn)
>>
>> Tasks: 4 (limit: 1689)
>>
>>CGroup: /system.slice/gunicorn.service
>>
>>├─8587 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>├─8590 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>├─8592 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>└─8594 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>
>> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8587] [INFO] S
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8587] [INFO] L
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8587] [INFO] U
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8590] [INFO] B
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8592] [INFO] B
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530]
>> [8594] [INFO] B
>>
>>
>> The app is well tested on my local, even i tried 15 days back the
>> same app to run on nginx, gunicorn and it ran on ip/domain:8000 but Not 
>> it
>> didnt run on ip/domain.
>>
>>
>> Also, i am checking for the app again if it has some issues.
>>
>>
>> I am following this guide:
>> https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Jagtar Singh Lakhyan
sudo ufw status

[sudo] password for wms:

Status: inactive


No funky settings as currently i want only to run the app on web, Not even
installed ssl.

On Sun, Apr 12, 2020 at 9:13 PM Rok Klancar  wrote:

> And did you set up any funky settings in settings.py, like for example
> some of these:
> [image: image.png]
> Cuz I once tried to make a "very secure" application, and I set all of
> those settings,
> but when I moved them into production, none of them worked, because I
> didn't really
> understand them.
>
> V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar 
> napisala:
>
>> Everything seems to be in order
>>
>> Maybe it's the firewall's fault.
>> What do you get when you type
>> 'sudo ufw status' ?
>>
>> V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> napisala:
>>
>>> /etc/nginx/sites-available/iitians
>>>
>>> server {
>>>listen 80;
>>>server_name 192.95.37.123;
>>>location = /images/favicon.ico {access_log off;log_not_found off;}
>>>
>>>location /static/ {
>>>  root /home/wms/iitians;
>>>}
>>>location /media/ {
>>>  root /home/wms/iitians;
>>>}
>>>
>>>location / {
>>>  include proxy_params;
>>>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>>>}
>>>  }
>>>
>>> /etc/systemd/system/gunicorn.service
>>>
>>> [Unit]
>>> Description=gunicorn service
>>> After=network.target
>>>
>>> [Service]
>>> User=wms
>>> Group=www-data
>>> WorkingDirectory=/home/wms/iitians/
>>> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 3 
>>> --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application
>>>
>>> [Install]
>>> WantedBy=multi-user.target
>>>
>>>
>>> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar  wrote:
>>>
 Provide the contents of your file in nginx/sites-available and your
 gunicorn.service file

 V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
 jagtar.lakhe...@gmail.com> napisala:

> Hi Ajayi,
>
> sudo systemctl reload daemon-reload
>
> Failed to reload daemon-reload.service: Unit daemon-reload.service not
> found.
>
>
> perhaps u mean to say: sudo systemctl daemon-reload
>
>
> Ran these
> sudo systemctl daemon-reload
> sudo systemctl enable gunicorn
> sudo systemctl restart gunicorn
> sudo systemctl restart nginx
>
> wait for about 2-5minutes then run
> sudo systemctl status gunicorn
>
>
> Result:
>
>
> sudo systemctl status gunicorn
>
> [sudo] password for wms:
>
> *●* gunicorn.service - gunicorn service
>
>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
> vendor preset
>
>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min
> ago
>
>  Main PID: 8587 (gunicorn)
>
> Tasks: 4 (limit: 1689)
>
>CGroup: /system.slice/gunicorn.service
>
>├─8587 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8590 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8592 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>└─8594 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>
> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] S
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] L
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] U
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
> [INFO] B
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
> [INFO] B
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
> [INFO] B
>
>
> The app is well tested on my local, even i tried 15 days back the same
> app to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it 
> didnt
> run on ip/domain.
>
>
> Also, i am checking for the app again if it has some issues.
>
>
> I am following this guide:
> https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac
>
> On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi <
> sunnexaj...@gmail.com> wrote:
>
>> HI Jagtar,
>>
>> Sometimes when you get 502 nginx server error , it can be due to the
>> fact that your django code has some error. If there is an error in your
>> code, nginx will no serve.
>>
>> Try to run
>> sudo systemctl reload daemon-reload
>> sudo systemctl enable gunicorn
>> sudo systemctl restart gunicorn
>> sudo systemctl restart 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
And did you set up any funky settings in settings.py, like for example some
of these:
[image: image.png]
Cuz I once tried to make a "very secure" application, and I set all of
those settings,
but when I moved them into production, none of them worked, because I
didn't really
understand them.

V V ned., 12. apr. 2020 ob 17:40 je oseba Rok Klancar 
napisala:

> Everything seems to be in order
>
> Maybe it's the firewall's fault.
> What do you get when you type
> 'sudo ufw status' ?
>
> V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> /etc/nginx/sites-available/iitians
>>
>> server {
>>listen 80;
>>server_name 192.95.37.123;
>>location = /images/favicon.ico {access_log off;log_not_found off;}
>>
>>location /static/ {
>>  root /home/wms/iitians;
>>}
>>location /media/ {
>>  root /home/wms/iitians;
>>}
>>
>>location / {
>>  include proxy_params;
>>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>>}
>>  }
>>
>> /etc/systemd/system/gunicorn.service
>>
>> [Unit]
>> Description=gunicorn service
>> After=network.target
>>
>> [Service]
>> User=wms
>> Group=www-data
>> WorkingDirectory=/home/wms/iitians/
>> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 3 
>> --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application
>>
>> [Install]
>> WantedBy=multi-user.target
>>
>>
>> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar  wrote:
>>
>>> Provide the contents of your file in nginx/sites-available and your
>>> gunicorn.service file
>>>
>>> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> napisala:
>>>
 Hi Ajayi,

 sudo systemctl reload daemon-reload

 Failed to reload daemon-reload.service: Unit daemon-reload.service not
 found.


 perhaps u mean to say: sudo systemctl daemon-reload


 Ran these
 sudo systemctl daemon-reload
 sudo systemctl enable gunicorn
 sudo systemctl restart gunicorn
 sudo systemctl restart nginx

 wait for about 2-5minutes then run
 sudo systemctl status gunicorn


 Result:


 sudo systemctl status gunicorn

 [sudo] password for wms:

 *●* gunicorn.service - gunicorn service

Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
 vendor preset

Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min
 ago

  Main PID: 8587 (gunicorn)

 Tasks: 4 (limit: 1689)

CGroup: /system.slice/gunicorn.service

├─8587 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

├─8590 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

├─8592 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun

└─8594 /home/wms/iitiansenv/bin/python3
 /home/wms/iitiansenv/bin/gun


 Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
 [INFO] S

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
 [INFO] L

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
 [INFO] U

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
 [INFO] B

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
 [INFO] B

 Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
 [INFO] B


 The app is well tested on my local, even i tried 15 days back the same
 app to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it didnt
 run on ip/domain.


 Also, i am checking for the app again if it has some issues.


 I am following this guide:
 https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac

 On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi <
 sunnexaj...@gmail.com> wrote:

> HI Jagtar,
>
> Sometimes when you get 502 nginx server error , it can be due to the
> fact that your django code has some error. If there is an error in your
> code, nginx will no serve.
>
> Try to run
> sudo systemctl reload daemon-reload
> sudo systemctl enable gunicorn
> sudo systemctl restart gunicorn
> sudo systemctl restart nginx
>
> wait for about 2-5minutes then run
> sudo systemctl status gunicorn
>
> IT shoud display error in your code
>
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@gmail.com *
>
>
>
> On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> wrote:
>
>> No luck, same 502 error.
>>

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
Everything seems to be in order

Maybe it's the firewall's fault.
What do you get when you type
'sudo ufw status' ?

V V ned., 12. apr. 2020 ob 16:09 je oseba Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> napisala:

> /etc/nginx/sites-available/iitians
>
> server {
>listen 80;
>server_name 192.95.37.123;
>location = /images/favicon.ico {access_log off;log_not_found off;}
>
>location /static/ {
>  root /home/wms/iitians;
>}
>location /media/ {
>  root /home/wms/iitians;
>}
>
>location / {
>  include proxy_params;
>  proxy_pass http://unix:/home/wms/iitians/iitians.sock;
>}
>  }
>
> /etc/systemd/system/gunicorn.service
>
> [Unit]
> Description=gunicorn service
> After=network.target
>
> [Service]
> User=wms
> Group=www-data
> WorkingDirectory=/home/wms/iitians/
> ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile - --workers 3 
> --bind unix:/home/wms/iitians/iitans.sock iitians.wsgi:application
>
> [Install]
> WantedBy=multi-user.target
>
>
> On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar  wrote:
>
>> Provide the contents of your file in nginx/sites-available and your
>> gunicorn.service file
>>
>> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> napisala:
>>
>>> Hi Ajayi,
>>>
>>> sudo systemctl reload daemon-reload
>>>
>>> Failed to reload daemon-reload.service: Unit daemon-reload.service not
>>> found.
>>>
>>>
>>> perhaps u mean to say: sudo systemctl daemon-reload
>>>
>>>
>>> Ran these
>>> sudo systemctl daemon-reload
>>> sudo systemctl enable gunicorn
>>> sudo systemctl restart gunicorn
>>> sudo systemctl restart nginx
>>>
>>> wait for about 2-5minutes then run
>>> sudo systemctl status gunicorn
>>>
>>>
>>> Result:
>>>
>>>
>>> sudo systemctl status gunicorn
>>>
>>> [sudo] password for wms:
>>>
>>> *●* gunicorn.service - gunicorn service
>>>
>>>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
>>> vendor preset
>>>
>>>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min
>>> ago
>>>
>>>  Main PID: 8587 (gunicorn)
>>>
>>> Tasks: 4 (limit: 1689)
>>>
>>>CGroup: /system.slice/gunicorn.service
>>>
>>>├─8587 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>├─8590 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>├─8592 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>└─8594 /home/wms/iitiansenv/bin/python3
>>> /home/wms/iitiansenv/bin/gun
>>>
>>>
>>> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>>> [INFO] S
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>>> [INFO] L
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>>> [INFO] U
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
>>> [INFO] B
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
>>> [INFO] B
>>>
>>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
>>> [INFO] B
>>>
>>>
>>> The app is well tested on my local, even i tried 15 days back the same
>>> app to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it didnt
>>> run on ip/domain.
>>>
>>>
>>> Also, i am checking for the app again if it has some issues.
>>>
>>>
>>> I am following this guide:
>>> https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac
>>>
>>> On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi <
>>> sunnexaj...@gmail.com> wrote:
>>>
 HI Jagtar,

 Sometimes when you get 502 nginx server error , it can be due to the
 fact that your django code has some error. If there is an error in your
 code, nginx will no serve.

 Try to run
 sudo systemctl reload daemon-reload
 sudo systemctl enable gunicorn
 sudo systemctl restart gunicorn
 sudo systemctl restart nginx

 wait for about 2-5minutes then run
 sudo systemctl status gunicorn

 IT shoud display error in your code

 *AJAYI Sunday *
 (+234) 806 771 5394
 *sunnexaj...@gmail.com *



 On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
 jagtar.lakhe...@gmail.com> wrote:

> No luck, same 502 error.
>
> These r settings.py
>
> *# SECURITY WARNING: don't run with debug turned on in production!*
>
> DEBUG = *False*
>
>
> ALLOWED_HOSTS = [*'iitian.xyz '*, *'192.95.37.123'*
> ]
>
> On Sun, Apr 12, 2020 at 6:19 AM Andrew C. 
> wrote:
>
>> What’s the HTTP status code? Does the nginx page even show anything?
>> Try:
>>
>> sudo systemctl stop nginx && sudo systemctl disable nginx && sudo
>> systemctl enable nginx && sudo systemctl start nginx
>>

Re: Setting DEBUG = False causes 500 Error

2020-04-12 Thread Eki
I ran into exatly the same issue just now (10 years after your post). When 
I use compress in production with DEBUG=False, I get a 500 error. I wish I 
had read your post 5 hours ago... Everything works fine now.

-- Eki

On Monday, 25 January 2010 23:05:57 UTC+2, Damon Jablons wrote:
>
> I do have a 400 and 500 error page.
>
> I've been mulling over this issue for a couple days and I just
> discovered what it was. I was using the css/js compression app called
> "compress" which only runs if DEBUG=True. It was throwing some error,
> so I removed it and things work fine now.
>
> In the immortal words of Homer Simpson, "Do'h!"
>
> On Jan 25, 3:40 pm, Ted Nyman  wrote:
> > Have you created a 404.html and 500.html in your template directory?
> >
> > On Mon, Jan 25, 2010 at 12:37 PM, Damon Jablons  >wrote:
> >
> > > I work on my django site locally, and pull from the repository
> > > remotely. On my local machine, I have DEBUG = True, and on my remote
> > > machine I have DEBUG = False. Whenever I set the server's DEBUG to
> > > False, the server presents a 500 error, and there's nothing to be
> > > found in the Apache logs. If I set DEBUG to True, the site runs
> > > perfectly fine.
>
>

-- 
You received this message because you are 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/6daa2f56-7225-44c3-897a-37397695cf0a%40googlegroups.com.


Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Jagtar Singh Lakhyan
/etc/nginx/sites-available/iitians

server {
   listen 80;
   server_name 192.95.37.123;
   location = /images/favicon.ico {access_log off;log_not_found off;}

   location /static/ {
 root /home/wms/iitians;
   }
   location /media/ {
 root /home/wms/iitians;
   }

   location / {
 include proxy_params;
 proxy_pass http://unix:/home/wms/iitians/iitians.sock;
   }
 }

/etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn service
After=network.target

[Service]
User=wms
Group=www-data
WorkingDirectory=/home/wms/iitians/
ExecStart=/home/wms/iitiansenv/bin/gunicorn --access-logfile -
--workers 3 --bind unix:/home/wms/iitians/iitans.sock
iitians.wsgi:application

[Install]
WantedBy=multi-user.target


On Sun, Apr 12, 2020 at 7:33 PM Rok Klancar  wrote:

> Provide the contents of your file in nginx/sites-available and your
> gunicorn.service file
>
> V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> napisala:
>
>> Hi Ajayi,
>>
>> sudo systemctl reload daemon-reload
>>
>> Failed to reload daemon-reload.service: Unit daemon-reload.service not
>> found.
>>
>>
>> perhaps u mean to say: sudo systemctl daemon-reload
>>
>>
>> Ran these
>> sudo systemctl daemon-reload
>> sudo systemctl enable gunicorn
>> sudo systemctl restart gunicorn
>> sudo systemctl restart nginx
>>
>> wait for about 2-5minutes then run
>> sudo systemctl status gunicorn
>>
>>
>> Result:
>>
>>
>> sudo systemctl status gunicorn
>>
>> [sudo] password for wms:
>>
>> *●* gunicorn.service - gunicorn service
>>
>>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor
>> preset
>>
>>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min ago
>>
>>  Main PID: 8587 (gunicorn)
>>
>> Tasks: 4 (limit: 1689)
>>
>>CGroup: /system.slice/gunicorn.service
>>
>>├─8587 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>├─8590 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>├─8592 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>└─8594 /home/wms/iitiansenv/bin/python3
>> /home/wms/iitiansenv/bin/gun
>>
>>
>> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>> [INFO] S
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>> [INFO] L
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
>> [INFO] U
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
>> [INFO] B
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
>> [INFO] B
>>
>> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
>> [INFO] B
>>
>>
>> The app is well tested on my local, even i tried 15 days back the same
>> app to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it didnt
>> run on ip/domain.
>>
>>
>> Also, i am checking for the app again if it has some issues.
>>
>>
>> I am following this guide:
>> https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac
>>
>> On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi 
>> wrote:
>>
>>> HI Jagtar,
>>>
>>> Sometimes when you get 502 nginx server error , it can be due to the
>>> fact that your django code has some error. If there is an error in your
>>> code, nginx will no serve.
>>>
>>> Try to run
>>> sudo systemctl reload daemon-reload
>>> sudo systemctl enable gunicorn
>>> sudo systemctl restart gunicorn
>>> sudo systemctl restart nginx
>>>
>>> wait for about 2-5minutes then run
>>> sudo systemctl status gunicorn
>>>
>>> IT shoud display error in your code
>>>
>>> *AJAYI Sunday *
>>> (+234) 806 771 5394
>>> *sunnexaj...@gmail.com *
>>>
>>>
>>>
>>> On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> wrote:
>>>
 No luck, same 502 error.

 These r settings.py

 *# SECURITY WARNING: don't run with debug turned on in production!*

 DEBUG = *False*


 ALLOWED_HOSTS = [*'iitian.xyz '*, *'192.95.37.123'*]

 On Sun, Apr 12, 2020 at 6:19 AM Andrew C. 
 wrote:

> What’s the HTTP status code? Does the nginx page even show anything?
> Try:
>
> sudo systemctl stop nginx && sudo systemctl disable nginx && sudo
> systemctl enable nginx && sudo systemctl start nginx
>
> This command could also be in the wrong order... it’s been awhile.
>
> It could be a symbolic link error. I don’t know. If you see some web
> page with an error message like Internal Error 500 or the default nginx
> page, let us know.
>
> On Sat, Apr 11, 2020 at 1:39 PM Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> wrote:
>
>> sudo systemctl status nginx
>>
>> *●* nginx.service - A high performance web server 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Rok Klancar
Provide the contents of your file in nginx/sites-available and your
gunicorn.service file

V V ned., 12. apr. 2020 ob 15:57 je oseba Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> napisala:

> Hi Ajayi,
>
> sudo systemctl reload daemon-reload
>
> Failed to reload daemon-reload.service: Unit daemon-reload.service not
> found.
>
>
> perhaps u mean to say: sudo systemctl daemon-reload
>
>
> Ran these
> sudo systemctl daemon-reload
> sudo systemctl enable gunicorn
> sudo systemctl restart gunicorn
> sudo systemctl restart nginx
>
> wait for about 2-5minutes then run
> sudo systemctl status gunicorn
>
>
> Result:
>
>
> sudo systemctl status gunicorn
>
> [sudo] password for wms:
>
> *●* gunicorn.service - gunicorn service
>
>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor
> preset
>
>Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min ago
>
>  Main PID: 8587 (gunicorn)
>
> Tasks: 4 (limit: 1689)
>
>CGroup: /system.slice/gunicorn.service
>
>├─8587 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8590 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>├─8592 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>└─8594 /home/wms/iitiansenv/bin/python3
> /home/wms/iitiansenv/bin/gun
>
>
> Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] S
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] L
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
> [INFO] U
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
> [INFO] B
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
> [INFO] B
>
> Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
> [INFO] B
>
>
> The app is well tested on my local, even i tried 15 days back the same app
> to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it didnt run
> on ip/domain.
>
>
> Also, i am checking for the app again if it has some issues.
>
>
> I am following this guide:
> https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac
>
> On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi 
> wrote:
>
>> HI Jagtar,
>>
>> Sometimes when you get 502 nginx server error , it can be due to the fact
>> that your django code has some error. If there is an error in your code,
>> nginx will no serve.
>>
>> Try to run
>> sudo systemctl reload daemon-reload
>> sudo systemctl enable gunicorn
>> sudo systemctl restart gunicorn
>> sudo systemctl restart nginx
>>
>> wait for about 2-5minutes then run
>> sudo systemctl status gunicorn
>>
>> IT shoud display error in your code
>>
>> *AJAYI Sunday *
>> (+234) 806 771 5394
>> *sunnexaj...@gmail.com *
>>
>>
>>
>> On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> wrote:
>>
>>> No luck, same 502 error.
>>>
>>> These r settings.py
>>>
>>> *# SECURITY WARNING: don't run with debug turned on in production!*
>>>
>>> DEBUG = *False*
>>>
>>>
>>> ALLOWED_HOSTS = [*'iitian.xyz '*, *'192.95.37.123'*]
>>>
>>> On Sun, Apr 12, 2020 at 6:19 AM Andrew C. 
>>> wrote:
>>>
 What’s the HTTP status code? Does the nginx page even show anything?
 Try:

 sudo systemctl stop nginx && sudo systemctl disable nginx && sudo
 systemctl enable nginx && sudo systemctl start nginx

 This command could also be in the wrong order... it’s been awhile.

 It could be a symbolic link error. I don’t know. If you see some web
 page with an error message like Internal Error 500 or the default nginx
 page, let us know.

 On Sat, Apr 11, 2020 at 1:39 PM Jagtar Singh Lakhyan <
 jagtar.lakhe...@gmail.com> wrote:

> sudo systemctl status nginx
>
> *●* nginx.service - A high performance web server and a reverse proxy
> server
>
>Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor
> preset: enabled)
>
>Active: *active (running)* since Sat 2020-04-11 04:54:18 IST; 18h
> ago
>
>  Docs: man:nginx(8)
>
>   Process: 1650 ExecStop=/sbin/start-stop-daemon --quiet --stop
> --retry QUIT/5 --pidfi
>
>   Process: 1652 ExecStart=/usr/sbin/nginx -g daemon on;
> master_process on; (code=exite
>
>   Process: 1651 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
> master_process on; (c
>
>  Main PID: 1653 (nginx)
>
> Tasks: 9 (limit: 1689)
>
>CGroup: /system.slice/nginx.service
>
>├─1653 nginx: master process /usr/sbin/nginx -g daemon on;
> master_process o
>
>├─1654 nginx: worker process
>
>├─1655 nginx: worker process
>
>├─1656 nginx: worker process
>
>├─1657 

Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Jagtar Singh Lakhyan
Hi Ajayi,

sudo systemctl reload daemon-reload

Failed to reload daemon-reload.service: Unit daemon-reload.service not
found.


perhaps u mean to say: sudo systemctl daemon-reload


Ran these
sudo systemctl daemon-reload
sudo systemctl enable gunicorn
sudo systemctl restart gunicorn
sudo systemctl restart nginx

wait for about 2-5minutes then run
sudo systemctl status gunicorn


Result:


sudo systemctl status gunicorn

[sudo] password for wms:

*●* gunicorn.service - gunicorn service

   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor
preset

   Active: *active (running)* since Sun 2020-04-12 19:17:35 IST; 6min ago

 Main PID: 8587 (gunicorn)

Tasks: 4 (limit: 1689)

   CGroup: /system.slice/gunicorn.service

   ├─8587 /home/wms/iitiansenv/bin/python3
/home/wms/iitiansenv/bin/gun

   ├─8590 /home/wms/iitiansenv/bin/python3
/home/wms/iitiansenv/bin/gun

   ├─8592 /home/wms/iitiansenv/bin/python3
/home/wms/iitiansenv/bin/gun

   └─8594 /home/wms/iitiansenv/bin/python3
/home/wms/iitiansenv/bin/gun


Apr 12 19:17:35 wms systemd[1]: Started gunicorn service.

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
[INFO] S

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
[INFO] L

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8587]
[INFO] U

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8590]
[INFO] B

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8592]
[INFO] B

Apr 12 19:17:35 wms gunicorn[8587]: [2020-04-12 19:17:35 +0530] [8594]
[INFO] B


The app is well tested on my local, even i tried 15 days back the same app
to run on nginx, gunicorn and it ran on ip/domain:8000 but Not it didnt run
on ip/domain.


Also, i am checking for the app again if it has some issues.


I am following this guide:
https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac

On Sun, Apr 12, 2020 at 5:14 PM Sunday Iyanu Ajayi 
wrote:

> HI Jagtar,
>
> Sometimes when you get 502 nginx server error , it can be due to the fact
> that your django code has some error. If there is an error in your code,
> nginx will no serve.
>
> Try to run
> sudo systemctl reload daemon-reload
> sudo systemctl enable gunicorn
> sudo systemctl restart gunicorn
> sudo systemctl restart nginx
>
> wait for about 2-5minutes then run
> sudo systemctl status gunicorn
>
> IT shoud display error in your code
>
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@gmail.com *
>
>
>
> On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
> jagtar.lakhe...@gmail.com> wrote:
>
>> No luck, same 502 error.
>>
>> These r settings.py
>>
>> *# SECURITY WARNING: don't run with debug turned on in production!*
>>
>> DEBUG = *False*
>>
>>
>> ALLOWED_HOSTS = [*'iitian.xyz '*, *'192.95.37.123'*]
>>
>> On Sun, Apr 12, 2020 at 6:19 AM Andrew C.  wrote:
>>
>>> What’s the HTTP status code? Does the nginx page even show anything? Try:
>>>
>>> sudo systemctl stop nginx && sudo systemctl disable nginx && sudo
>>> systemctl enable nginx && sudo systemctl start nginx
>>>
>>> This command could also be in the wrong order... it’s been awhile.
>>>
>>> It could be a symbolic link error. I don’t know. If you see some web
>>> page with an error message like Internal Error 500 or the default nginx
>>> page, let us know.
>>>
>>> On Sat, Apr 11, 2020 at 1:39 PM Jagtar Singh Lakhyan <
>>> jagtar.lakhe...@gmail.com> wrote:
>>>
 sudo systemctl status nginx

 *●* nginx.service - A high performance web server and a reverse proxy
 server

Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor
 preset: enabled)

Active: *active (running)* since Sat 2020-04-11 04:54:18 IST; 18h
 ago

  Docs: man:nginx(8)

   Process: 1650 ExecStop=/sbin/start-stop-daemon --quiet --stop
 --retry QUIT/5 --pidfi

   Process: 1652 ExecStart=/usr/sbin/nginx -g daemon on; master_process
 on; (code=exite

   Process: 1651 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
 master_process on; (c

  Main PID: 1653 (nginx)

 Tasks: 9 (limit: 1689)

CGroup: /system.slice/nginx.service

├─1653 nginx: master process /usr/sbin/nginx -g daemon on;
 master_process o

├─1654 nginx: worker process

├─1655 nginx: worker process

├─1656 nginx: worker process

├─1657 nginx: worker process

├─1658 nginx: worker process

├─1659 nginx: worker process

├─1660 nginx: worker process

└─1661 nginx: worker process


 Apr 11 04:54:18 wms systemd[1]: Starting A high performance web server
 and a reverse p

 Apr 11 04:54:18 wms systemd[1]: Started A high performance web server
 and a reverse pr


Re: django doughts

2020-04-12 Thread kakan ghosh
I think you missed to include your polls app urls in your project top urls
file.

On Sun, Apr 12, 2020, 7:05 PM Motaz Hejaze  wrote:

> You need the Url in urls.py
> You missed some parts of the tutorial
> Try to complete the tutorial following every step
>
> On Sun, 12 Apr 2020, 2:39 pm Anonymous Patel, 
> wrote:
>
>> Ask your query in Errormania they helped me they have django Developers
>> they provide within hour solutions to a problem
>> Telegram  name:- Errormania
>>
>> YouTube :- https://youtu.be/_xu1ds3DICA
>> Raj Patel
>>
>> On Sun, 12 Apr, 2020, 6:06 pm rama prakash y, 
>> wrote:
>>
>>> Hi can u plz tell me how can solve the pollsapp development in  django
>>> project. I had complete my pollsapp development project in Django
>>> documentation like that guidance.but i have browser error .
>>>
>>> --
>>> You received this message because you are 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/c09b3231-3700-4157-9c4a-a75bc9a6e69c%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAF_9CitU41d0peeuWj-vuLNpxNavUsJTrL3ZrZPAsAzCN3BFuQ%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHV4E-da8BLGCB4Vzzi92bM2%3Dz%2B%3Da8VW5FUDvDp2yvDa8aSfYg%40mail.gmail.com
> 
> .
>

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


Re: django doughts

2020-04-12 Thread Motaz Hejaze
You need the Url in urls.py
You missed some parts of the tutorial
Try to complete the tutorial following every step

On Sun, 12 Apr 2020, 2:39 pm Anonymous Patel,  wrote:

> Ask your query in Errormania they helped me they have django Developers
> they provide within hour solutions to a problem
> Telegram  name:- Errormania
>
> YouTube :- https://youtu.be/_xu1ds3DICA
> Raj Patel
>
> On Sun, 12 Apr, 2020, 6:06 pm rama prakash y, 
> wrote:
>
>> Hi can u plz tell me how can solve the pollsapp development in  django
>> project. I had complete my pollsapp development project in Django
>> documentation like that guidance.but i have browser error .
>>
>> --
>> You received this message because you are 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/c09b3231-3700-4157-9c4a-a75bc9a6e69c%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF_9CitU41d0peeuWj-vuLNpxNavUsJTrL3ZrZPAsAzCN3BFuQ%40mail.gmail.com
> 
> .
>

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


Re: best practice: using only url.py from the main project

2020-04-12 Thread Chucky Mada Madamombe
Hi yes it's bad practice.this is why:

The best point is to be able to reuse applications in different projects.
There will be problem if you are saving all your URLs in the
“projecturl.py” file. So best practice is to create an “url.py” per
application and to include it in your main projects url.py file.

Regards

Chuck G. Madamombe
NAM: +264 81 842 1284
RSA: +27 78 208 7034
Twitter: @chuckygari
Skype: chuckygari
Facebook: Chucky Mada Madamombe
LinkedIn: Chucknorris Garikayi Madamombe

On Sun, 12 Apr 2020, 14:37 Esther Camilo  wrote:

> Most of the tutorial recomends you create a url.py inside your app (as
> polls for example). Is it a bad practice using only url.py from the main
> project folder?
> Thanks for your attention.
>
> --
> You received this message because you are 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/0c93108f-370b-4555-8a65-e6d78f829e36%40googlegroups.com
> 
> .
>

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


Re: django doughts

2020-04-12 Thread Anonymous Patel
Ask your query in Errormania they helped me they have django Developers
they provide within hour solutions to a problem
Telegram  name:- Errormania

YouTube :- https://youtu.be/_xu1ds3DICA
Raj Patel

On Sun, 12 Apr, 2020, 6:06 pm rama prakash y,  wrote:

> Hi can u plz tell me how can solve the pollsapp development in  django
> project. I had complete my pollsapp development project in Django
> documentation like that guidance.but i have browser error .
>
> --
> You received this message because you are 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/c09b3231-3700-4157-9c4a-a75bc9a6e69c%40googlegroups.com
> 
> .
>

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


django doughts

2020-04-12 Thread rama prakash y
Hi can u plz tell me how can solve the pollsapp development in  django 
project. I had complete my pollsapp development project in Django 
documentation like that guidance.but i have browser error .

-- 
You received this message because you are 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/c09b3231-3700-4157-9c4a-a75bc9a6e69c%40googlegroups.com.


best practice: using only url.py from the main project

2020-04-12 Thread Esther Camilo
Most of the tutorial recomends you create a url.py inside your app (as 
polls for example). Is it a bad practice using only url.py from the main 
project folder?
Thanks for your attention.

-- 
You received this message because you are 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/0c93108f-370b-4555-8a65-e6d78f829e36%40googlegroups.com.


i want to change database sqllite to mysql but show error

2020-04-12 Thread Arun Sharma
python manage.py runserver



Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py",
 
line 16, in

import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File 
"C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
 
line 926, in _bootstrap_inner
self.run()
  File 
"C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
 
line 870, in run
self._target(*self._args, **self._kwargs)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
 
line 53, in wrappe
r
fn(*args, **kwargs)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\commands\runserver.py",
line 109, in inner_run
autoreload.raise_last_exception()
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
 
line 76, in raise_
last_exception
raise _exception[1]
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\__init__.py",
 
line 357,
in execute
autoreload.check_errors(django.setup)()
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py",
 
line 53, in wrappe
r
fn(*args, **kwargs)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\__init__.py",
 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\registry.py",
 
line 114, in populate

app_config.import_models()
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\config.py",
 
line 211, in import_mod
els
self.models_module = import_module(models_module_name)
  File 
"C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py",
 
line 127, in import_m
odule
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File "C:\Users\Arunkumar\PycharmProjects\app2\project\models.py", line 4, 
in 
class Project(models.Model):
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py",
 
line 121, in __new__

new_class.add_to_class('_meta', Options(meta, app_label))
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py",
 
line 325, in add_to_
class
value.contribute_to_class(cls, name)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\options.py",
 
line 208, in cont
ribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\__init__.py",
 
line 28, in __getattr__

return getattr(connections[DEFAULT_DB_ALIAS], item)
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py",
 
line 207, in __getitem__
backend = load_backend(db['ENGINE'])
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py",
 
line 111, in load_backend
return import_module('%s.base' % backend_name)
  File 
"C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py",
 
line 127, in import_m
odule
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File 
"C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py",
 
line 21, in

) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?










pip install mysqlclient
Collecting mysqlclient
  Using cached 
https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e
03a/mysqlclient-1.4.6.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
Complete output from command 
C:\Users\Arunkumar\PycharmProjects\app2\venv\Scripts\python.exe -u -c 
"import setupto
ols, 
tokenize;__file__='C:\\Users\\ARUNKU~1\\AppData\\Local\\Temp\\pip-install-5yg5lx4_\\mysqlclient\\setup.py';f=geta
ttr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', 

Re: This is channel helping in Django errors

2020-04-12 Thread Anonymous Patel
Errormania

They have. Some standards and they upload our solution to problem errors
videos.

I gave them 1 static error one, lets grow that django community on YouTube.
Follow them on telegarm

There telegram link is :- https://t.me/errormania

On Sun, 12 Apr, 2020, 5:40 pm Anonymous Patel, 
wrote:

> Its an community of django Developers
>
> https://youtu.be/_xu1ds3DICA
>
>
> https://youtu.be/RomFqczpVzs
>
> I think we should join that community and let them know we will even
> provide videos to solve the problem and error.
>
> https://www.youtube.com/channel/UCxxPBCkto7W8MX6TMctgLqw/
>

-- 
You received this message because you are 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/CAF_9CisU6f8jiwjZGNZKma1FW%2BTYMK-_xxUGh19BM19z7NDafw%40mail.gmail.com.


This is channel helping in Django errors

2020-04-12 Thread Anonymous Patel
Its an community of django Developers

https://youtu.be/_xu1ds3DICA


https://youtu.be/RomFqczpVzs

I think we should join that community and let them know we will even
provide videos to solve the problem and error.

https://www.youtube.com/channel/UCxxPBCkto7W8MX6TMctgLqw/

-- 
You received this message because you are 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/CAF_9CivMut_u8RM9%2BkmYbBeNfxcHzHM-c5Meyqq-Bfk3QE0A%3Dw%40mail.gmail.com.


Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-12 Thread Sunday Iyanu Ajayi
HI Jagtar,

Sometimes when you get 502 nginx server error , it can be due to the fact
that your django code has some error. If there is an error in your code,
nginx will no serve.

Try to run
sudo systemctl reload daemon-reload
sudo systemctl enable gunicorn
sudo systemctl restart gunicorn
sudo systemctl restart nginx

wait for about 2-5minutes then run
sudo systemctl status gunicorn

IT shoud display error in your code

*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *



On Sun, Apr 12, 2020 at 5:54 AM Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> wrote:

> No luck, same 502 error.
>
> These r settings.py
>
> *# SECURITY WARNING: don't run with debug turned on in production!*
>
> DEBUG = *False*
>
>
> ALLOWED_HOSTS = [*'iitian.xyz '*, *'192.95.37.123'*]
>
> On Sun, Apr 12, 2020 at 6:19 AM Andrew C.  wrote:
>
>> What’s the HTTP status code? Does the nginx page even show anything? Try:
>>
>> sudo systemctl stop nginx && sudo systemctl disable nginx && sudo
>> systemctl enable nginx && sudo systemctl start nginx
>>
>> This command could also be in the wrong order... it’s been awhile.
>>
>> It could be a symbolic link error. I don’t know. If you see some web page
>> with an error message like Internal Error 500 or the default nginx page,
>> let us know.
>>
>> On Sat, Apr 11, 2020 at 1:39 PM Jagtar Singh Lakhyan <
>> jagtar.lakhe...@gmail.com> wrote:
>>
>>> sudo systemctl status nginx
>>>
>>> *●* nginx.service - A high performance web server and a reverse proxy
>>> server
>>>
>>>Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor
>>> preset: enabled)
>>>
>>>Active: *active (running)* since Sat 2020-04-11 04:54:18 IST; 18h ago
>>>
>>>  Docs: man:nginx(8)
>>>
>>>   Process: 1650 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry
>>> QUIT/5 --pidfi
>>>
>>>   Process: 1652 ExecStart=/usr/sbin/nginx -g daemon on; master_process
>>> on; (code=exite
>>>
>>>   Process: 1651 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
>>> master_process on; (c
>>>
>>>  Main PID: 1653 (nginx)
>>>
>>> Tasks: 9 (limit: 1689)
>>>
>>>CGroup: /system.slice/nginx.service
>>>
>>>├─1653 nginx: master process /usr/sbin/nginx -g daemon on;
>>> master_process o
>>>
>>>├─1654 nginx: worker process
>>>
>>>├─1655 nginx: worker process
>>>
>>>├─1656 nginx: worker process
>>>
>>>├─1657 nginx: worker process
>>>
>>>├─1658 nginx: worker process
>>>
>>>├─1659 nginx: worker process
>>>
>>>├─1660 nginx: worker process
>>>
>>>└─1661 nginx: worker process
>>>
>>>
>>> Apr 11 04:54:18 wms systemd[1]: Starting A high performance web server
>>> and a reverse p
>>>
>>> Apr 11 04:54:18 wms systemd[1]: Started A high performance web server
>>> and a reverse pr
>>>
>>> On Sat, Apr 11, 2020 at 11:07 PM Rok Klancar  wrote:
>>>
 Dude, try "sudo systemctl status nginx"

 Dne sobota, 11. april 2020 18.53.50 UTC+2 je oseba Jagtar Singh Lakhyan
 napisala:
>
> Im trying to deploy django app using nginx & gunicorn but its showing
> error
>
> sudo nginx -t
>
> nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
>
> nginx: configuration file /etc/nginx/nginx.conf test is successful
>
>
> sudo systemctl status gunicorn.service
>
> gunicorn.service - gunicorn service
>
>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled;
> vendor preset:
>
>Active: *active (running)* since Sat 2020-04-11 21:19:19 IST; 11s
> ago
>
>  Main PID: 16326 (gunicorn)
>
> Tasks: 4 (limit: 1689)
>
>
> --
 You received this message because you are 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/a3223d66-8adb-4dcd-8a48-d43d8a426ddc%40googlegroups.com
 
 .

>>>
>>>
>>> --
>>>
>>> *jagtar singh*founder & CEO
>>> LinkedIn 
>>> Twitter 
>>>
>>> web 1: Network 
>>> web 2: WMS 
>>> web 3: Conference 
>>>
>>> Android App 1: Network
>>> 
>>> Android App 2: WMS
>>> 
>>> Android App 3: Conference
>>> 
>>>
>>> LinkedIn
>>> 
>>> LinkedIn2 

CUSTOMIZING ERROR 404 with debug =True

2020-04-12 Thread Sunday Iyanu Ajayi
Good day,

I have a web application built with django and angular. While deploying, I
had to set debug to be 'True' (debug=True) for it to work. but now we a
wrong url is type  with the root url, ( 192.2.3.4/ddfdf) , it takes be to
the django url with debug =True and even when I customize  or  create a new
custom 4004 error page ,it does not override the django default 404 error
page.

Please I need help on how to override django default error 404 page while
my debug is seet to true?
*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *

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


Re: Django - PrePopulate the Foreign Key on the web page, and use that id to save the model.

2020-04-12 Thread Antje Kazimiers
 Hi, I think in your view modulesView() you need to pass the project id to 
ModuleForm:

..
else :
form = ModuleForm(projectid)
..

and then you need to overwrite the constructor of ModuleForm by adding an 
__init__ function:

  def __init__(self, projectid=None, *args, **kwargs):
super(ModuleForm, self).__init__(*args, **kwargs)
if projectid is not None:
self.fields['project'] = forms.ModelChoiceField(
...
queryset=Project.objects.filter(id=projectid)
)

something like that. --Antje

On Sunday, April 12, 2020 at 8:14:51 AM UTC+2, Mayank Tripathi wrote:
>
> Hi All,
>
> I am facing an issue, to pre-populate the Foreign Key on the web page.
> Actually i have two models Projects and Modules. 
> To create a Module, one has to select the Project and go to Module page 
> for create it, but there the Project is not populated.
>
> Below are the details... Please guide me.
>
> *models.py*
> class Project(models.Model): 
> name = models.CharField(max_length = 200, null = True)
> startdate = models.DateTimeField()
>
> def __str__(self):
> return self.name
>
> class Modules(models.Model): 
> project = models.ForeignKey(Project, null = True, on_delete = 
> models.SET_NULL) 
> modulename = models.CharField(max_length = 200, null = True)
> modulestartdate = models.DateTimeField()
>
> def __str__(self):
> return self.modulename 
>
> *forms.py*
> class ProjectForm(forms.ModelForm):
> class Meta:
> model = Project
> fields = '__all__'
>
>
> class ModuleForm(forms.ModelForm): 
> class Meta: 
> model = Modules
> fields = '__all__'  
>
> *views.py*
> def projectView (request):
> if request.method == 'POST':
> form = ProjectForm(request.POST) 
> if form.is_valid():
> form.save(commit=True)
>
> return render(request, 'budget/projectForm.html', {'form': form})
>
> else :
> form = ProjectForm()
> return render(request, 'budget/projectForm.html', {'form': form})
>
>
> def modulesView (request, projectid):
> project = Project.objects.get(pk=projectid)
>  
> if request.method == 'POST':
> form = ModuleForm(request.POST) 
> if form.is_valid():
> form.save(commit=True)
>
> return render(request, 'example/modulesForm.html', {'form': form})
>
> else :
> form = ModuleForm(instance=project)
> return render(request, 'example/modulesForm.html', {'form': form})
>
> *urls.py*
> path('testproject/', views.projectView, name='projectView'),
> path('testprojectmodule//', views.modulesView, 
> name='modulesView'),
>
> in html forms for both Project and Modules... just using {{ form.as_table 
> }}.
>
> Now after createing the Project, i used the url as 
> http://127.0.0.1:8000/testprojectmodule/1/ 
> then my Project should get pre-populated... as reached using the project 
> id which is 1 in this case, but i am getting full drop-down. Refer attached 
> image.
> Either the Project should be pre-selected.. or can make it non-editable 
> either will work for me.
>
> 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/26744cb1-03e3-4189-a438-0b462013bb66%40googlegroups.com.


django dependent drop down list without using javascript; ajax; jquery

2020-04-12 Thread Mayank Tripathi
Hi All,

Could any one please share some details on how we can do dependent drop 
down list selection.
I am seeing lot of videos or content to handle this via JavaScript; AJAX; 
jquery etc.. but just wondering if Django has anything which can be handled 
easily.

-- 
You received this message because you are 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/5d0ab688-2f10-4380-b14d-c622ae5fa9fc%40googlegroups.com.


Django - PrePopulate the Foreign Key on the web page, and use that id to save the model.

2020-04-12 Thread Mayank Tripathi
Hi All,

I am facing an issue, to pre-populate the Foreign Key on the web page.
Actually i have two models Projects and Modules. 
To create a Module, one has to select the Project and go to Module page for 
create it, but there the Project is not populated.

Below are the details... Please guide me.

*models.py*
class Project(models.Model): 
name = models.CharField(max_length = 200, null = True)
startdate = models.DateTimeField()

def __str__(self):
return self.name

class Modules(models.Model): 
project = models.ForeignKey(Project, null = True, on_delete = 
models.SET_NULL) 
modulename = models.CharField(max_length = 200, null = True)
modulestartdate = models.DateTimeField()

def __str__(self):
return self.modulename 

*forms.py*
class ProjectForm(forms.ModelForm):
class Meta:
model = Project
fields = '__all__'


class ModuleForm(forms.ModelForm): 
class Meta: 
model = Modules
fields = '__all__'  

*views.py*
def projectView (request):
if request.method == 'POST':
form = ProjectForm(request.POST) 
if form.is_valid():
form.save(commit=True)

return render(request, 'budget/projectForm.html', {'form': form})

else :
form = ProjectForm()
return render(request, 'budget/projectForm.html', {'form': form})


def modulesView (request, projectid):
project = Project.objects.get(pk=projectid)
 
if request.method == 'POST':
form = ModuleForm(request.POST) 
if form.is_valid():
form.save(commit=True)

return render(request, 'example/modulesForm.html', {'form': form})

else :
form = ModuleForm(instance=project)
return render(request, 'example/modulesForm.html', {'form': form})

*urls.py*
path('testproject/', views.projectView, name='projectView'),
path('testprojectmodule//', views.modulesView, 
name='modulesView'),

in html forms for both Project and Modules... just using {{ form.as_table 
}}.

Now after createing the Project, i used the url as 
http://127.0.0.1:8000/testprojectmodule/1/ 
then my Project should get pre-populated... as reached using the project id 
which is 1 in this case, but i am getting full drop-down. Refer attached 
image.
Either the Project should be pre-selected.. or can make it non-editable 
either will work for me.

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/046a4b4b-57c5-45f2-bfed-84f938cf1e2d%40googlegroups.com.