Rajjix
add your path then LoginView.as_view(template_name=<your_template>
Rajjix
template_name should be a string
Danil
template_name should be a string
yeah it's working, but then i need sign up view
Danil
and i use same methods as i used to in login view
Rajjix
almost only u add a CreateView in your views
Rajjix
And a form for password validation in forms
Rajjix
The form and views both should be 6 lines of code if not less i’ll send you a snippet if needed
Rajjix
maybe a bit more for password validation xd
Danil
i have user creation form
Rajjix
in your views import CreateView Import your form class NewDick(CreateView): form_class = <your_form> template_name = ‘lol’ success_url= ‘/‘
Danil
yeah, but i still have troubles with my model
Danil
e.g now i can't see email field in admin panel
Rajjix
u can’t see the field when creating a user only
Rajjix
in the admin panel right?
Danil
i've created user via class based view
Danil
and then in admin panel i can't see his email
Danil
but i can get it with self.email
Rajjix
ok
Danil
some mystery you know
Rajjix
import user model to admin.py
Rajjix
and i’ll send u snippet
Danil
ofc i did
Rajjix
class UserAdmin(BaseUserAdmin): add_form = <your_form> list_display = ('username','email','is_admin') list_filter = ('is_admin',) fieldsets = ( (None, {'fields': ('username','email','password')}), ('Permissions', {'fields': ('is_admin',)}) ) filter_horizontal = () admin.site.register(MyUser, UserAdmin)
Danil
ERRORS: <class 'users.admin.CustomProfileAdminView'>: (admin.E108) The value of 'list_display[2]' refers to 'is_admin', which is not a callable, an attribute of 'CustomProfileAdminView', or an attribute or method on 'users.Profile'. <class 'users.admin.CustomProfileAdminView'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_admin', which does not refer to a Field.
Danil
got these errors
Danil
im pretty sure that i've messed up with my custom model
Danil
somewhere
Rajjix
Send ur models
Danil
i've sent it already
Danil
here it is
Danil
https://gist.github.com/yungcatx/16f6c02679d4e8ea0b86970c08ececdb
Danil
don't look at views, i've changed it
Danil
and that's a form
Danil
class SignUpForm(UserCreationForm): email = forms.EmailField(required=True) class Meta: model = Profile fields = ['username', 'password1', 'password2']
Danil
oops
Rajjix
change is_superuser to is_admin
Danil
same errors
Rajjix
but why the if statements in your superuser creation
Rajjix
try this function instead
Rajjix
def create_superuser(self, username, email, password=None): user = self.create_user( username, email, password=password ) user.is_admin = True user.is_staff = True user.is_active = True user.save(using=self._db) return user
Danil
nah, still the same
Rajjix
how?
Rajjix
same error?
Danil
yeah
Danil
<class 'users.admin.CustomProfileAdminView'>: (admin.E108) The value of 'list_display[2]' refers to 'is_admin', which is not a callable, an attribute of 'CustomProfileAdminView', or an attribute or method on 'users.Profile'. <class 'users.admin.CustomProfileAdminView'>: (admin.E116) The value of 'list_filter[0]' refers to 'is_admin', which does not refer to a Field.
Danil
this one
Rajjix
wait wait
Rajjix
fuck sorry my bad
Rajjix
what did you import in your admin.py
Danil
sign up form
Danil
and profile model
Rajjix
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
Danil
as i remember i can't use useradmin with abstract user
Danil
still the same
Rajjix
ok then delete what's in your admin.py
Rajjix
and we go round 2
Danil
mby i define my fields incorrect?
Danil
i mean in model
Danil
or sth like that
Rajjix
no ur fields are right if you 're creating users
Rajjix
but hey
Rajjix
in your admins.py
Rajjix
from django.contrib import admin
Danil
yeah
Danil
got this one
Rajjix
class ProfileAdmin(admin.ModelAdmin): list_display = ('username', 'email') admin.site.register(Profile, ProfileAdmin)
Rajjix
and import Profile from your models as well
Rajjix
ah u don't have a username
Rajjix
remove it
Rajjix
use whatever fields here from ur models
Danil
yeah i see now
Danil
big thx to you
Danil
it's working
Rajjix
remove the username field from the create super user function i sent u as well
Danil
oh
Danil
now i have permission denied
Danil
in admin panel
Rajjix
u can't log in u mean?