Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-02 Thread James Schneider
On Thu, Nov 2, 2017 at 12:57 PM, fábio andrews rocha marques <
fabioandrewsrochamarq...@gmail.com> wrote:

> To use django forms is to use the django Form class and it's components on
> a view? How will this solve the issue? If i use the components, don't i
> have to re-render the page when a user makes an error on the form?
>
>
Are you submitting and rendering the information entirely via JavaScript?
That would be the only case where you may get errant messages on the same
page where the user submitted the form. You'll need to examine your JS
workflow, as that is not a Django issue.

You'll integrate the form usage within your view. The Django tutorial
covers this using both function-based views and class-based views. You
should do this even when submitting the information via AJAX/JS, but the
page doesn't necessarily need to be redirected because your JS will handle
re-rendering the page properly. I'd recommend the Django Rest Framework
package in that case.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVaD43g-u4tXc_Org%3DnX6%2BJuAdu1w%3Dtq0viQ9RA5gWYvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: postgres library in django using jython

2017-11-02 Thread Antonis Christofides
Hi,

apparently you are confusing sqlite with postgresql. Could you show the full
stack trace and error message, and your DATABASES setting?

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com

On 2017-11-02 20:23, Felipe Salazar wrote:
> Hi all
>
> I a python developer that I don't use Django very frequently. I am facing a 
> struggle these days because I am development APIs in Django but to deploy the
> project I want to pack the project in a war file, so that is the reason that 
> I am using Jython. However, I am getting errors when I try to connect the
> project to Postgres database because it said that the library sqlite2 is not
> supported in Jython. I installed pysqlite3 1.3 but it looks like that this
> version does not support Postgres until version 1.7 of, but when I tried to
> install the package I get an error:" ' NoneType' object has no attribute
> 'startswith' ".
>
> Please does anyone have an idea of how to solve this issue? 
>
> I appreciate any help and thank you in advance.
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e526aed1-8685-41ac-88f7-371f1bd54224%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

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


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-02 Thread fábio andrews rocha marques
To use django forms is to use the django Form class and it's components on 
a view? How will this solve the issue? If i use the components, don't i 
have to re-render the page when a user makes an error on the form?

On Tuesday, October 31, 2017 at 7:50:38 PM UTC-3, James Schneider wrote:
>
>
>
> On Oct 30, 2017 4:46 PM, "fábio andrews rocha marques" <
> fabioandrews...@gmail.com > wrote:
>
> Let's say i have a "register a new user" View and on this page, when the 
> user forgets to inform a password or a username, i show a message to him on 
> the same page saying "you forgot the password". The way i do this is by 
> doing this(on my View.py in a function called cadastrarprofessor):
>
> nomeusuario = request.POST['usuario'] #username
> nomesenha = request.POST['senha'] #password
> nomeemail = request.POST['email'] #email
>
> if not nomeusuario:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um usuário", 
> 'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
> elif not nomesenha:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
> 'nomeusuariocadastro':nomeusuario})
> elif not nomeemail:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
> 'nomeusuariocadastro':nomeusuario})
>
> And my template for this page(cadastro.html) is like this:
> 
> Cadastro
> 
> {% csrf_token %}
> Usuário: 
> {% if nomeusuariocadastro %}
>  nomeusuariocadastro }}>
> {% else %}
> 
> {% endif %}
>
>
> ... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)
>
> 
> 
> 
> 
> {% csrf_token %}
> 
> {% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
> sucesso!{% endif %}
> {% if error_message %}{{ error_message }}{% endif 
> %}
>
> So, every time the user forgets to mention a username or email or password 
> in this screen, i use render to redirect the user to the same page but this 
> time displaying a error_message. Let's say he did forget to fill the 
> textfield with a username... he goes back to the same page and sees the 
> error message. After that, let's say everything is right and he finally 
> registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
> registered new user) and stays on the same page. But when he goes back a 
> page(pressing "back" on the browser), instead of going back to the page 
> before the cadastro.html, he goes back to the same page cadastro.html but 
> displaying the error message for the "you forgot to mention your username". 
> I don't want him to go back to the same page with error message, i want to 
> make him go back to my main menu. 
>
>
> There is very little that you can do to prevent this type of behavior when 
> the user presses the back button.
>
> After the user successfully authenticates, they should be redirected to 
> the proper landing page by using an HTTP 302 redirect. This is very common 
> and baked in to all of the generic form handling views provided by Django. 
> If the page is redirected, then the user will encounter a warning pop up 
> from the browser asking if they want to resubmit the data. Generally this 
> is enough to scare users away from using the back button, but even if they 
> do continue through the warning, they'll simply reauthenticate and be 
> redirected to the same landing page, again.
>
> If that is not happening, them your form processing workflow is incorrect.
>
> From your view, you aren't using Django forms at all. I would highly 
> encourage you to do so, especially to better understand how form data 
> should be processed and validated, and how to properly handle responses 
> back to the client. The Django tutorial covers this topic. 
>
> -James
>

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


