Re: Django - Pass a model instance specified by template tags to the view

2017-11-09 Thread Jack Zhang
bscr...@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/CAH-jdcw11Z1w2qRCkuwzdXL0qFNXD1Pk

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
m = Dog_Form(request.POST) > if form.is_valid(): > form_save = form.save(commit=False) > form_save.user = request.user # user is logged in > form.save() > > > On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang <valac...@gmail.com > > wrote: > >> Let's

Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
Let's say I have a model called 'Dogs'. Users can create instances of Dogs. Let's say we have a user called User1. I have 2 questions: 1. When User1 creates an instance of Dogs, how do I automatically assign that instance to User1? I tried using a model field like this but it doesn't pick

Re: Generating a unique 10 digit ID for each model instance

2017-10-23 Thread Jack Zhang
, 2017 at 4:32:28 AM UTC-4, James Schneider wrote: > > > > On Oct 22, 2017 8:52 AM, "Jack Zhang" <valac...@gmail.com > > wrote: > > Let's say I have a model called 'Dogs'. Users can create instances of > Dogs. For every Dogs instance that is created,

Building a search form with 4 required choices, which will be inserted as arguments in an URL [warning: long question]

2017-10-23 Thread Jack Zhang
This is a semi-long question. Please let me know wherever I make a mistake. I'm building a search form with 4 required choices, 1 of the choices is a CharField with a max_length of 3. The other 3 choices are ChoiceField's. Here is a picture of what the search form looks like:

Re: Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
tabase usually handles this and you don't need to worry, there are > many corner cases and DB systems are able to handle them > > But they won't look like whatever format you would like, usually it is > just a number > > Why do you need the IDs to look like that? > > On Oct

Re: Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
D field. See > https://docs.djangoproject.com/en/1.11/topics/signals/ > > Best regards, > > Andréas > > 2017-10-22 17:52 GMT+02:00 Jack Zhang <valac...@gmail.com >: > >> Let's say I have a model called 'Dogs'. Users can create instances of >>

Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
Let's say I have a model called 'Dogs'. Users can create instances of Dogs. For every Dogs instance that is created, I want to assign a globally unique ID to it. The ID will be 3 capitalized letters followed by 7 numbers. E.g. ABC1234567, POZ2930193 What is the easiest way to go about

Django 1.11 - Best Datepicker to use?

2017-10-21 Thread Jack Zhang
I'm looking for a datepicker widget to use for a DateTime form field. I searched around and most of the answers were old Stack Overflow posts from 2011 about hacking the calendar datepicker widget from Django's Admin. The information about that was inconclusive and I couldn't get mine to