Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
I doubt whether you are reading my response properly. Let me reiterate my response for you. *There are two ways to do this. * *1. You can set the owner as the logged in user by default* *2. You can provide all possible owners as options and the user can select the owner from a dropdown.* *For

Re: CRUD code feedback

2018-01-27 Thread tango ward
Sorry for being a drag, I tried this code: class CreateDog(CreateView): template_name = 'dogs_cats/create_dog.html' model = Dog fields = ('name', 'bday', 'owner') def get_initial(self): initial_data = super(CreateDog, self).get_initial() initial_data["owner"] = [(s

Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
override get_initial and set only the logged in user class CreateDog(CreateView): ... def get_initial(self): initial_data = super(CreateDog, self).get_initial() initial_data["owner"] = [(self.request.user.id, self.request.user.username)] return initial_data

Re: CRUD code feedback

2018-01-27 Thread tango ward
I updated my models. py from django.db import models from django.contrib.auth import get_user_model from django.contrib.auth.models import User, PermissionsMixin # Create your models here. Pet_Owner = get_user_model() class RegisteredUser(User, PermissionsMixin): def __str__(self):

Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
There are two ways to do this. 1. You can set the owner as the logged in user by default 2. You can provide all possible owners as options and the user can select the owner from a dropdown. For case 1, you may not want to display the owner field in frontend. Here you can override form_valid an

Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
Its the reverse. If the owner is deleted, all the cats and dogs associated with the owner will be deleted. On Sunday, 28 January 2018 10:43:54 UTC+5:30, tangoward15 wrote: > > Will try it now. > > Quesion about the on_delete=models.CASCADE, does this mean that if I > delete the pet (dog or cat)

Re: CRUD code feedback

2018-01-27 Thread tango ward
When I added the owner field, it doesn't have any value though the user is already registered. how do i make it mandatory in createview? owner = Owner.objects.create_user(username="blah", password="blah", email=" b...@blah.com") dog = Dog(name="mydog", bday=datetime.today(), owner=owner).save()

Re: CRUD code feedback

2018-01-27 Thread tango ward
Will try it now. Quesion about the on_delete=models.CASCADE, does this mean that if I delete the pet (dog or cat) it will delete the owner who owns them? On Sun, Jan 28, 2018 at 1:11 PM, Akhil Lawrence wrote: > Your create view do not accept owner as a input and according to your > models, owne

Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
Your create view do not accept owner as a input and according to your models, owner can be null. That's the problem. Include owner to your create view fields as shown below. Also you may consider making owner mandatory as mentioned in my previous response. class CreateDog(CreateView): mode

Re: CRUD code feedback

2018-01-27 Thread tango ward
Hi, Thanks for the response Akhil, I am using the CreateView in my view.py to create ne pets class CreateDog(CreateView): model = Dog fields = ('name', 'bday') template_name = 'animals/dog_create.html' class CreateCat(CreateView): model = Cat fields = ('name', 'bday')

Customizable Invoice

2018-01-27 Thread Rakhee Menon
Hi Everyone, I want to create a customizable invoice format wherein i can drag and drop the fields to any position and can save the current format and print the invoice . Please can anyone help me out with it. Thanks in Advance Regards , Rakhee -- You received this message because you are su

Re: CRUD code feedback

2018-01-27 Thread Akhil Lawrence
Hi Jarvis, The code which you have posted only shows the model. Within your cat and dog models the owner can be null. Which explains why the owner is not associated with the pets. Can I see the code you tried to insert the records? ## changes needed in models models.ForeignKey(Owner, related_n

CRUD code feedback

2018-01-27 Thread tango ward
Hi, I am playing around with CRUD. I want a user a create an account first before he/she can add pets under his/her profile. I tried adding one pet however it's seems that it is not associated to the Owner who added the pet. models.py from django.db import models from django.contrib.auth.models

javascript transpilers

2018-01-27 Thread Mike Dewhirst
I have avoided javascript like the plague. However it seems I have to bite the bullet. Interestingly, there are now a number of Python -> Javascript transpilers. http://stromberg.dnsalias.org/~strombrg/pybrowser/python-browser.html Where would be a good place to start a discussion on the topic

Re: Get request, has PK, how do I access the PK data with in the model

2018-01-27 Thread Matemática A3K
https://docs.djangoproject.com/en/2.0/intro/tutorial01/ On Sat, Jan 27, 2018 at 8:19 AM, Travis Pickle wrote: > Andy, > > Do you have a link for this? Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this grou

Native JIT compiler for Django?

2018-01-27 Thread Etienne Robillard
Hi, I would like to know if it's possible to compile Django code with a JIT compiler to a C file using LLVM? What do you think? Etienne Etienne Robillard tkad...@yandex.com https://www.isotopesoftware.ca/ -- You received this message because you are subscribed to the Google Groups "Django

Re: Dynamic update template

2018-01-27 Thread Ruchit Bhatt
Ok.Thank you so much for reply. -- 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 d

Re: CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

2018-01-27 Thread Andréas Kühne
If you are not running with the following statement in settings.py: DEBUG = True AND you have to run the server with "python manage.py runserver", if you are running it in any other way, you have to setup ALLOWED_HOSTS. You could also (but definitely not recommended) set ALLOWED_HOSTS = ['*'] T

Re: CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

2018-01-27 Thread Jason
uhm, implement the setting for your enviroment? https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts On Saturday, January 27, 2018 at 9:04:17 AM UTC-5, bootcamprag wrote: > > Hello > > I am using django 2.0 and I cannot resolve the the error in the subject > line when I run the loc

Re: Dynamic update template

2018-01-27 Thread Jason
Any of those options work for the frontend. I wouldn't worry so much about the reading the code for the following reasons: 1. You're most likely using a build step for production deployment which concatenates all the files into one and minifies it after, with renaming of functions, cl

CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

2018-01-27 Thread bootcamprag
Hello I am using django 2.0 and I cannot resolve the the error in the subject line when I run the local server. I am in the development phase. Not production. Please assist. Thanks. r, Demayne -- You received this message because you are subscribed to the Google Groups "Django users" group

Re: Dynamic update template

2018-01-27 Thread Ruchit Bhatt
Ok,so you are suggesting front-end framework to make life easier. Do you have any personal choice over angularjs / React / Vue ? One more thing, how security will work in this case because javascript runs on client side & anybody can read how js code comunicating with backend ? -- You received

Re: Dynamic update template

2018-01-27 Thread Jani Tiainen
Hi. Unfortunately doing ajax calls to partially update page is required. It is possible to write all the javascript needed by hand but using frameworks usually makes things easier. 27.1.2018 13.32 "Ruchit Bhatt" kirjoitti: > Hi folks, > Currently i am using Django at basic/intermediate level.

Dynamic update template

2018-01-27 Thread Ruchit Bhatt
Hi folks, Currently i am using Django at basic/intermediate level. And in my web template, single page contains more than one *Forms*, many *chart.js* widgets for to plot graph, plus 2-3 small widget for task management. Now i want to make my site more dynamic (i.e update UI without reloading wh

Re: Get request, has PK, how do I access the PK data with in the model

2018-01-27 Thread Travis Pickle
Andy, Do you have a link for this? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send

Re: Deploying SSL for my Django 2.0.1 server with Apache on Ubuntu 16.04 (droplet)

2018-01-27 Thread Antonis Christofides
> > But the following is still saying, “Forbidden”: > > > https://www.angeles4four.info/static/admin/ > This is normal. The reason is not the filesystem permissions, but that Apache is configured to not list files inside that directory (to change that you'd need to use "Options Indexes" somewhere,