postgres library in django using jython

2017-11-02 Thread Felipe Salazar
Hi all

I a python developer that I don't use Django very frequently. I am facing 
a  struggle these days because I am development APIs in Django but to 
deploy the project I want to pack the project in a war file, so that is the 
reason that  I am using Jython. However, I am getting errors when I try to 
connect the project to Postgres database because it said that the library 
sqlite2 is not supported in Jython. I installed pysqlite3 1.3 but it looks 
like that this version does not support Postgres until version 1.7 of, but 
when I tried to install the package I get an error:" ' NoneType' object has 
no attribute 'startswith' ".

Please does anyone have an idea of how to solve this issue? 

I appreciate any help and thank you in advance.

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


Re: Cannot connect to 127.0.0.1 error

2017-11-02 Thread Jorge Gimeno
Check to see DATABASES is configured correctly in settings.py.  An example
of it looks like:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'myprojectuser',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
}
}

-Jorge

On Thu, Nov 2, 2017 at 7:50 AM, Aditya Vartak  wrote:

> Performing system checks...
>
> Unhandled exception in thread started by .
> wrapper
>  at 0x02A52AE0>
> Traceback (most recent call last):
>   File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py",
> line 213
> , in ensure_connection
> self.connect()
>   File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py",
> line 189
> , in connect
> self.connection = self.get_new_connection(conn_params)
>   File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py",
> line 27
> 4, in get_new_connection
> conn = Database.connect(**conn_params)
>   File "D:\anaconda\lib\site-packages\MySQLdb\__init__.py", line 86, in
> Connect
> return Connection(*args, **kwargs)
>   File "D:\anaconda\lib\site-packages\MySQLdb\connections.py", line 204,
> in __in
> it__
> super(Connection, self).__init__(*args, **kwargs2)
> _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server
> on '12
> 7.0.0.1' (10061)")
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "D:\anaconda\lib\site-packages\django\utils\autoreload.py", line
> 228, in
> wrapper
> fn(*args, **kwargs)
>   File "D:\anaconda\lib\site-packages\django\core\
> management\commands\runserver.
> py", line 125, in inner_run
> self.check(display_num_errors=True)
>   File "D:\anaconda\lib\site-packages\django\core\management\base.py",
> line 359,
>  in check
> include_deployment_checks=include_deployment_checks,
>   File "D:\anaconda\lib\site-packages\django\core\management\base.py",
> line 346,
>  in _run_checks
> return checks.run_checks(**kwargs)
>   File "D:\anaconda\lib\site-packages\django\core\checks\registry.py",
> line 81,
> in run_checks
> new_errors = check(app_configs=app_configs)
>   File "D:\anaconda\lib\site-packages\django\core\checks\model_checks.py",
> line
> 30, in check_all_models
> errors.extend(model.check(**kwargs))
>   File "D:\anaconda\lib\site-packages\django\db\models\base.py", line 1284
> , in c
> heck
> errors.extend(cls._check_fields(**kwargs))
>   File "D:\anaconda\lib\site-packages\django\db\models\base.py", line 1359
> , in _
> check_fields
> errors.extend(field.check(**kwargs))
>   File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py"
> , line
>  913, in check
> errors = super(AutoField, self).check(**kwargs)
>   File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py"
> , line
>  219, in check
> errors.extend(self._check_backend_specific_checks(**kwargs))
>   File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py"
> , line
>  322, in _check_backend_specific_checks
> return connections[db].validation.check_field(self, **kwargs)
>   File "D:\anaconda\lib\site-packages\django\db\backends\
> mysql\validation.py", l
> ine 49, in check_field
> field_type = field.db_type(self.connection)
>   File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py"
> , line
>  644, in db_type
> return connection.data_types[self.get_internal_type()] % data
>   File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35
> , in _
> _get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py",
> line 17
> 4, in data_types
> if self.features.supports_microsecond_precision:
>   File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35
> , in _
> _get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "D:\anaconda\lib\site-packages\django\db\backends\
> mysql\features.py", lin
> e 53, in supports_microsecond_precision
> return self.connection.mysql_version >= (5, 6, 4) and Database.
> version_info
> >= (1, 2, 5)
>   File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35
> , in _
> _get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py",
> line 38
> 5, in mysql_version
> with self.temporary_connection() as cursor:
>   File "D:\anaconda\lib\contextlib.py", line 82, in __enter__
> return next(self.gen)
>   File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py",
> line 591
> , in temporary_connection
> cursor = self.cursor()
>   File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py",
> line 254
> , in cursor
> return self._cursor()
>   File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py",
> line 229
> , in _cursor
> self.ensure_connectio

