George
I think there are decorators for that
Krunal
I think there are decorators for that
I try decorator but it's not working
George
I havent implemented it but i know a bit
George
@login_required
I have seen that :)
cj
@login_required
and LoginRequiredMixin for CBV
Mirco
and LoginRequiredMixin for CBV
Yup but I think he's using FBVs
cj
looks like he is
Mirco
Krunal
I don't have permission to send media in this group.
Mirco
I don't have permission to send media in this group.
Yup, because you have to use code sharing service like pastebin 😁 Read pinned message pls
George
We should promote pastebin like services like 10000x compression, efficient, cheap omg
Mayank
hi
Mayank
any one is there
Mayank
i want to add extra fileds to the user which shows to the admin page and remove is_staff and user permission ...how to do that please help
Neo
can anybody tell me how can i send additional modelform of different model with current model
Mehul
SMTPSenderRefused at /password-reset/ (530, b'5.5.1 Authentication Required. Learn more at\n5.5.1 https://support.google.com/mail/?p=WantAuthError z62sm8168280pfi.4 - gsmtp', 'webmaster@localhost')
Mehul
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = os.environ.get('EMAIL_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') setting.py file
Mehul
path('password-reset/', auth_views.PasswordResetView.as_view( template_name='users/password_reset.html' ), name='password_reset'), path('password-reset/done/', auth_views.PasswordResetDoneView.as_view( template_name='users/password_reset_done.html' ), name='password_reset_done'), path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view( template_name='users/password_reset_confirm.html' ), name='password_reset_confirm'), path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view( template_name='users/password_reset_complete.html' ), name='password_reset_complete'), path('', include('blog.urls')),
Mehul
url.py file.
Paritosh
https://stackoverflow.com/questions/54547705/how-to-fix-the-labels-positioned-wrong-in-my-default-django-form
Mayank
i want to add extra fileds to the user which shows to the admin page and remove is_staff and user permission ...how to do that please help
Mayank
from django.contrib import admin from .models import MyUser class MyUserAdmin(admin.ModelAdmin): list_display = ('username','email','phone','account_name','account_number','bank_name') USERNAME_FIELD = 'email' def str__(self): # __unicode on Python 2 return self.email admin.site.register(MyUser,MyUserAdmin)
Mayank
admin .py above
Mayank
from django.db import models from django.contrib.auth.models import AbstractUser class MyUser(AbstractUser): phone = models.CharField(max_length = 20) account_name = models.CharField(max_length = 200) account_number = models.IntegerField() bank_name = models.CharField(max_length = 200) class Meta: unique_together = ('account_number', 'bank_name') # class UserManager(BaseUserManager): # def create_user(self, email,name,phone,account_name,account_number,bank_name,bsb_number, password=None,is_staff=False,is_admin=False): # if not email: # raise ValueError('Users must have an email address') # if not password: # raise ValueError("Users must have password ") # user = self.model( # email=self.normalize_email(email), # ) # user.set_password(password) # user.save(using=self._db) # return user # # def create_staffuser(self, email, password=None): # user = self.create_user( # email, # password=password, # ) # user.staff = True # user.save(using=self._db) # return user # # def create_superuser(self, email, password): # user = self.create_user( # email, # password=password, # ) # user.staff = True # user.admin = True # user.save(using=self._db) # return user # # # hook in the New Manager to our Model # # # class User(AbstractBaseUser): # email = models.EmailField(verbose_name='email address',max_length=255,unique=True,) # active = models.BooleanField(default=True) #can login # staff = models.BooleanField(default=False) # a admin user; non super-user # admin = models.BooleanField(default=False) # a superuser # # notice the absence of a "Password field", that's built in. # name = models.CharField(max_length = 200) # phone = models.CharField(max_length = 20) # account_name = models.CharField(max_length = 200) # account_number = models.IntegerField() # bank_name = models.CharField(max_length = 200) # bsb_number = models.IntegerField() # # # USERNAME_FIELD = 'email' # REQUIRED_FIELDS = ['name','phone','account_name','account_number','bank_name','bsb_number'] # Email & Password are required by default. # # def get_full_name(self): # return self.email # # def get_short_name(self): # return self.email # # def str__(self): # __unicode on Python 2 # return self.email # # def has_perm(self, perm, obj=None): # "Does the user have a specific permission?" # # Simplest possible answer: Yes, always # return True # # def has_module_perms(self, app_label): # "Does the user have permissions to view the app app_label?" # # Simplest possible answer: Yes, always # return True # # @property # def is_staff(self): # return self.staff # # @property # def is_admin(self): # return self.admin # # @property # def is_active(self): # return self.active # # # # # class Investor(models.Model): # # name = models.CharField(max_length = 200) # # email = models.EmailField() # # phone = models.CharField(max_length = 20) # # password = models.CharField(max_length = 20) # # account_name = models.CharField(max_length = 200) # # account_number = models.IntegerField() # # bank_name = models.CharField(max_length = 200) # # bsb_number = models.IntegerField() # # # # def __str__(self): # # return self.name
Mayank
model.py
Mayank
DM?
Ronald
Direct Message
Ronald
Private Message
Mayank
okay
Mayank
so how to do that
Ronald
use the chat
Mayank
can you give me any hint
Mayank
how to do that
Mayank
adding some extra fileds in user model and want to remove timestmaps and all that
Ronald
also, remove the code
Ronald
and use
Ronald
Pastebin
Ronald
or
Ronald
dpaste
Mirco
?
Enable less secure apps on Google
Mehul
Enable less secure apps on Google
try it ...but it will show same error
Mehul
k
Anonymous
Hii, Any rich text editor for djano. ?? I tried summernote but its shows the data with html tags
Kowalski
Saran maybe try vscode with some django plugins?
Anonymous
I think you're not getting his question
Anders (izzno / gooood) πŸ‡³πŸ‡΄
I am creating a Django app that "i think" consists of two parts. A pim system which holds information about our products and product models and information around that which will be served over an API && a news/product site pulling information from the pim models and have its own models like articles etc... Would you split these in two different apps and keep the api as a seperate app and import the models as needed in the "site" app? Any thoughts on how to do this ?
Anders (izzno / gooood) πŸ‡³πŸ‡΄
lex
pycharm, has the best django support.
Pycharm has Django support only in Professional edition
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Student license is free, one month free professional for everyone.
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Anything special about importing models from another app ?
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Namespaces etc will probably not be an issues as the pim will only use DRE
inchidi
Hii, Any rich text editor for djano. ?? I tried summernote but its shows the data with html tags
you dont need any specific rich text editor for django tho. any rich text editor should work. probably you are using it wrong, my quick ddg search: https://github.com/summernote/summernote/issues/59 maybe you want to check it out
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Pycharm has Django support only in Professional edition
I still meen the license is worth it... If you plan to use Django/Flask/python/JS and OR Vue/React/Angular and more the support is uncomparable ...
Anders (izzno / gooood) πŸ‡³πŸ‡΄
That being said, its a full blown IDE. Not comparable to Atom/Sublime/VScode etc... Does not start in ms ;)
Anders (izzno / gooood) πŸ‡³πŸ‡΄
Mirco
Anything special about importing models from another app ?
nope, I think you always import models from other apps for example think about User model from contrib.auth
Anders (izzno / gooood) πŸ‡³πŸ‡΄
good point ;)
inchidi
?
not one month free pro but one year free pro
Anders (izzno / gooood) πŸ‡³πŸ‡΄
One month free for trial. Unlimited free as long as you are a student.
Anders (izzno / gooood) πŸ‡³πŸ‡΄
https://www.jetbrains.com/student/
Mirco
good point ;)
💪🏻💪🏻
Anders (izzno / gooood) πŸ‡³πŸ‡΄
The akilles might be that you get spoiled when it comes to autocomplete / linting but your progress will skyrocket.