Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-15 Thread Mislav Jurić
Thank you for your suggestion. I will use the username, as it is unique as well. Best, Mislav Dana ponedjeljak, 14. rujna 2020. u 19:45:36 UTC+2 korisnik coolguy napisao je: > If i had to stick to your code then i would save the file with > instance.username. username is available and folder

Re: I've got two apps in my project and each one should have different authentication model. How do achieve this?

2020-09-15 Thread Mislav Jurić
ou > can add it on the new Model > > It could be the one of the easy ways. > Thanks > > On Mon, Sep 14, 2020 at 11:00 PM Mislav Jurić > wrote: > >> Hey guys, >> >> as the title says, I've got two apps in my project and each one should >> have differ

I've got two apps in my project and each one should have different authentication model. How do achieve this?

2020-09-14 Thread Mislav Jurić
Hey guys, as the title says, I've got two apps in my project and each one should have different authentication model. My first app just extends the User class, which I have done following the instructions here .

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-14 Thread Mislav Jurić
What I can do is first register the employee via a register form, then once he logs in ask him/her for the profile picture. *Can I do that this way? * If I do it this way, I don't have to change my model in any way. Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao je: >

How do I make a pre-selectable city and country pairs which will be stored in a model?

2020-09-13 Thread Mislav Jurić
Hey guys, I want to make a drop-down list of all city an country pairs (such as New York, USA) where the user, upon registration, will be able to select the (city, country) pairs from all over Europe and then I want to store that in one of my models. *How do I accomplish this (both front-end and

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-13 Thread Mislav Jurić
Hey coolguy, thanks for responding. After I changed that line as you suggested that error is solved, *but when I add the user through the admin interface, I get None as the ID* (the folder that gets created in the */media/users* is titled *None*). I'm not sure if this is expected behavior. I

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
coolguy here is the complete Employee model: class Employee(models.Model): #TODO: Double-check this username = models.CharField(max_length=50, unique=True) email = models.EmailField() password = models.CharField(max_length=50) first_name = models.CharField(max_length=150)

Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
of the *migrations* folders from all >>>> of my apps. >>>> >>>> Thank you for responding. >>>> >>>> Best, >>>> Mislav >>>> >>>> >>>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik >>&

AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-12 Thread Mislav Jurić
Hey guys, I have the following code in models.py file in one of my apps: def get_upload_path(instance, filename): extension = filename.split('.')[-1] return "employees/media/users/{0}/profile_picture.{1}".format( instance.user.id, extension) class Employee(models.Model): # some

Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
t;> Thank you for responding. >> >> Best, >> Mislav >> >> >> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik >> mailto...@gmail.com napisao je: >> >>> you need to give default value in email. seems few records are already &

Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
: > you need to give default value in email. seems few records are already > exist. > > else delete sqllite file and try again. > > On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić wrote: > >> Hey guys, >> >> I added an EmailField >> <https:/

Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
: > you need to give default value in email. seems few records are already > exist. > > else delete sqllite file and try again. > > On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić wrote: > >> Hey guys, >> >> I added an EmailField >> <https://docs.django

I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey guys, I added an EmailField to some of my already existing models. When I tried to run: *python manage.py makemigrations* I got the following prompt: *You are trying to add a non-nullable field 'email' to employee

Re: I need help with my first Django project - its structure etc.

2020-09-10 Thread Mislav Jurić
: > 1. You have to start from there > 2. Yes you need two apps companies and employees > 3. Yes your idea is correct > 4. You can do that. > > Email me if you still need help > > On Thursday, September 10, 2020, Mislav Jurić > wrote: > >> Hey guys, >

Re: I need help with my first Django project - its structure etc.

2020-09-10 Thread Mislav Jurić
Yes your idea is correct > 4. You can do that. > > Email me if you still need help > > On Thursday, September 10, 2020, Mislav Jurić > wrote: > >> Hey guys, >> >> I went through the Django tutorial >> <https://docs.djangoproject.com/en/3.1/intro/t

I need help with my first Django project - its structure etc.

2020-09-10 Thread Mislav Jurić
Hey guys, I went through the Django tutorial about 2 weeks ago and I decided to create a website using Django. I have a couple of questions on the structure of the Django project, but before I voice them, I wanted to describe the features