Re: My first project - URL issue?

2017-11-02 Thread Tony King

>
> Ok, well I've solved my immediate problem but clearly need to learn more 
> about JavaScript, jQuery and CSRF tokens.
>

But for anyone with a similar URL issue, I did the following;

Added an appname setting to my urls.py
appname = 'shopfront'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^launch_app/$', views.launch_app, name='launch'),
]

 Modified the $.post function to use the URL name mapping which as I 
expected meant I now have single function for handling the application 
launch.
{% for my_apps in my_apps_list %}
{{ my_apps.app_name }}

$("#app{{ forloop.counter }}").click( function() {
$.post("{% url 'launch' %}", {appname: '{{ my_apps.app_name }}'}, function 
() {});
});

{% endfor %}

 Initially this moved me onto CSRF token errors but having temporarily 
> disabled this, my function has been executed.  Onto the next issueCSRF 
> tokens..
>

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


Cannot connect to 127.0.0.1 error

2017-11-02 Thread Aditya Vartak
Performing system checks...

Unhandled exception in thread started by .
wrapper
 at 0x02A52AE0>
Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 213
, in ensure_connection
self.connect()
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 189
, in connect
self.connection = self.get_new_connection(conn_params)
  File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py", 
line 27
4, in get_new_connection
conn = Database.connect(**conn_params)
  File "D:\anaconda\lib\site-packages\MySQLdb\__init__.py", line 86, in 
Connect
return Connection(*args, **kwargs)
  File "D:\anaconda\lib\site-packages\MySQLdb\connections.py", line 204, in 
__in
it__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server 
on '12
7.0.0.1' (10061)")

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

Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\django\utils\autoreload.py", line 228, 
in
wrapper
fn(*args, **kwargs)
  File 
"D:\anaconda\lib\site-packages\django\core\management\commands\runserver.
py", line 125, in inner_run
self.check(display_num_errors=True)
  File "D:\anaconda\lib\site-packages\django\core\management\base.py", line 
359,
 in check
include_deployment_checks=include_deployment_checks,
  File "D:\anaconda\lib\site-packages\django\core\management\base.py", line 
346,
 in _run_checks
return checks.run_checks(**kwargs)
  File "D:\anaconda\lib\site-packages\django\core\checks\registry.py", line 
81,
in run_checks
new_errors = check(app_configs=app_configs)
  File "D:\anaconda\lib\site-packages\django\core\checks\model_checks.py", 
line
30, in check_all_models
errors.extend(model.check(**kwargs))
  File "D:\anaconda\lib\site-packages\django\db\models\base.py", line 1284, 
in c
heck
errors.extend(cls._check_fields(**kwargs))
  File "D:\anaconda\lib\site-packages\django\db\models\base.py", line 1359, 
in _
check_fields
errors.extend(field.check(**kwargs))
  File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py", 
line
 913, in check
errors = super(AutoField, self).check(**kwargs)
  File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py", 
line
 219, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
  File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py", 
line
 322, in _check_backend_specific_checks
return connections[db].validation.check_field(self, **kwargs)
  File 
"D:\anaconda\lib\site-packages\django\db\backends\mysql\validation.py", l
ine 49, in check_field
field_type = field.db_type(self.connection)
  File "D:\anaconda\lib\site-packages\django\db\models\fields\__init__.py", 
line
 644, in db_type
return connection.data_types[self.get_internal_type()] % data
  File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35, 
in _
_get__
res = instance.__dict__[self.name] = self.func(instance)
  File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py", 
line 17
4, in data_types
if self.features.supports_microsecond_precision:
  File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35, 
in _
_get__
res = instance.__dict__[self.name] = self.func(instance)
  File "D:\anaconda\lib\site-packages\django\db\backends\mysql\features.py", 
lin
e 53, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.
version_info
>= (1, 2, 5)
  File "D:\anaconda\lib\site-packages\django\utils\functional.py", line 35, 
in _
_get__
res = instance.__dict__[self.name] = self.func(instance)
  File "D:\anaconda\lib\site-packages\django\db\backends\mysql\base.py", 
line 38
5, in mysql_version
with self.temporary_connection() as cursor:
  File "D:\anaconda\lib\contextlib.py", line 82, in __enter__
return next(self.gen)
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 591
, in temporary_connection
cursor = self.cursor()
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 254
, in cursor
return self._cursor()
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 229
, in _cursor
self.ensure_connection()
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 213
, in ensure_connection
self.connect()
  File "D:\anaconda\lib\site-packages\django\db\utils.py", line 94, in 
__exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "D:\anaconda\lib\site-packages\django\utils\six.py", line 685, in 
reraise

raise value.with_traceback(tb)
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 213
, in ensure_connection
self.connect()
  File "D:\anaconda\lib\site-packages\django\db\backends\base\base.py", 
line 189
, in connect
self.connec

Re: Re-runnable sql scripts in the migrations framework

2017-11-02 Thread James Schneider
On Nov 2, 2017 4:01 AM, "Chris Wedgwood"  wrote:

Hi

As part of my deployment process I want to be able to have some db
scripts that are re-runnable

For example I have some internal configuration tables that I would
like to be able to change values with a merge statement in the same
file but not have to create a new migration file

I suppose my question is does the migration framework allow for
re-runnables?

If not can anyone recommend a good approach for this?


I have no idea what you are actually trying to achieve, but it sounds like
a custom management command may be able to get you there:

https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/

-James

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


Re: Adding data via admin not visible on html template until restart server (python manage.py runserver)

2017-11-02 Thread avtar sandhu
In the end I created a new app  and model and it worked correctly 
I never solved the original issue






On Tuesday, 19 September 2017 15:42:59 UTC+2, avtar sandhu wrote:
>
> Please can anyone help me
>
>
> I have a Django Model
>
> class Event(models.Model): scheduled_event = 
> models.BooleanField(default=True) category = models.CharField("category ", 
> max_length = 30)
>
> registered in admin
>
> class PostEvent(admin.ModelAdmin): admin.site.register(Event, PostEvent)
>
> I can add delete etc ok in Admin
>
> However the data is not refreshed in my html template until i restart the 
> server
>
> python manage.py runserver
>
>
> How can i make the changes dynamic.  dont want to restart the server 
> anytime a user makes some content change 
>
>
> All help would be appreciated 
>

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


My first project - URL issue?

2017-11-02 Thread Tony King

Hi,

I've started my first real project (django v1.11.4 and Python 3.6.2) and 
I'm probably trying to run before I'm ready, but anyway I'm here.  I'm 
essentially trying to create a front-end menu, that will eventually launch 
and log-on to either a local application or another web-site.  This latter 
part I have managed in Python but not within a Django project.

Anyway, I have a model which hold details of my 3rd party applications and 
I've created an index view and template that will display a series of 
buttons as below.

I want to execute another function when I click on one of the buttons, the 
current idea is a function per button but I expect this to evolve into a 
single function, I'm just trying to get something to work at the moment.  
I've found an example, involving jQuery, which I've attempted to adapt but 
I don't think I'm getting the URL right as nothing happens when I click one 
of my buttons.  I know the click event works, because if I leave in the 
$("h1").hide();, it works just fine.  So, I'm thinking I have the URL 
syntax wrong but as nothing happens, I'm not sure if I have any of the 
$.post quite right, although I receive no errors.

Having followed the tutorial I have stuck to the recommended folder layout 
as below;

project folder \
  *project files*
  shopfront \
  templates \
static \
jquery-3.2.1.min.js
  index.html
  urls.py
  views.py

Despite numerous edits, I don't seem to be getting anywhere - can someone 
tell me what I have wrong?

I'm going to need to create a front-end log-in page to this project, so if 
someone could point me in the right direction on doing this I would be 
grateful for that also.

urls.py
from django.conf.urls import url

from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^launch_app1/$', views.launch_app1, name='launch1'),
url(r'^launch_app2/$', views.launch_app2, name='launch2'),
url(r'^launch_app3/$', views.launch_app3, name='launch3'),
url(r'^launch_app4/$', views.launch_app4, name='launch4'),
url(r'^launch_app5/$', views.launch_app5, name='launch5'),
]


views.py
from django.shortcuts import render

from django.http import HttpResponse

from .models import my_apps

# Create your views here.
def index(request):
'''
Index page content function
'''
context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application List'}
return render(request, 'shopfront/index.html', context)

def launch_app1(request):
'''
Launch application function
'''
# context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application 
List - '+request['appname']+' Launched'}
context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application List 
- Application 1 Launched'}
return render(request, 'shopfront/index.html', context)
# return HttpResponse(request['msg'])

def launch_app2(request):
'''
Launch application function
'''
return HttpResponse(request['appname'])

. 


index.html
{% load static %}




https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>



var csrf_token = '{% csrf_token %}';



$("body").bind("ajaxSend", function(elm, xhr, s) {
if (s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Token', csrf_token);
}
});


{{ hdr1 }}

{% if my_apps_list %}

{% for my_apps in my_apps_list %}
{{ my_apps.app_name }}

$("#app{{ forloop.counter }}").click( function() {
// $("h1").hide();
$.post("launch_app{{ forloop.counter }}/", {appname: '{{ my_apps.app_name 
}}'}, function () {});
});

{% endfor %}

{% else %}
No applications are available.
{% endif %}


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


Re: Unable to use custom StaticFilesStorage

2017-11-02 Thread Stodge
There's a flaw in my plan as STATICFILES_STORAGE is a string and not a 
tuple. 

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


Re: Pulling data from database

2017-11-02 Thread Derek
You can look at the guide in the docs:

https://docs.djangoproject.com/en/1.11/howto/legacy-databases/

But as everyone will tell you; you need to have done a  basic tutorial 
first (official or otherwise*), otherwise all the jargon will be confusing.

After that, you can also look at areas such as:

https://docs.djangoproject.com/en/1.11/topics/db/queries/
and
https://docs.djangoproject.com/en/1.11/ref/models/expressions/

(* e.g. https://simpleisbetterthancomplex.com/series/)

On Thursday, 2 November 2017 13:18:18 UTC+2, jay seattle wrote:
>
> New to Django, coming from C# and I am totally confused how you pull data 
> from a database. I have a Postgres DB with a table "customer" created, but 
> have NO idea how to connect to it. I have read a bunch of stuff but they 
> all seem to work from the Model creation to database (migration), but if 
> the table is already created, I can't find detail what to do. 
>
> If I have a table called "customer" and want to pull the data into my 
> template, what should I read up on to accomplish this?
>
> Thanks
> Jay
>

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


Re: Pulling data from database

2017-11-02 Thread Jani Tiainen

Hi,

And welcome to world of Django.

You should start by reading official tutorial 
https://docs.djangoproject.com/en/1.11/intro/


If you feel that it's too compact, Django Girls do have much more 
verbose one https://tutorial.djangogirls.org/en/



On 2.11.2017 6.08, jay seattle wrote:
New to Django, coming from C# and I am totally confused how you pull 
data from a database. I have a Postgres DB with a table "customer" 
created, but have NO idea how to connect to it. I have read a bunch of 
stuff but they all seem to work from the Model creation to database 
(migration), but if the table is already created, I can't find detail 
what to do.


If I have a table called "customer" and want to pull the data into my 
template, what should I read up on to accomplish this?


Thanks
Jay
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64ab175d-4897-42ba-8f84-fa3778791226%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10f2be2b-1a5e-b4d6-512e-56f67cc035ff%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Remove/undo a multi table inheritance

2017-11-02 Thread 'Tom Evans' via Django users
Does it work if you do it in several stages (each one is a separate
migration action):

* Add the OneToOneField, make it nullable, still using MTI
* Add a python migration that populates it from the existing MTI information
* Remove the MTI
* Make the 1-2-1 field as you like it (remove null=True etc)

Of course, this won't get rid of MTI, as MTI is simply a normalized
way of specifying that other models have a one to one correspondence
with a base model - if you express this as model inheritance, or if
you express it as an explicit 1-2-1 with a base model makes no
difference to the underlying structure of the tables, and hence any
performance characteristics will not change, so why bother?

Cheers

Tom

On Thu, Nov 2, 2017 at 9:11 AM,   wrote:
> Hi,
>
> I have introduced a multi table inheritance in the past. Now I am trying to
> remove it again by adding an explicit one-to-one relation from the child
> table to the parent. So my starting point is:
>
> from django.db import models
>
> class Place(models.Model):
>  name = models.CharField(max_length=50)
>  address = models.CharField(max_length=80)
>
> class Restaurant(Place):
>  serves_hot_dogs = models.BooleanField(default=False)
>  serves_pizza = models.BooleanField(default=False)
>
>
> And I want to end up with something similar to this:
>
>
> from django.db import models
>
> class Place(models.Model):
>  name = models.CharField(max_length=50)
>  address = models.CharField(max_length=80)
>
> class Restaurant(models.Model):
>  place_ptr = models.OneToOneField(Place)
>  serves_hot_dogs = models.BooleanField(default=False)
>  serves_pizza = models.BooleanField(default=False)
>
> When running make migrations it will prompt me for an initial value for the
> newly introduced `id` field, which I don't know howto provide.
>
>
> I attempt the following fixes:
>
>
>- introducing an Integer field, copy data from the implicit OneToOneField
> and making both explicit while switiching the primary_key at the same time
> (fails in sqlite with NOT NULL constraint and primary key issues on
> postgres)
>
>- writing a SplitDatabaseAndState migration where in the State part the
> model is deleted and recreated, while in the database part the shema editor
> is used to alter the fields as needed, that didn't work either
>
>
> So there are two questions that come to my mind:
>
>
> 1. What is the proper way to undo a multi table inheritance?
>
> 2. Is there even an official way to change the primary key of a model in
> Django, that does work without SQL migrations?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ff8be877-1eb8-419b-b456-89d20e9c09d8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Pulling data from database

2017-11-02 Thread jay seattle
New to Django, coming from C# and I am totally confused how you pull data 
from a database. I have a Postgres DB with a table "customer" created, but 
have NO idea how to connect to it. I have read a bunch of stuff but they 
all seem to work from the Model creation to database (migration), but if 
the table is already created, I can't find detail what to do. 

If I have a table called "customer" and want to pull the data into my 
template, what should I read up on to accomplish this?

Thanks
Jay

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


Re: write custom decorators in django to authenticate the user

2017-11-02 Thread yves . mueller
Can you post an example of how you are using the decorator? If you are 
using it on a dispatch/get/post ... method of a class based views, it will 
still get the instance (self) as a first parameter. So you should take also 
self as an argument to your inner wrap method.

Unrelated: Your wrap method never calls f, that is probably also something 
you would like to change.

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


Remove/undo a multi table inheritance

2017-11-02 Thread yves . mueller
Hi,

I have introduced a multi table inheritance in the past. Now I am trying to 
remove it again by adding an explicit one-to-one relation from the child 
table to the parent. So my starting point is:
 
from django.db import models

class Place(models.Model):
 name = models.CharField(max_length=50)
 address = models.CharField(max_length=80)

class Restaurant(Place):
 serves_hot_dogs = models.BooleanField(default=False)
 serves_pizza = models.BooleanField(default=False)


And I want to end up with something similar to this:


from django.db import models

class Place(models.Model):
 name = models.CharField(max_length=50)
 address = models.CharField(max_length=80)

class Restaurant(models.Model):
 place_ptr = models.OneToOneField(Place) 
 serves_hot_dogs = models.BooleanField(default=False)
 serves_pizza = models.BooleanField(default=False)

When running make migrations it will prompt me for an initial value for the 
newly introduced `id` field, which I don't know howto provide.


I attempt the following fixes:


   - introducing an Integer field, copy data from the implicit OneToOneField 
and making both explicit while switiching the primary_key at the same time 
(fails in sqlite with NOT NULL constraint and primary key issues on postgres)

   - writing a SplitDatabaseAndState migration where in the State part the 
model is deleted and recreated, while in the database part the shema editor is 
used to alter the fields as needed, that didn't work either


So there are two questions that come to my mind:


1. What is the proper way to undo a multi table inheritance?

2. Is there even an official way to change the primary key of a model in 
Django, that does work without SQL migrations?


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


Re-runnable sql scripts in the migrations framework

2017-11-02 Thread Chris Wedgwood
Hi

As part of my deployment process I want to be able to have some db
scripts that are re-runnable

For example I have some internal configuration tables that I would
like to be able to change values with a merge statement in the same
file but not have to create a new migration file

I suppose my question is does the migration framework allow for re-runnables?

If not can anyone recommend a good approach for this?

thanks
Chris

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